//---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- // File : API_GdbModify.cpp Data : 06.10.14 Versione : 1.5i5 // Contenuto : Funzioni di modifica geometrica per API. // // // // Modifiche : 06.10.14 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" #include "API_Macro.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EgkGeoPoint3d.h" #include "/EgtDev/Include/EgkGeoVector3d.h" #include "/EgtDev/Include/EgkSurfTriMesh.h" #include "/EgtDev/Include/EgkExtText.h" #include "/EgtDev/Include/EGnStringConverter.h" #include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; //------------------------------------------------------------------------------- BOOL __stdcall EgtChangeGroupFrame( int nId, double ptOrig[3], double vtX[3], double vtY[3], double vtZ[3]) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // recupero il riferimento del gruppo Frame3d* pFrame = pGeomDB->GetGroupFrame( nId) ; if ( pFrame == nullptr) return FALSE ; // imposto il nuovo riferimento Frame3d frNew ; if ( ! frNew.Set( ptOrig, vtX, vtY, vtZ)) return FALSE ; *pFrame = frNew ; return TRUE ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtChangeVectorBase( int nId, const double ptB[3]) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // recupero il vettore IGeoVector3d* pGVect = GetGeoVector3d( pGeomDB->GetGeoObj( nId)) ; if ( pGVect == nullptr) return FALSE ; // imposto il nuovo punto di base return ( pGVect->ChangeBase( ptB) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtModifyText( int nId, const wchar_t* wsNewText) { return EgtModifyText( nId, wstrztoA( wsNewText)) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtModifyText( int nId, const string& sNewText) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // recupero il testo IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ; if ( pTXT == nullptr) return FALSE ; // eseguo l'operazione return ( pTXT->ModifyText( sNewText) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtChangeTextFont( int nId, const wchar_t* wsNewFont) { return EgtChangeTextFont( nId, wstrztoA( wsNewFont)) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtChangeTextFont( int nId, const string& sNewFont) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // recupero il testo IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ; if ( pTXT == nullptr) return FALSE ; // eseguo l'operazione return ( pTXT->ChangeFont( sNewFont) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtFlipText( int nId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // recupero il testo IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ; if ( pTXT == nullptr) return FALSE ; // eseguo l'operazione return ( pTXT->Flip() ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtMirrorText( int nId, BOOL bOnL) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // recupero il testo IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ; if ( pTXT == nullptr) return FALSE ; // eseguo l'operazione return ( pTXT->Mir( ( bOnL ? true : false)) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtTextToOutline( int nId, int nDestGroupId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // recupero il testo IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ; if ( pTXT == nullptr) return FALSE ; // recupero il riferimento del testo Frame3d frTXT ; if ( ! pGeomDB->GetGlobFrame( nId, frTXT)) return FALSE ; // recupero il riferimento del gruppo destinazione Frame3d frDest ; if ( ! pGeomDB->GetGroupGlobFrame( nDestGroupId, frDest)) return FALSE ; // recupero l'outline del testo ICURVEPLIST lstPCRV ; pTXT->GetOutline( lstPCRV) ; // inserisco le curve nel gruppo destinazione dopo aver sistemato il cambio di riferimento bool bOk = true ; ICURVEPLIST::iterator iIter ; for ( iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) { (*iIter)->LocToLoc( frTXT, frDest) ; if ( pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGroupId, (*iIter)) == GDB_ID_NULL) { delete (*iIter) ; bOk = false ; } } return ( bOk ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtSplitText( int nId, int nDestGroupId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // recupero il testo IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ; if ( pTXT == nullptr) return FALSE ; // recupero il riferimento del testo Frame3d frTXT ; if ( ! pGeomDB->GetGlobFrame( nId, frTXT)) return FALSE ; // recupero il riferimento del gruppo destinazione Frame3d frDest ; if ( ! pGeomDB->GetGroupGlobFrame( nDestGroupId, frDest)) return FALSE ; // recupero l'esplosione del testo in linee singole IEXTTEXTPVECTOR vTxt ; pTXT->SplitOnLineBreak( vTxt) ; // inserisco i nuovi testi nel gruppo destinazione dopo aver sistemato il cambio di riferimento bool bOk = true ; for ( int i = 0 ; i < int( vTxt.size()) ; ++ i) { vTxt[i]->LocToLoc( frTXT, frDest) ; if ( pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGroupId, vTxt[i]) == GDB_ID_NULL) { delete vTxt[i] ; bOk = false ; } } return ( bOk ? TRUE : FALSE) ; }