EgtInterface 1.6e2 :

- esecutore e lua scorporato in EgtExecutor.
This commit is contained in:
Dario Sassi
2015-05-05 22:14:56 +00:00
parent e7ee6d9255
commit 8bc0e986b2
60 changed files with 454 additions and 16260 deletions
+9 -200
View File
@@ -15,17 +15,9 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "API.h"
#include "API_Macro.h"
#include "AuxTools.h"
#include "GeoTools.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EInConst.h"
#include "/EgtDev/Include/EgkGeoPoint3d.h"
#include "/EgtDev/Include/EgkGeoVector3d.h"
#include "/EgtDev/Include/EgkExtText.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EGnStringConverter.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
@@ -39,237 +31,54 @@ __stdcall EgtChangeGroupFrame( int nId, double ptOrig[3],
if ( ! frFrame.Set( ptOrig, vtX, vtY, vtZ))
return FALSE ;
// eseguo
return ( EgtChangeGroupFrame( nId, frFrame, nRefType) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
bool
EgtChangeGroupFrame( int nId, const Frame3d& frNewRef, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
bool bOk = true ;
// recupero il riferimento del gruppo
Frame3d* pFrame = pGeomDB->GetGroupFrame( nId) ;
bOk = bOk && ( pFrame != nullptr) ;
// porto il nuovo riferimento in locale
Frame3d frNewL = frNewRef ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ;
if ( nRefType == RTY_GLOB)
frNewL.ToLoc( frLoc) ;
else /* RTY_GRID */
frNewL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
// aggiorno il gruppo
if ( bOk)
*pFrame = frNewL ;
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtChangeGroupFrame(" + ToString( nId) + ",{{" +
ToString( frNewRef.Orig()) + "},{" +
ToString( frNewRef.VersX()) + "},{" +
ToString( frNewRef.VersY()) + "},{" +
ToString( frNewRef.VersZ()) + "}}," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return bOk ;
return ( ExeChangeGroupFrame( nId, frFrame, nRefType) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
BOOL
__stdcall EgtChangeVectorBase( int nId, const double ptB[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
bool bOk = true ;
// recupero il vettore
IGeoVector3d* pGVect = GetGeoVector3d( pGeomDB->GetGeoObj( nId)) ;
bOk = bOk && ( pGVect != nullptr) ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ;
// porto il nuovo punto base in locale
Point3d ptBL = GetPointLocal( pGeomDB, ptB, nRefType, frLoc) ;
// imposto il nuovo punto di base
bOk = bOk && pGVect->ChangeBase( ptBL) ;
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtChangeVectorBase(" + ToString( nId) + ",{" +
ToString( Point3d( ptB)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return ( bOk ? TRUE : FALSE) ;
return ( ExeChangeVectorBase( nId, ptB, nRefType) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
BOOL
__stdcall EgtModifyText( int nId, const wchar_t* wsNewText)
{
return ( EgtModifyText( nId, wstrztoA( wsNewText)) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
bool
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) ;
return ( ExeModifyText( nId, wstrztoA( wsNewText)) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
BOOL
__stdcall EgtChangeTextFont( int nId, const wchar_t* wsNewFont)
{
return ( EgtChangeTextFont( nId, wstrztoA( wsNewFont)) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
bool
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) ;
return ( ExeChangeTextFont( nId, wstrztoA( wsNewFont)) ? 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) ;
return ( ExeFlipText( nId) ? 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) ;
return ( ExeMirrorText( nId, ( bOnL != FALSE)) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtExplodeText( int nId, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero il testo
IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pTXT != nullptr) ;
// recupero l'outline del testo
ICURVEPLIST lstPCRV ;
bOk = bOk && pTXT->GetOutline( lstPCRV) ;
// inserisco le curve nella stessa posizione del testo
int nFirstId = GDB_ID_NULL ;
int nCount = 0 ;
for ( ICURVEPLIST::iterator iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) {
// inserisco la curva nello stesso gruppo e nello stesso posto del GeomDB
int nCrvId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, (*iIter)) ;
bOk = bOk && ( nCrvId != GDB_ID_NULL) ;
// copio gli attributi
bOk = bOk && pGeomDB->CopyAttributes( nId, nCrvId) ;
// aggiorno contatori
if ( bOk) {
if ( nFirstId == GDB_ID_NULL)
nFirstId = nCrvId ;
++ nCount ;
}
}
nFirstId = ( bOk ? nFirstId : GDB_ID_NULL) ;
// elimino il testo originale
bOk = bOk && pGeomDB->Erase( nId) ;
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtExplodeText(" + ToString( nId) + ")" +
" -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultati
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
return ExeExplodeText( nId, pnCount) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtSplitText( int nId, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero il testo
IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pTXT != nullptr) ;
// recupero l'esplosione del testo in linee singole
IEXTTEXTPVECTOR vTxt ;
bOk = bOk && pTXT->SplitOnLineBreak( vTxt) ;
// inserisco i nuovi testi nella stessa posizione del testo
int nFirstId = GDB_ID_NULL ;
int nCount = 0 ;
for ( int i = 0 ; i < int( vTxt.size()) ; ++ i) {
// inserimento
int nCrvId = ( bOk ? pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, vTxt[i]) : GDB_ID_NULL) ;
if ( nCrvId != GDB_ID_NULL) {
// copio gli attributi
bOk = bOk && pGeomDB->CopyAttributes( nId, nCrvId) ;
// aggiorno contatori
if ( bOk) {
if ( nFirstId == GDB_ID_NULL)
nFirstId = nCrvId ;
++ nCount ;
}
}
else {
bOk = false ;
delete vTxt[i] ;
}
}
nFirstId = ( bOk ? nFirstId : GDB_ID_NULL) ;
// elimino il testo originale
bOk = bOk && pGeomDB->Erase( nId) ;
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSplitText(" + ToString( nId) + ")" +
" -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultati
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
return ExeSplitText( nId, pnCount) ;
}