//---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- // File : API_GdbObjAttribs.cpp Data : 03.09.14 Versione : 1.5i1 // Contenuto : Funzioni sugli attributi degli oggetti di GeomDB per API. // // // // Modifiche : 03.09.14 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" #include "API_Macro.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnStringConverter.h" #include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; //----------------------------------------------------------------------------- BOOL __stdcall EgtSetLevel( int nGseCtx, int nId, int nLevel) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // imposto il livello return ( pGeomDB->SetLevel( nId, nLevel) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtRevertLevel( int nGseCtx, int nId) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // porto il livello allo stato precedente return ( pGeomDB->RevertLevel( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetLevel( int nGseCtx, int nId, int* pnLevel) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // verifico il parametro if ( pnLevel == nullptr) return FALSE ; // recupero il livello return ( pGeomDB->GetLevel( nId, *pnLevel) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetCalcLevel( int nGseCtx, int nId, int* pnLevel) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // verifico il parametro if ( pnLevel == nullptr) return FALSE ; // recupero il modo return ( pGeomDB->GetCalcLevel( nId, *pnLevel) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetMode( int nGseCtx, int nId, int nMode) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // imposto il modo return ( pGeomDB->SetMode( nId, nMode) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtRevertMode( int nGseCtx, int nId) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // porto il modo allo stato precedente return ( pGeomDB->RevertMode( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetMode( int nGseCtx, int nId, int* pnMode) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // verifico il parametro if ( pnMode == nullptr) return FALSE ; // recupero il modo return ( pGeomDB->GetMode( nId, *pnMode) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetCalcMode( int nGseCtx, int nId, int* pnMode) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // verifico il parametro if ( pnMode == nullptr) return FALSE ; // recupero il modo return ( pGeomDB->GetCalcMode( nId, *pnMode) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetStatus( int nGseCtx, int nId, int nStat) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // imposto il modo return ( pGeomDB->SetStatus( nId, nStat) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtRevertStatus( int nGseCtx, int nId) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // porto lo stato al valore precedente return ( pGeomDB->RevertStatus( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetStatus( int nGseCtx, int nId, int* pnStat) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // verifico il parametro if ( pnStat == nullptr) return FALSE ; // recupero il modo return ( pGeomDB->GetStatus( nId, *pnStat) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetCalcStatus( int nGseCtx, int nId, int* pnStat) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // verifico il parametro if ( pnStat == nullptr) return FALSE ; // recupero il modo return ( pGeomDB->GetCalcStatus( nId, *pnStat) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetMark( int nGseCtx, int nId) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // imposto l'evidenziazione return ( pGeomDB->SetMark( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtResetMark( int nGseCtx, int nId) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // cancello l'evidenziazione return ( pGeomDB->ResetMark( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetMark( int nGseCtx, int nId, BOOL* pbMark) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // verifico il parametro if ( pbMark == nullptr) return FALSE ; // recupero il modo return ( pGeomDB->GetMark( nId, *pbMark) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetCalcMark( int nGseCtx, int nId, BOOL* pbMark) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // verifico il parametro if ( pbMark == nullptr) return FALSE ; // recupero il modo return ( pGeomDB->GetCalcMark( nId, *pbMark) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtStdColor( const wchar_t* wsName, int& nRed, int& nGreen, int& nBlue, int& nAlpha) { return EgtStdColor( wstrztoA( wsName), nRed, nGreen, nBlue, nAlpha) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtStdColor( const string& sName, int& nRed, int& nGreen, int& nBlue, int& nAlpha) { // recupero il colore standard Color cCol ; if ( GetStdColor( sName, cCol)) { nRed = cCol.GetIntRed() ; nGreen = cCol.GetIntGreen() ; nBlue = cCol.GetIntBlue() ; nAlpha = cCol.GetIntAlpha() ; return TRUE ; } else return FALSE ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetColor( int nGseCtx, int nId, int nRed, int nGreen, int nBlue, int nAlpha) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // assegno il colore Color cCol( nRed, nGreen, nBlue, nAlpha) ; return ( pGeomDB->SetMaterial( nId, cCol) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetColor( int nGseCtx, int nId, int& nRed, int& nGreen, int& nBlue, int& nAlpha) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // recupero il colore Color cCol ; if ( pGeomDB->GetMaterial( nId, cCol)) { nRed = cCol.GetIntRed() ; nGreen = cCol.GetIntGreen() ; nBlue = cCol.GetIntBlue() ; nAlpha = cCol.GetIntAlpha() ; return TRUE ; } else return FALSE ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetCalcColor( int nGseCtx, int nId, int& nRed, int& nGreen, int& nBlue, int& nAlpha) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // recupero il colore Color cCol ; if ( pGeomDB->GetCalcMaterial( nId, cCol)) { nRed = cCol.GetIntRed() ; nGreen = cCol.GetIntGreen() ; nBlue = cCol.GetIntBlue() ; nAlpha = cCol.GetIntAlpha() ; return TRUE ; } else return FALSE ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetName( int nGseCtx, int nId, const wchar_t* wsName) { return EgtSetName( nGseCtx, nId, wstrztoA( wsName)) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetName( int nGseCtx, int nId, const string& sName) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // assegno il nome return ( pGeomDB->SetName( nId, sName) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetName( int nGseCtx, int nId, wchar_t*& wsName) { string sName ; if ( ! EgtGetName( nGseCtx, nId, sName)) return FALSE ; wsName = _wcsdup( stringtoW( sName)) ; return (( wsName == nullptr) ? FALSE : TRUE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetName( int nGseCtx, int nId, string& sName) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // recupero il nome return pGeomDB->GetName( nId, sName) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtExistsName( int nGseCtx, int nId) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // verifico esistenza del nome return ( pGeomDB->ExistsName( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtRemoveName( int nGseCtx, int nId) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // rimuovo il nome return ( pGeomDB->RemoveName( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetInfo( int nGseCtx, int nId, const wchar_t* wsKey, const wchar_t* wsInfo) { return EgtSetInfo( nGseCtx, nId, wstrztoA( wsKey), wstrztoA( wsInfo)) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetInfo( int nGseCtx, int nId, const string& sKey, const string& sInfo) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // assegno la info return ( pGeomDB->SetInfo( nId, sKey, sInfo) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetInfo( int nGseCtx, int nId, const wchar_t* wsKey, wchar_t*& wsInfo) { string sInfo ; if ( ! EgtGetInfo( nGseCtx, nId, wstrztoA( wsKey), sInfo)) return FALSE ; wsInfo = _wcsdup( stringtoW( sInfo)) ; return (( wsInfo == nullptr) ? FALSE : TRUE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetInfo( int nGseCtx, int nId, const string& sKey, string& sInfo) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // recupero la info return pGeomDB->GetInfo( nId, sKey, sInfo) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtExistsInfo( int nGseCtx, int nId, const wchar_t* wsKey) { return EgtExistsInfo( nGseCtx, nId, wstrztoA( wsKey)) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtExistsInfo( int nGseCtx, int nId, const string& sKey) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // verifico esistenza info return ( pGeomDB->ExistsInfo( nId, sKey) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtRemoveInfo( int nGseCtx, int nId, const wchar_t* wsKey) { return EgtRemoveInfo( nGseCtx, nId, wstrztoA( wsKey)) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtRemoveInfo( int nGseCtx, int nId, const string& sKey) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // rimuovo la info return ( pGeomDB->RemoveInfo( nId, sKey) ? TRUE : FALSE) ; }