diff --git a/API.h b/API.h index d7337a2..db47a85 100644 --- a/API.h +++ b/API.h @@ -30,6 +30,8 @@ bool EgtGetVersionInfo( std::string& sVer, const char* szNewLine) ; bool EgtSetGridFrame( const Frame3d& frFrame) ; bool EgtGetGridFrame( int nRefId, Frame3d& frFrame) ; bool EgtGetGridVersZ( int nRefId, Vector3d& vtVersZ) ; +bool EgtSetCurrFilePath( const std::string& sFilePath) ; +bool EgtGetCurrFilePath( std::string& sFilePath) ; bool EgtOpenFile( const std::string& sFilePath) ; bool EgtInsertFile( const std::string& sFilePath) ; bool EgtSaveFile( const std::string& sFilePath, int nFlag) ; diff --git a/API_Exchange.cpp b/API_Exchange.cpp index 9eda291..f991d1c 100644 --- a/API_Exchange.cpp +++ b/API_Exchange.cpp @@ -80,17 +80,20 @@ __stdcall EgtImportDxf( const wchar_t* wsFilePath) bool EgtImportDxf( const string& sFilePath) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, false) bool bOk = true ; // importo il file DXF // aggiungo un gruppo pezzo - int nPartId = pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; + int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; // preparo l'importatore PtrOwner pImpDxf( CreateImportDxf()) ; bOk = bOk && ! IsNull( pImpDxf) ; // eseguo l'importazione - bOk = bOk && pImpDxf->Import( sFilePath, pGeomDB, nPartId) ; + bOk = bOk && pImpDxf->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId) ; + // aggiorno stato file corrente + pGseCtx->m_sFilePath = sFilePath ; + pGseCtx->m_bModified = true ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLuaPath = sFilePath ; @@ -114,18 +117,21 @@ __stdcall EgtImportStl( const wchar_t* wsFilePath) bool EgtImportStl( const string& sFilePath) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, false) bool bOk = true ; // importo il file STL // aggiungo un gruppo pezzo e un gruppo layer - int nPartId = pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; - int nLayerId = pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ; + int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; + int nLayerId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ; // preparo l'importatore PtrOwner pImpStl( CreateImportStl()) ; bOk = bOk && ! IsNull( pImpStl) ; // eseguo l'importazione - bOk = bOk && pImpStl->Import( sFilePath, pGeomDB, nLayerId) ; + bOk = bOk && pImpStl->Import( sFilePath, pGseCtx->m_pGeomDB, nLayerId) ; + // aggiorno stato file corrente + pGseCtx->m_sFilePath = sFilePath ; + pGseCtx->m_bModified = true ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLuaPath = sFilePath ; @@ -149,17 +155,20 @@ __stdcall EgtImportCnc( const wchar_t* wsFilePath) bool EgtImportCnc( const string& sFilePath) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, false) bool bOk = true ; // importo il file CNC // aggiungo un gruppo pezzo - int nPartId = pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; + int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; // preparo l'importatore PtrOwner pImpCnc( CreateImportCnc()) ; bOk = bOk && ! IsNull( pImpCnc) ; // eseguo l'importazione - bOk = bOk && pImpCnc->Import( sFilePath, pGeomDB, nPartId) ; + bOk = bOk && pImpCnc->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId) ; + // aggiorno stato file corrente + pGseCtx->m_sFilePath = sFilePath ; + pGseCtx->m_bModified = true ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLuaPath = sFilePath ; diff --git a/API_GdbCreate.cpp b/API_GdbCreate.cpp index e41a09d..37824d4 100644 --- a/API_GdbCreate.cpp +++ b/API_GdbCreate.cpp @@ -49,6 +49,7 @@ __stdcall EgtCreateGroup( int nParentId, const double ptOrig[3], } // creo il gruppo int nId = ( bOk ? pGeomDB->AddGroup( GDB_ID_NULL, nParentId, frFrameL) : GDB_ID_NULL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua ; @@ -99,6 +100,7 @@ __stdcall EgtCreateGeoPoint( int nParentId, const double ptP[3], int nRefType) bOk = bOk && pGeoPnt->Set( ptPL) ; // inserisco il punto nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoPnt)) : GDB_ID_NULL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtPoint(" + ToString( nParentId) + ",{" + @@ -140,6 +142,7 @@ __stdcall EgtCreateGeoVector( int nParentId, const double vtV[3], const double p bOk = bOk && pGeoVct->Set( vtVL, ptBL) ; // inserisco il vettore nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoVct)) : GDB_ID_NULL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua ; @@ -195,6 +198,7 @@ __stdcall EgtCreateGeoFrame( int nParentId, const double ptOrig[3], bOk = bOk & pGeoFrm->Set( ptOrigL, vtXL, vtYL, vtZL) ; // inserisco il riferimento nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoFrm)) : GDB_ID_NULL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtFrame(" + ToString( nParentId) + ",{{" + @@ -250,6 +254,7 @@ EgtCreateText( int nParentId, const Point3d& ptP, double dAngRotDeg, bOk = bOk && pTXT->Set( ptPL, vtNL, vtDL, sText, "", false, dH) ; // inserisco il testo nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) : GDB_ID_NULL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtText(" + ToString( nParentId) + ",{" + @@ -306,6 +311,7 @@ EgtCreateTextEx( int nParentId, const Point3d& ptP, const Vector3d& vtN, const V bOk = bOk && pTXT->Set( ptPL, vtNL, vtDL, sText, sFont, bItalic, dH) ; // inserisco il testo nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) : GDB_ID_NULL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtTextEx(" + ToString( nParentId) + ",{" + @@ -368,6 +374,7 @@ EgtCreateTextAdv( int nParentId, const Point3d& ptP, const Vector3d& vtN, const bOk = bOk && pTXT->Set( ptPL, vtNL, vtDL, sText, sFont, nW, bItalic, dH, dRat, dAddAdv, nInsPos) ; // inserisco il testo nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) : GDB_ID_NULL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtTextAdv(" + ToString( nParentId) + ",{" + diff --git a/API_GdbCreateCurve.cpp b/API_GdbCreateCurve.cpp index 5a22049..81d71f7 100644 --- a/API_GdbCreateCurve.cpp +++ b/API_GdbCreateCurve.cpp @@ -89,6 +89,7 @@ __stdcall EgtCreateCurveLine( int nParentId, const double ptIni[3], const double pCrvLine->SetExtrusion( vtExtrL) ; // inserisco la linea nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtLine(" + ToString( nParentId) + ",{" + @@ -213,6 +214,7 @@ __stdcall EgtCreateCurveLineEx( int nParentId, const double ptIni[3], int nSepI, pCrvLine->SetExtrusion( vtExtrL) ; // inserisco la linea nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua ; @@ -536,6 +538,7 @@ __stdcall EgtCreateCurveLinePVL( int nParentId, const double ptIni[3], pCrvLine->SetExtrusion( vtExtrL) ; // inserisco la linea nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtLinePVL(" + ToString( nParentId) + ",{" + @@ -602,6 +605,7 @@ __stdcall EgtCreateCurveLineMinPointCurve( int nParentId, pCrvLine->SetExtrusion( vtExtrL) ; // inserisco la linea nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtLineMinPointCurve(" + ToString( nParentId) + ",{" + @@ -653,6 +657,7 @@ __stdcall EgtCreateCurveCircle( int nParentId, const double ptCen[3], pCrvArc->SetExtrusion( vtExtrL) ; // inserisco l'arco nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtCircle(" + ToString( nParentId) + ",{" + @@ -709,6 +714,7 @@ __stdcall EgtCreateCurveCircleCPN( int nParentId, const double ptCen[3], pCrvArc->SetExtrusion( vtExtrL) ; // inserisco l'arco nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtCircleCPN(" + ToString( nParentId) + ",{" + @@ -763,6 +769,7 @@ __stdcall EgtCreateCurveCircle3P( int nParentId, const double ptP1[3], pCrvArc->SetExtrusion( vtExtrL) ; // inserisco l'arco nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtCircle3P(" + ToString( nParentId) + ",{" + @@ -818,6 +825,7 @@ __stdcall EgtCreateCurveArc( int nParentId, pCrvArc->SetExtrusion( vtExtrL) ; // inserisco l'arco nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtArc(" + ToString( nParentId) + ",{" + @@ -878,6 +886,7 @@ __stdcall EgtCreateCurveArcC2PN( int nParentId, const double ptCen[3], const dou pCrvArc->SetExtrusion( vtExtrL) ; // inserisco l'arco nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtArcC2PN(" + ToString( nParentId) + ",{" + @@ -945,6 +954,7 @@ __stdcall EgtCreateCurveArc3P( int nParentId, const double ptP1[3], nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ; } } + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtArc3P(" + ToString( nParentId) + ",{" + @@ -1014,6 +1024,7 @@ __stdcall EgtCreateCurveArc2PVN( int nParentId, const double ptStart[3], const d nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ; } } + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtArc2PVN(" + ToString( nParentId) + ",{" + @@ -1081,6 +1092,7 @@ EgtCreateCurveBezier( int nParentId, int nDegree, const PNTVECTOR& vPnt, int nRe pCrvBez->SetExtrusion( vtExtrL) ; // inserisco la curva nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) : GDB_ID_NULL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sPC ; @@ -1152,6 +1164,7 @@ EgtCreateCurveBezierRational( int nParentId, int nDegree, const PNTUVECTOR& vPnt pCrvBez->SetExtrusion( vtExtrL) ; // inserisco la curva nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) : GDB_ID_NULL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sPC ; @@ -1208,6 +1221,7 @@ __stdcall EgtCreateCurveBezierFromArc( int nParentId, int nArcId, BOOL bErase) return GDB_ID_NULL ; } } + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtCurveBezierFromArc(" + ToString( nParentId) + "," + @@ -1285,6 +1299,7 @@ MyCreateCurveCompo( int nParentId, const INTVECTOR& vIds, bool bErase) pCrvCompo->SetThickness( dThick) ; // inserisco la curva composita nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) ; + EgtSetModified() ; // se ok e richiesto, cancello le curve originali if ( nId != GDB_ID_NULL && bErase) { for ( Iter = vIds.begin() ; Iter != vIds.end() ; ++Iter) { @@ -1456,6 +1471,7 @@ EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, { // eseguo int nFirstId = MyCreateCurveCompoByChain( nParentId, vIds, ptNear, bErase, nRefType) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sIds ; @@ -1511,6 +1527,7 @@ EgtCreateCurveCompoFromPoints( int nParentId, const PolyLine& PL, int nRefType) pCrvCompo->LocToLoc( pGeomDB->GetGridFrame(), frDest) ; // inserisco la curva composita nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) : GDB_ID_NULL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sPnt ; @@ -1564,6 +1581,7 @@ EgtCreateCurveCompoFromPointBulges( int nParentId, const PolyArc& PA, int nRefTy pCrvCompo->LocToLoc( pGeomDB->GetGridFrame(), frDest) ; // inserisco la curva composita nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) : GDB_ID_NULL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sPnt ; @@ -1622,6 +1640,7 @@ __stdcall EgtCreateCurveCompoByApprox( int nParentId, int nSouId, BOOL bArcsVsLi } // inserisco la curva composita nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCC)) : GDB_ID_NULL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtCurveCompoByApprox(" + ToString( nParentId) + "," + @@ -1740,6 +1759,7 @@ __stdcall EgtCreatePolygonFromSide( int nParentId, int nNumSides, const double p bOk = bOk && pCrvCompo->SetExtrusion( vtExtrL) ; // inserisco la curva nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) : GDB_ID_NULL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtPolygonFromSide(" + ToString( nParentId) + "," + diff --git a/API_GdbCreateSurf.cpp b/API_GdbCreateSurf.cpp index 06d069a..9f4b6f0 100644 --- a/API_GdbCreateSurf.cpp +++ b/API_GdbCreateSurf.cpp @@ -46,6 +46,7 @@ __stdcall EgtCreateSurfTriMeshByContour( int nParentId, int nCrvId, double dLinT bOk = false ; // inserisco la superficie nel DB int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSurfTmByContour(" + ToString( nParentId) + "," + @@ -85,6 +86,7 @@ __stdcall EgtCreateSurfTriMeshByExtrusion( int nParentId, int nCrvId, const doub bOk = bOk && pSTM->CreateByExtrusion( PL, vtExtrL) ; // inserisco la superficie nel DB int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSurfTmByExtrusion(" + ToString( nParentId) + "," + @@ -145,6 +147,7 @@ __stdcall EgtCreateSurfTriMeshByScrewing( int nParentId, int nCrvId, bOk = bOk && pSTM->CreateByScrewing( PL, ptAxL, vtAxL, dAngRotDeg, dStepRotDeg, dMove) ; // inserisco la superficie nel DB int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSurfTmByScrewing(" + ToString( nParentId) + "," + @@ -187,6 +190,7 @@ __stdcall EgtCreateSurfTriMeshRuled( int nParentId, int nCrvId1, int nCrvId2, do bOk = false ; // inserisco la superficie trimesh nel DB int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSurfTmRuled(" + ToString( nParentId) + "," + diff --git a/API_GdbModifyCurve.cpp b/API_GdbModifyCurve.cpp index 799d29e..7abd4a9 100644 --- a/API_GdbModifyCurve.cpp +++ b/API_GdbModifyCurve.cpp @@ -56,6 +56,7 @@ __stdcall EgtInvertCurve( int nId) nI = pGeomDB->GetNextSelectedObj() ; } } + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtInvertCurve(" + ( nId != GDB_ID_SEL ? ToString( nId): "GDB_ID_SEL") + ")" + @@ -76,6 +77,7 @@ __stdcall EgtOffsetCurve( int nId, double dDist, int nType) ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; // eseguo l'offset bool bOk = ( pCurve != nullptr) && pCurve->SimpleOffset( dDist, nType) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua ; @@ -116,6 +118,7 @@ __stdcall EgtModifyCurveStartPoint( int nId, const double ptP[3], int nRefType) } // ne modifico il punto iniziale bOk = bOk && pCurve->ModifyStart( ptPL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtModifyCurveStartPoint(" + ToString( nId) + ",{" + @@ -150,6 +153,7 @@ __stdcall EgtModifyCurveEndPoint( int nId, const double ptP[3], int nRefType) } // ne modifico il punto finale bOk = bOk && pCurve->ModifyEnd( ptPL) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtModifyCurveEndPoint(" + ToString( nId) + ",{" + @@ -238,6 +242,7 @@ EgtModifyCurveExtrusion( INTVECTOR& vIds, const Vector3d& vtExtr, int nRefType) } } } + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sIds ; @@ -306,6 +311,7 @@ __stdcall EgtModifyCurveThickness( int nId, double dThick) nI = pGeomDB->GetNextSelectedObj() ; } } + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtModifyCurveThickness(" + ( nId != GDB_ID_SEL ? ToString( nId) : "GDB_ID_SEL") + "," + @@ -328,7 +334,9 @@ __stdcall EgtTrimCurveStartAtLen( int nId, double dLen) if ( pCurve == nullptr) return FALSE ; // taglio la curva all'inizio - return ( pCurve->TrimStartAtLen( dLen) ? TRUE : FALSE) ; + bool bOk = pCurve->TrimStartAtLen( dLen) ; + EgtSetModified() ; + return ( bOk ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- @@ -342,7 +350,9 @@ __stdcall EgtTrimCurveEndAtLen( int nId, double dLen) if ( pCurve == nullptr) return FALSE ; // taglio la curva alla fine - return ( pCurve->TrimEndAtLen( dLen) ? TRUE : FALSE) ; + bool bOk = pCurve->TrimEndAtLen( dLen) ; + EgtSetModified() ; + return ( bOk ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- @@ -356,7 +366,9 @@ __stdcall EgtTrimCurveStartAtParam( int nId, double dPar) if ( pCurve == nullptr) return FALSE ; // taglio la curva all'inizio - return ( pCurve->TrimStartAtParam( dPar) ? TRUE : FALSE) ; + bool bOk = pCurve->TrimStartAtParam( dPar) ; + EgtSetModified() ; + return ( bOk ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- @@ -370,7 +382,9 @@ __stdcall EgtTrimCurveEndAtParam( int nId, double dPar) if ( pCurve == nullptr) return FALSE ; // taglio la curva alla fine - return ( pCurve->TrimEndAtParam( dPar) ? TRUE : FALSE) ; + bool bOk = pCurve->TrimEndAtParam( dPar) ; + EgtSetModified() ; + return ( bOk ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- @@ -384,7 +398,9 @@ __stdcall EgtTrimCurveStartEndAtParam( int nId, double dParS, double dParE) if ( pCurve == nullptr) return FALSE ; // taglio la curva agli estremi - return ( pCurve->TrimStartEndAtParam( dParS, dParE) ? TRUE : FALSE) ; + bool bOk = pCurve->TrimStartEndAtParam( dParS, dParE) ; + EgtSetModified() ; + return ( bOk ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- @@ -398,7 +414,9 @@ __stdcall EgtExtendCurveStartByLen( int nId, double dLen) if ( pCurve == nullptr) return FALSE ; // estendo la curva all'inizio - return ( pCurve->ExtendStartByLen( dLen) ? TRUE : FALSE) ; + bool bOk = pCurve->ExtendStartByLen( dLen) ; + EgtSetModified() ; + return ( bOk ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- @@ -412,7 +430,9 @@ __stdcall EgtExtendCurveEndByLen( int nId, double dLen) if ( pCurve == nullptr) return FALSE ; // estendo la curva alla fine - return ( pCurve->ExtendEndByLen( dLen) ? TRUE : FALSE) ; + bool bOk = pCurve->ExtendEndByLen( dLen) ; + EgtSetModified() ; + return ( bOk ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- @@ -454,6 +474,7 @@ __stdcall EgtTrimExtendCurveByLen( int nId, double dLen, const double ptNear[3], } else bOk = false ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtTrimExtendCurveByLen(" + ToString( nId) + "," + @@ -517,6 +538,7 @@ __stdcall EgtSplitCurveAtPoint( int nId, double ptOn[3], int nRefType) bOk = bOk && pCurve->TrimEndAtParam( dU) ; bOk = bOk && ( EgtTrimCurveStartAtParam( nCopyId, dU) != FALSE) ; } + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSplitCurveAtPoint(" + ToString( nId) + ",{" + @@ -680,6 +702,7 @@ __stdcall EgtExplodeCurveCompo( int nId) } // elimino la curva composita ormai vuota bOk = bOk && pGeomDB->Erase( nId) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtExplodeCurveCompo(" + ToString( nId) + ")" + @@ -733,6 +756,7 @@ __stdcall EgtExplodeCurveBezier( int nId, BOOL bArcsVsLines, double dLinTol) } // elimino la curva di Bezier bOk = bOk && pGeomDB->Erase( nId) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtExplodeCurveBezier(" + ToString( nId) + "," + diff --git a/API_GdbObjAttribs.cpp b/API_GdbObjAttribs.cpp index 416775d..34fb735 100644 --- a/API_GdbObjAttribs.cpp +++ b/API_GdbObjAttribs.cpp @@ -30,7 +30,9 @@ __stdcall EgtSetLevel( int nId, int nLevel) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // imposto il livello - return ( pGeomDB->SetLevel( nId, nLevel) ? TRUE : FALSE) ; + bool bOk = pGeomDB->SetLevel( nId, nLevel) ; + EgtSetModified() ; + return ( bOk ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -40,7 +42,9 @@ __stdcall EgtRevertLevel( int nId) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // porto il livello allo stato precedente - return ( pGeomDB->RevertLevel( nId) ? TRUE : FALSE) ; + bool bOk = pGeomDB->RevertLevel( nId) ; + EgtSetModified() ; + return ( bOk ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -76,7 +80,9 @@ __stdcall EgtSetMode( int nId, int nMode) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // imposto il modo - return ( pGeomDB->SetMode( nId, nMode) ? TRUE : FALSE) ; + bool bOk = pGeomDB->SetMode( nId, nMode) ; + EgtSetModified() ; + return ( bOk ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -86,7 +92,9 @@ __stdcall EgtRevertMode( int nId) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // porto il modo allo stato precedente - return ( pGeomDB->RevertMode( nId) ? TRUE : FALSE) ; + bool bOk = pGeomDB->RevertMode( nId) ; + EgtSetModified() ; + return ( bOk ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -123,6 +131,16 @@ __stdcall EgtSetStatus( int nId, int nStat) VERIFY_GEOMDB( pGeomDB, FALSE) // imposto il modo bool bOk = pGeomDB->SetStatus( nId, nStat) ; + // se nascosto pezzo corrente o layer corrente + if ( nStat == GDB_ST_OFF) { + int nCurrPartId = EgtGetCurrPart() ; + if ( nId == nCurrPartId) + EgtResetCurrPartLayer() ; + else if ( nId == EgtGetCurrLayer()) + EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstVisibleLayer( nCurrPartId)) ; + } + // dichiaro progetto modificato + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sStat = "'ON'" ; @@ -146,7 +164,9 @@ __stdcall EgtRevertStatus( int nId) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // porto lo stato al valore precedente - return ( pGeomDB->RevertStatus( nId) ? TRUE : FALSE) ; + bool bOk = pGeomDB->RevertStatus( nId) ; + EgtSetModified() ; + return ( bOk ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -182,7 +202,9 @@ __stdcall EgtSetMark( int nId) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // imposto l'evidenziazione - return ( pGeomDB->SetMark( nId) ? TRUE : FALSE) ; + bool bOk = pGeomDB->SetMark( nId) ; + EgtSetModified() ; + return ( bOk ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -192,7 +214,9 @@ __stdcall EgtResetMark( int nId) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // cancello l'evidenziazione - return ( pGeomDB->ResetMark( nId) ? TRUE : FALSE) ; + bool bOk = pGeomDB->ResetMark( nId) ; + EgtSetModified() ; + return ( bOk ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -258,6 +282,7 @@ __stdcall EgtSetColor( int nId, const int ObjCol[4]) nI = pGeomDB->GetNextSelectedObj() ; } } + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSetColor(" + ( nId != GDB_ID_SEL ? ToString( nId): "GDB_ID_SEL") + ",{" + @@ -289,6 +314,7 @@ __stdcall EgtResetColor( int nId) nI = pGeomDB->GetNextSelectedObj() ; } } + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtResetColor(" + ( nId != GDB_ID_SEL ? ToString( nId): "GDB_ID_SEL") + ")" + @@ -352,6 +378,7 @@ EgtSetName( int nId, const string& sName) VERIFY_GEOMDB( pGeomDB, false) // assegno il nome bool bOk = pGeomDB->SetName( nId, sName) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSetName(" + ToString( nId) + ",'" + @@ -368,7 +395,7 @@ BOOL __stdcall EgtGetName( int nId, wchar_t*& wsName) { if ( &wsName == nullptr) - return false ; + return FALSE ; string sName ; if ( ! EgtGetName( nId, sName)) return FALSE ; @@ -404,6 +431,7 @@ __stdcall EgtRemoveName( int nId) VERIFY_GEOMDB( pGeomDB, FALSE) // rimuovo il nome bool bOk = pGeomDB->RemoveName( nId) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtRemoveName(" + ToString( nId) + ")" + @@ -429,6 +457,7 @@ EgtSetInfo( int nId, const string& sKey, const string& sInfo) VERIFY_GEOMDB( pGeomDB, FALSE) // assegno la info bool bOk = pGeomDB->SetInfo( nId, sKey, sInfo) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSetInfo(" + ToString( nId) + ",'" + @@ -455,7 +484,9 @@ EgtSetInfo( int nId, const string& sKey, int nInfo) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // assegno la info - return pGeomDB->SetInfo( nId, sKey, nInfo) ; + bool bOk = pGeomDB->SetInfo( nId, sKey, nInfo) ; + EgtSetModified() ; + return bOk ; } //----------------------------------------------------------------------------- @@ -532,6 +563,7 @@ EgtRemoveInfo( int nId, const string& sKey) VERIFY_GEOMDB( pGeomDB, FALSE) // rimuovo la info bool bOk = pGeomDB->RemoveInfo( nId, sKey) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtRemoveInfo(" + ToString( nId) + ",'" + diff --git a/API_GdbObjSelection.cpp b/API_GdbObjSelection.cpp index 1cacde5..a964fa2 100644 --- a/API_GdbObjSelection.cpp +++ b/API_GdbObjSelection.cpp @@ -113,32 +113,20 @@ __stdcall EgtDeselectAll( void) //----------------------------------------------------------------------------- BOOL -__stdcall EgtSelectPartObjs( int nPartId) +__stdcall EgtSelectGroupObjs( int nGroupId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) bool bOk = true ; - // verifico sia veramente un pezzo (gruppo sotto la radice) - if ( pGeomDB->GetGdbType( nPartId) == GDB_TY_GROUP && - pGeomDB->GetParentId( nPartId) == GDB_ID_ROOT) { - // ciclo sugli oggetti del pezzo - int nId = pGeomDB->GetFirstInGroup( nPartId) ; - while ( nId != GDB_ID_NULL) { - // se è gruppo seleziono i suoi componenti - if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) - pGeomDB->SelectGroupObjs( nId) ; - // altrimenti lo seleziono direttamente - else - pGeomDB->SelectObj( nId) ; - // passo al successivo - nId = pGeomDB->GetNext( nId) ; - } + // verifico sia un gruppo + if ( pGeomDB->GetGdbType( nGroupId) == GDB_TY_GROUP) { + bOk = pGeomDB->SelectGroupObjs( nGroupId) ; } else bOk = false ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtSelectPartObjs(" + ToString( nPartId) + ")" + + string sLua = "EgtSelectGroupObjs(" + ToString( nGroupId) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -148,94 +136,20 @@ __stdcall EgtSelectPartObjs( int nPartId) //----------------------------------------------------------------------------- BOOL -__stdcall EgtDeselectPartObjs( int nPartId) +__stdcall EgtDeselectGroupObjs( int nGroupId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) bool bOk = true ; - // verifico sia veramente un pezzo (gruppo sotto la radice) - if ( pGeomDB->GetGdbType( nPartId) == GDB_TY_GROUP && - pGeomDB->GetParentId( nPartId) == GDB_ID_ROOT) { - // ciclo sugli oggetti del pezzo - int nId = pGeomDB->GetFirstInGroup( nPartId) ; - while ( nId != GDB_ID_NULL) { - // se è gruppo deseleziono i suoi componenti - if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) - pGeomDB->DeselectGroupObjs( nId) ; - // altrimenti lo deseleziono direttamente - else - pGeomDB->DeselectObj( nId) ; - // passo al successivo - nId = pGeomDB->GetNext( nId) ; - } + // verifico sia un gruppo + if ( pGeomDB->GetGdbType( nGroupId) == GDB_TY_GROUP) { + bOk = pGeomDB->DeselectGroupObjs( nGroupId) ; } else bOk = false ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtDeselectPartObjs(" + ToString( nPartId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -BOOL -__stdcall EgtSelectLayerObjs( int nLayerId) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // verifico sia veramente un layer (gruppo senza sottogruppi) - if ( pGeomDB->GetGdbType( nLayerId) == GDB_TY_GROUP && - pGeomDB->GetFirstGroupInGroup( nLayerId) == GDB_ID_NULL) { - // ciclo sugli oggetti del layer - int nId = pGeomDB->GetFirstInGroup( nLayerId) ; - while ( nId != GDB_ID_NULL) { - // seleziono - pGeomDB->SelectObj( nId) ; - // passo al successivo - nId = pGeomDB->GetNext( nId) ; - } - } - else - bOk = false ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSelectLayerObjs(" + ToString( nLayerId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -BOOL -__stdcall EgtDeselectLayerObjs( int nLayerId) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // verifico sia veramente un layer (gruppo senza sottogruppi) - if ( pGeomDB->GetGdbType( nLayerId) == GDB_TY_GROUP && - pGeomDB->GetFirstGroupInGroup( nLayerId) == GDB_ID_NULL) { - // ciclo sugli oggetti del layer - int nId = pGeomDB->GetFirstInGroup( nLayerId) ; - while ( nId != GDB_ID_NULL) { - // deseleziono - pGeomDB->DeselectObj( nId) ; - // passo al successivo - nId = pGeomDB->GetNext( nId) ; - } - } - else - bOk = false ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtDeselectLayerObjs(" + ToString( nLayerId) + ")" + + string sLua = "EgtDeselectGroupObjs(" + ToString( nGroupId) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } diff --git a/API_GdbObjects.cpp b/API_GdbObjects.cpp index 18e1595..eb27b7f 100644 --- a/API_GdbObjects.cpp +++ b/API_GdbObjects.cpp @@ -227,6 +227,7 @@ __stdcall EgtCopy( int nSouId, int nRefId, int nSonBeforeAfter) VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // eseguo la copia int nNewId = pGeomDB->Copy( nSouId, GDB_ID_NULL, nRefId, nSonBeforeAfter) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua ; @@ -253,6 +254,7 @@ __stdcall EgtCopyGlob( int nSouId, int nRefId, int nSonBeforeAfter) VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // eseguo la copia mantenendo la posizione in globale int nNewId = pGeomDB->CopyGlob( nSouId, GDB_ID_NULL, nRefId, nSonBeforeAfter) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua ; @@ -279,6 +281,7 @@ __stdcall EgtRelocate( int nSouId, int nRefId, int nSonBeforeAfter) VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // eseguo la rilocazione bool bOk = pGeomDB->Relocate( nSouId, nRefId, nSonBeforeAfter) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua ; @@ -305,6 +308,7 @@ __stdcall EgtRelocateGlob( int nSouId, int nRefId, int nSonBeforeAfter) VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // eseguo la rilocazione mantenendo la posizione in globale bool bOk = pGeomDB->RelocateGlob( nSouId, nRefId, nSonBeforeAfter) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua ; @@ -331,6 +335,7 @@ __stdcall EgtChangeId( int nId, int nNewId) VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // eseguo cambio di Id bool bOk = pGeomDB->ChangeId( nId, nNewId) ; + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtChangeId(" + ToString( nId) + "," + @@ -351,16 +356,31 @@ __stdcall EgtErase( int nId) // eseguo cancellazione singola if ( nId != GDB_ID_SEL) { bOk = pGeomDB->Erase( nId) ; + // se cancellato pezzo corrente o layer corrente + int nCurrPartId = EgtGetCurrPart() ; + if ( nId == nCurrPartId) + EgtResetCurrPartLayer() ; + else if ( nId == EgtGetCurrLayer()) + EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstVisibleLayer( nCurrPartId)) ; } // eseguo cancellazione dei selezionati else { int nI = pGeomDB->GetFirstSelectedObj() ; while ( nI != GDB_ID_NULL && bOk) { + // cancello if ( ! pGeomDB->Erase( nI)) bOk = false ; + // se cancellato pezzo corrente o layer corrente + int nCurrPartId = EgtGetCurrPart() ; + if ( nI == nCurrPartId) + EgtResetCurrPartLayer() ; + else if ( nI == EgtGetCurrLayer()) + EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstVisibleLayer( nCurrPartId)) ; + // passo al successivo nI = pGeomDB->GetFirstSelectedObj() ; } } + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtErase(" + ( nId != GDB_ID_SEL ? ToString( nId) : "GDB_ID_SEL") + ")" + diff --git a/API_GdbPartLayers.cpp b/API_GdbPartLayers.cpp new file mode 100644 index 0000000..0dd2725 --- /dev/null +++ b/API_GdbPartLayers.cpp @@ -0,0 +1,323 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : API_GdbPartLayers.cpp Data : 29.01.15 Versione : 1.6a7 +// Contenuto : Funzioni di gestione pezzi e layer relativi. +// +// +// +// Modifiche : 29.01.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "API.h" +#include "API_Macro.h" +#include "/EgtDev/Include/EInAPI.h" +#include "/EgtDev/Include/EGkStringUtils3d.h" + +using namespace std ; + +//------------------------------------------------------------------------------- +static bool +EgtIsVisibleObj( IGeomDB* pGeomDB, int nId) +{ + int nStat ; + return ( pGeomDB->GetCalcStatus( nId, nStat) && nStat != GDB_ST_OFF) ; +} + +//------------------------------------------------------------------------------- +static int +EgtVerifyOrNextVisible( IGeomDB* pGeomDB, int nId) +{ + while ( nId != GDB_ID_NULL) { + if ( EgtIsVisibleObj( pGeomDB, nId)) + return nId ; + nId = pGeomDB->GetNextGroup( nId) ; + } + return GDB_ID_NULL ; +} + +//------------------------------------------------------------------------------- +int +__stdcall EgtGetCurrPart( void) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, GDB_ID_NULL) + // recupero il pezzo corrente + return pGseCtx->m_nCurrPart ; +} + +//------------------------------------------------------------------------------- +int +__stdcall EgtGetCurrLayer( void) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, GDB_ID_NULL) + // recupero il pezzo corrente + return pGseCtx->m_nCurrLayer ; +} + +//------------------------------------------------------------------------------- +BOOL +__stdcall EgtSetCurrPartLayer( int nPartId, int nLayerId) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, FALSE) + IGeomDB* pGeomDB = pGseCtx->m_pGeomDB ; + bool bOk = true ; + // verifico validità e visibilità pezzo + if ( pGeomDB->GetParentId( nPartId) == GDB_ID_ROOT && EgtIsVisibleObj( pGeomDB, nPartId)) { + if ( nPartId != pGseCtx->m_nCurrPart) + pGseCtx->m_nCurrLayer = GDB_ID_NULL ; + pGseCtx->m_nCurrPart = nPartId ; + } + else { + if ( nPartId == pGseCtx->m_nCurrPart || nPartId == GDB_ID_NULL) { + pGseCtx->m_nCurrPart = GDB_ID_NULL ; + pGseCtx->m_nCurrLayer = GDB_ID_NULL ; + } + bOk = false ; + } + // verifico validità e visibilità layer + if ( pGeomDB->GetParentId( nLayerId) == nPartId && EgtIsVisibleObj( pGeomDB, nLayerId)) { + pGseCtx->m_nCurrLayer = nLayerId ; + } + else { + if ( nLayerId == pGseCtx->m_nCurrLayer || nLayerId == GDB_ID_NULL) + pGseCtx->m_nCurrLayer = GDB_ID_NULL ; + bOk = false ; + } + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSetCurrPartLayer(" + ToString( nPartId) + "," + + ToString( nLayerId) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return ( bOk ? TRUE : FALSE) ; +} + +//------------------------------------------------------------------------------- +BOOL +__stdcall EgtResetCurrPartLayer( void) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, FALSE) + IGeomDB* pGeomDB = pGseCtx->m_pGeomDB ; + // reset + pGseCtx->m_nCurrPart = GDB_ID_NULL ; + pGseCtx->m_nCurrLayer = GDB_ID_NULL ; + // cerco il primo pezzo con un layer visibile + int nPartId = EgtGetFirstVisiblePart() ; + while ( nPartId != GDB_ID_NULL) { + // cerco il primo layer visibile del pezzo + int nLayerId = EgtGetFirstVisibleLayer( nPartId) ; + if ( nLayerId != GDB_ID_NULL) { + // assegno il pezzo corrente + pGseCtx->m_nCurrPart = nPartId ; + // assegno il layer corrente + pGseCtx->m_nCurrLayer = nLayerId ; + // esco dal ciclo di ricerca + break ; + } + nPartId = EgtGetNextVisiblePart( nPartId) ; + } + // se non ho trovato layer visibile mi accontento del primo pezzo visibile + if ( pGseCtx->m_nCurrPart == GDB_ID_NULL) + pGseCtx->m_nCurrPart = EgtGetFirstVisiblePart() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtResetCurrPartLayer()" + " -- Ids=" + ToString( pGseCtx->m_nCurrPart) + "," + ToString( pGseCtx->m_nCurrLayer) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return TRUE ; +} + +//------------------------------------------------------------------------------- +int +__stdcall EgtGetFirstVisiblePart( void) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero il primo gruppo sotto la radice + int nPartId = pGeomDB->GetFirstGroupInGroup( GDB_ID_ROOT) ; + // verifico sia visibile oppure passo al primo successivo visibile + return EgtVerifyOrNextVisible( pGeomDB, nPartId) ; +} + +//------------------------------------------------------------------------------- +int +__stdcall EgtGetNextVisiblePart( int nId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero il successivo gruppo + int nPartId = pGeomDB->GetNextGroup( nId) ; + // verifico sia visibile oppure passo al primo successivo visibile + return EgtVerifyOrNextVisible( pGeomDB, nPartId) ; +} + +//------------------------------------------------------------------------------- +int +__stdcall EgtGetFirstVisibleLayer( int nPartId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // verifico la visibilità del pezzo + if ( ! EgtIsVisibleObj( pGeomDB, nPartId)) + return GDB_ID_NULL ; + // recupero il primo layer nel pezzo + int nLayerId = pGeomDB->GetFirstGroupInGroup( nPartId) ; + // verifico sia visibile oppure passo al primo successivo visibile + return EgtVerifyOrNextVisible( pGeomDB, nLayerId) ; +} + +//------------------------------------------------------------------------------- +int +__stdcall EgtGetNextVisibleLayer( int nId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero il successivo gruppo + int nLayerId = pGeomDB->GetNextGroup( nId) ; + // verifico sia visibile oppure passo al primo successivo visibile + return EgtVerifyOrNextVisible( pGeomDB, nLayerId) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSelectPartObjs( int nPartId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + bool bOk = true ; + // verifico sia veramente un pezzo (gruppo sotto la radice) + if ( pGeomDB->GetGdbType( nPartId) == GDB_TY_GROUP && + pGeomDB->GetParentId( nPartId) == GDB_ID_ROOT) { + // ciclo sugli oggetti del pezzo + int nId = pGeomDB->GetFirstInGroup( nPartId) ; + while ( nId != GDB_ID_NULL) { + // se è gruppo seleziono i suoi componenti + if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) + pGeomDB->SelectGroupObjs( nId) ; + // altrimenti lo seleziono direttamente + else + pGeomDB->SelectObj( nId) ; + // passo al successivo + nId = pGeomDB->GetNext( nId) ; + } + } + else + bOk = false ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSelectPartObjs(" + ToString( nPartId) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return ( bOk ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtDeselectPartObjs( int nPartId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + bool bOk = true ; + // verifico sia veramente un pezzo (gruppo sotto la radice) + if ( pGeomDB->GetGdbType( nPartId) == GDB_TY_GROUP && + pGeomDB->GetParentId( nPartId) == GDB_ID_ROOT) { + // ciclo sugli oggetti del pezzo + int nId = pGeomDB->GetFirstInGroup( nPartId) ; + while ( nId != GDB_ID_NULL) { + // se è gruppo deseleziono i suoi componenti + if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) + pGeomDB->DeselectGroupObjs( nId) ; + // altrimenti lo deseleziono direttamente + else + pGeomDB->DeselectObj( nId) ; + // passo al successivo + nId = pGeomDB->GetNext( nId) ; + } + } + else + bOk = false ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtDeselectPartObjs(" + ToString( nPartId) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return ( bOk ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSelectLayerObjs( int nLayerId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + bool bOk = true ; + // verifico sia veramente un layer (gruppo senza sottogruppi) + if ( pGeomDB->GetGdbType( nLayerId) == GDB_TY_GROUP && + pGeomDB->GetFirstGroupInGroup( nLayerId) == GDB_ID_NULL) { + // ciclo sugli oggetti del layer + int nId = pGeomDB->GetFirstInGroup( nLayerId) ; + while ( nId != GDB_ID_NULL) { + // seleziono + pGeomDB->SelectObj( nId) ; + // passo al successivo + nId = pGeomDB->GetNext( nId) ; + } + } + else + bOk = false ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSelectLayerObjs(" + ToString( nLayerId) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return ( bOk ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtDeselectLayerObjs( int nLayerId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + bool bOk = true ; + // verifico sia veramente un layer (gruppo senza sottogruppi) + if ( pGeomDB->GetGdbType( nLayerId) == GDB_TY_GROUP && + pGeomDB->GetFirstGroupInGroup( nLayerId) == GDB_ID_NULL) { + // ciclo sugli oggetti del layer + int nId = pGeomDB->GetFirstInGroup( nLayerId) ; + while ( nId != GDB_ID_NULL) { + // deseleziono + pGeomDB->DeselectObj( nId) ; + // passo al successivo + nId = pGeomDB->GetNext( nId) ; + } + } + else + bOk = false ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtDeselectLayerObjs(" + ToString( nLayerId) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return ( bOk ? TRUE : FALSE) ; +} diff --git a/API_GeoTransform.cpp b/API_GeoTransform.cpp index 1545828..b6c37cd 100644 --- a/API_GeoTransform.cpp +++ b/API_GeoTransform.cpp @@ -82,6 +82,7 @@ EgtMove( INTVECTOR& vIds, const Vector3d& vtMove, int nRefType) } } } + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sIds ; @@ -163,6 +164,7 @@ EgtRotate( INTVECTOR& vIds, const Point3d& ptAx, const Vector3d& vtAx, double dA } } } + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sIds ; @@ -251,6 +253,7 @@ EgtScale( INTVECTOR& vIds, const Frame3d& frRef, } } } + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sIds ; @@ -338,6 +341,7 @@ EgtMirror( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, int nRefTyp } } } + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sIds ; @@ -424,6 +428,7 @@ EgtShear( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, } } } + EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sIds ; @@ -465,6 +470,7 @@ __stdcall EgtMoveGroup( int nId, double vVtMove[3]) nI = pGeomDB->GetNextSelectedObj() ; } } + EgtSetModified() ; // restituisco risultato return ( bOk ? TRUE : FALSE) ; } @@ -489,6 +495,7 @@ __stdcall EgtRotateGroup( int nId, double vPtAx[3], double vVtAx[3], double dAng nI = pGeomDB->GetNextSelectedObj() ; } } + EgtSetModified() ; // restituisco risultato return ( bOk ? TRUE : FALSE) ; } @@ -519,6 +526,7 @@ __stdcall EgtScaleGroup( int nId, const double vOrig[3], nI = pGeomDB->GetNextSelectedObj() ; } } + EgtSetModified() ; // restituisco risultato return ( bOk ? TRUE : FALSE) ; } @@ -543,6 +551,7 @@ __stdcall EgtMirrorGroup( int nId, const double vPnt[3], const double vN[3]) nI = pGeomDB->GetNextSelectedObj() ; } } + EgtSetModified() ; // restituisco risultato return ( bOk ? TRUE : FALSE) ; } @@ -568,6 +577,7 @@ __stdcall EgtShearGroup( int nId, const double vPnt[3], const double vN[3], nI = pGeomDB->GetNextSelectedObj() ; } } + EgtSetModified() ; // restituisco risultato return ( bOk ? TRUE : FALSE) ; } diff --git a/API_GeomDB.cpp b/API_GeomDB.cpp index 19299de..6271386 100644 --- a/API_GeomDB.cpp +++ b/API_GeomDB.cpp @@ -174,6 +174,104 @@ EgtGetGridVersZ( int nRefId, Vector3d& vtVersZ) return vtVersZ.ToLoc( frDest) ; } +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetCurrFilePath( const wchar_t* wsFilePath) +{ + return ( EgtSetCurrFilePath( wstrztoA( wsFilePath)) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +bool +EgtSetCurrFilePath( const string& sFilePath) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, false) + // assegno la path + pGseCtx->m_sFilePath = sFilePath ; + return true ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetCurrFilePath( wchar_t*& wsFilePath) +{ + if ( &wsFilePath == nullptr) + return false ; + string sFilePath ; + if ( ! EgtGetCurrFilePath( sFilePath)) + return FALSE ; + wsFilePath = _wcsdup( stringtoW( sFilePath)) ; + return (( wsFilePath == nullptr) ? FALSE : TRUE) ; +} + +//----------------------------------------------------------------------------- +bool +EgtGetCurrFilePath( string& sFilePath) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, false) + // restituisco la path + sFilePath = pGseCtx->m_sFilePath ; + return ( ! sFilePath.empty()) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtEnableModified( void) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, FALSE) + // abilito possibilità di alterare il flag di modifica + pGseCtx->m_bEnableModified = true ; + return TRUE ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtDisableModified( void) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, FALSE) + // disabilito possibilità di alterare il flag di modifica + pGseCtx->m_bEnableModified = false ; + return TRUE ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetModified( void) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, FALSE) + // se consentito, imposto il flag + if ( pGseCtx->m_bEnableModified) + pGseCtx->m_bModified = true ; + return TRUE ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtResetModified( void) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, FALSE) + // se consentito, cancello il flag + if ( pGseCtx->m_bEnableModified) + pGseCtx->m_bModified = false ; + return TRUE ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetModified( void) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, FALSE) + // imposto il flag + return ( pGseCtx->m_bModified ? TRUE : FALSE) ; +} + //----------------------------------------------------------------------------- BOOL __stdcall EgtNewFile( void) @@ -184,6 +282,9 @@ __stdcall EgtNewFile( void) // reinizializzazione (con pulizia) del DB geometrico bOk = bOk && pGseCtx->m_pGeomDB->Init() ; bOk = bOk && pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ; + // aggiorno stato file corrente + pGseCtx->m_sFilePath.clear() ; + pGseCtx->m_bModified = false ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtNewFile()" @@ -213,6 +314,9 @@ EgtOpenFile( const string& sFilePath) bOk = bOk && pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ; // carico il file bOk = bOk && GetCurrGeomDB()->Load( sFilePath) ; + // aggiorno stato file corrente + pGseCtx->m_sFilePath = sFilePath ; + pGseCtx->m_bModified = false ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLuaPath = sFilePath ; @@ -236,10 +340,12 @@ __stdcall EgtInsertFile( const wchar_t* wsFilePath) bool EgtInsertFile( const string& sFilePath) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, false) // carico il file - bool bOk = pGeomDB->Load( sFilePath) ; + bool bOk = pGseCtx->m_pGeomDB->Load( sFilePath) ; + // aggiorno stato file corrente + pGseCtx->m_bModified = true ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLuaPath = sFilePath ; @@ -263,10 +369,14 @@ __stdcall EgtSaveFile( const wchar_t* wsFilePath, int nFlag) bool EgtSaveFile( const string& sFilePath, int nFlag) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, false) // salvo il file - bool bOk = pGeomDB->Save( sFilePath, nFlag) ; + bool bOk = pGseCtx->m_pGeomDB->Save( sFilePath, nFlag) ; + // aggiorno stato file corrente + pGseCtx->m_sFilePath = sFilePath ; + if ( bOk) + pGseCtx->m_bModified = false ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLuaPath = sFilePath ; diff --git a/EgtInterface.rc b/EgtInterface.rc index 73b3d7c..9244765 100644 Binary files a/EgtInterface.rc and b/EgtInterface.rc differ diff --git a/EgtInterface.vcxproj b/EgtInterface.vcxproj index 60619e0..3247d41 100644 --- a/EgtInterface.vcxproj +++ b/EgtInterface.vcxproj @@ -224,6 +224,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -245,6 +246,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/EgtInterface.vcxproj.filters b/EgtInterface.vcxproj.filters index 1e359a4..86fefc6 100644 --- a/EgtInterface.vcxproj.filters +++ b/EgtInterface.vcxproj.filters @@ -173,6 +173,12 @@ File di origine\LUA + + File di origine\LUA + + + File di origine\API + diff --git a/GseContext.h b/GseContext.h index 8b56f49..79151fd 100644 --- a/GseContext.h +++ b/GseContext.h @@ -27,10 +27,18 @@ class GseContext HWND m_hWnd ; IEGrScene* m_pScene ; ICmdParser* m_pTscExec ; + std::string m_sFilePath ; + bool m_bEnableModified ; + bool m_bModified ; + int m_nCurrPart ; + int m_nCurrLayer ; public : GseContext( void) - : m_pGeomDB( nullptr), m_colDef( GRAY), m_hWnd( nullptr), m_pScene( nullptr), m_pTscExec( nullptr) {} + : m_pGeomDB( nullptr), m_colDef( GRAY), m_hWnd( nullptr), m_pScene( nullptr), m_pTscExec( nullptr), + m_sFilePath(), m_bEnableModified( true), m_bModified( false), + m_nCurrPart( GDB_ID_NULL), m_nCurrLayer( GDB_ID_NULL) + {} ~GseContext( void) { Clear() ; } void Clear( void) @@ -49,6 +57,11 @@ class GseContext delete m_pGeomDB ; m_pGeomDB = nullptr ; } + m_sFilePath.clear() ; + m_bEnableModified = true ; + m_bModified = false ; + m_nCurrPart = GDB_ID_NULL ; + m_nCurrLayer = GDB_ID_NULL ; } } ; diff --git a/LUA.h b/LUA.h index 86e64b2..f895579 100644 --- a/LUA.h +++ b/LUA.h @@ -83,6 +83,9 @@ bool LuaInstallGdbModify( lua_State* L) ; //-------------------------- GdbModifyCurve ---------------------------------- bool LuaInstallGdbModifyCurve( lua_State* L) ; +//-------------------------- GdbPartLayer ------------------------------------ +bool LuaInstallGdbPartLayer( lua_State* L) ; + //-------------------------- GdbObjects -------------------------------------- bool LuaInstallGdbObjects( lua_State* L) ; diff --git a/LUA_GdbObjSelection.cpp b/LUA_GdbObjSelection.cpp index 12c81ef..0263be3 100644 --- a/LUA_GdbObjSelection.cpp +++ b/LUA_GdbObjSelection.cpp @@ -21,7 +21,6 @@ using namespace std ; - //------------------------------------------------------------------------------- static int LuaSelectObj( lua_State* L) @@ -82,14 +81,14 @@ LuaDeselectAll( lua_State* L) //------------------------------------------------------------------------------- static int -LuaSelectPartObjs( lua_State* L) +LuaSelectGroupObjs( lua_State* L) { - // 1 parametro : PartId - int nPartId ; - LuaCheckParam( L, 1, nPartId) + // 1 parametro : GroupId + int GroupId ; + LuaCheckParam( L, 1, GroupId) LuaClearStack( L) ; // eseguo la selezione - bool bOk = ( EgtSelectPartObjs( nPartId) != FALSE) ; + bool bOk = ( EgtSelectGroupObjs( GroupId) != FALSE) ; // restituisco il risultato LuaSetReturn( L, bOk) ; return 1 ; @@ -97,44 +96,14 @@ LuaSelectPartObjs( lua_State* L) //------------------------------------------------------------------------------- static int -LuaDeselectPartObjs( lua_State* L) +LuaDeselectGroupObjs( lua_State* L) { - // 1 parametro : PartId - int nPartId ; - LuaCheckParam( L, 1, nPartId) + // 1 parametro : GroupId + int GroupId ; + LuaCheckParam( L, 1, GroupId) LuaClearStack( L) ; - // eseguo la selezione - bool bOk = ( EgtDeselectPartObjs( nPartId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSelectLayerObjs( lua_State* L) -{ - // 1 parametro : LayerId - int nLayerId ; - LuaCheckParam( L, 1, nLayerId) - LuaClearStack( L) ; - // eseguo la selezione - bool bOk = ( EgtSelectLayerObjs( nLayerId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaDeselectLayerObjs( lua_State* L) -{ - // 1 parametro : LayerId - int nLayerId ; - LuaCheckParam( L, 1, nLayerId) - LuaClearStack( L) ; - // eseguo la selezione - bool bOk = ( EgtDeselectLayerObjs( nLayerId) != FALSE) ; + // eseguo la deselezione + bool bOk = ( EgtDeselectGroupObjs( GroupId) != FALSE) ; // restituisco il risultato LuaSetReturn( L, bOk) ; return 1 ; @@ -241,10 +210,8 @@ LuaInstallGdbObjSelection( lua_State* L) lua_register( L, "EgtDeselectObj", LuaDeselectObj) ; lua_register( L, "EgtSelectAll", LuaSelectAll) ; lua_register( L, "EgtDeselectAll", LuaDeselectAll) ; - lua_register( L, "EgtSelectPartObjs", LuaSelectPartObjs) ; - lua_register( L, "EgtDeselectPartObjs", LuaDeselectPartObjs) ; - lua_register( L, "EgtSelectLayerObjs", LuaSelectLayerObjs) ; - lua_register( L, "EgtDeselectLayerObjs", LuaDeselectLayerObjs) ; + lua_register( L, "EgtSelectGroupObjs", LuaSelectGroupObjs) ; + lua_register( L, "EgtDeselectGroupObjs", LuaDeselectGroupObjs) ; lua_register( L, "EgtIsSelectedObj", LuaIsSelectedObj) ; lua_register( L, "EgtGetSelectedObjNbr", LuaGetSelectedObjNbr) ; lua_register( L, "EgtGetFirstSelectedObj", LuaGetFirstSelectedObj) ; diff --git a/LUA_GdbPartLayers.cpp b/LUA_GdbPartLayers.cpp new file mode 100644 index 0000000..13a4955 --- /dev/null +++ b/LUA_GdbPartLayers.cpp @@ -0,0 +1,220 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : LUA_GdbPartLayers.cpp Data : 29.01.15 Versione : 1.6a7 +// Contenuto : Funzioni di gestione pezzi e layer relativi per LUA. +// +// +// +// Modifiche : 29.01.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "LUA.h" +#include "API.h" +#include "/EgtDev/Include/EInAPI.h" +#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Extern/Lua/Include/lua.hpp" + +using namespace std ; + +//------------------------------------------------------------------------------- +static int +LuaGetCurrPart( lua_State* L) +{ + // nessun parametro + LuaClearStack( L) ; + // recupero il pezzo corrente + int nId = EgtGetCurrPart() ; + // restituisco il risultato + LuaSetReturn( L, nId) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetCurrLayer( lua_State* L) +{ + // nessun parametro + LuaClearStack( L) ; + // recupero il layer corrente + int nId = EgtGetCurrLayer() ; + // restituisco il risultato + LuaSetReturn( L, nId) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaSetCurrPartLayer( lua_State* L) +{ + // 2 parametri : nPartId, nLayerId + int nPartId ; + LuaCheckParam( L, 1, nPartId) + int nLayerId ; + LuaCheckParam( L, 2, nLayerId) + LuaClearStack( L) ; + // imposto pezzo e layer correnti + bool bOk = ( EgtSetCurrPartLayer( nPartId, nLayerId) != FALSE) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaResetCurrPartLayer( lua_State* L) +{ + // nessun parametro + LuaClearStack( L) ; + // cerco primo pezzo e layer validi per essere dichiarati correnti + bool bOk = ( EgtResetCurrPartLayer() != FALSE) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetFirstVisiblePart( lua_State* L) +{ + // nessun parametro + LuaClearStack( L) ; + // cerco primo pezzo e layer validi per essere dichiarati correnti + int nId = EgtGetFirstVisiblePart() ; + // restituisco il risultato + LuaSetReturn( L, nId) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetNextVisiblePart( lua_State* L) +{ + // 1 parametro : nPartId + int nPartId ; + LuaCheckParam( L, 1, nPartId) + LuaClearStack( L) ; + // cerco primo pezzo e layer validi per essere dichiarati correnti + int nId = EgtGetNextVisiblePart( nPartId) ; + // restituisco il risultato + LuaSetReturn( L, nId) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetFirstVisibleLayer( lua_State* L) +{ + // 1 parametro : nPartId + int nPartId ; + LuaCheckParam( L, 1, nPartId) + LuaClearStack( L) ; + // cerco il primo layer visibile del pezzo + int nId = EgtGetFirstVisibleLayer( nPartId) ; + // restituisco il risultato + LuaSetReturn( L, nId) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetNextVisibleLayer( lua_State* L) +{ + // 1 parametro : nLayerId + int nLayerId ; + LuaCheckParam( L, 1, nLayerId) + LuaClearStack( L) ; + // cerco il prossimo layer visibile (ovviamente dello stesso pezzo) + int nId = EgtGetNextVisibleLayer( nLayerId) ; + // restituisco il risultato + LuaSetReturn( L, nId) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaSelectPartObjs( lua_State* L) +{ + // 1 parametro : PartId + int nPartId ; + LuaCheckParam( L, 1, nPartId) + LuaClearStack( L) ; + // eseguo la selezione + bool bOk = ( EgtSelectPartObjs( nPartId) != FALSE) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaDeselectPartObjs( lua_State* L) +{ + // 1 parametro : PartId + int nPartId ; + LuaCheckParam( L, 1, nPartId) + LuaClearStack( L) ; + // eseguo la selezione + bool bOk = ( EgtDeselectPartObjs( nPartId) != FALSE) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaSelectLayerObjs( lua_State* L) +{ + // 1 parametro : LayerId + int nLayerId ; + LuaCheckParam( L, 1, nLayerId) + LuaClearStack( L) ; + // eseguo la selezione + bool bOk = ( EgtSelectLayerObjs( nLayerId) != FALSE) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaDeselectLayerObjs( lua_State* L) +{ + // 1 parametro : LayerId + int nLayerId ; + LuaCheckParam( L, 1, nLayerId) + LuaClearStack( L) ; + // eseguo la selezione + bool bOk = ( EgtDeselectLayerObjs( nLayerId) != FALSE) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +bool +LuaInstallGdbPartLayer( lua_State* L) +{ + try { + lua_register( L, "EgtGetCurrPart", LuaGetCurrPart) ; + lua_register( L, "EgtGetCurrLayer", LuaGetCurrLayer) ; + lua_register( L, "EgtSetCurrPartLayer", LuaSetCurrPartLayer) ; + lua_register( L, "EgtResetCurrPartLayer", LuaResetCurrPartLayer) ; + lua_register( L, "EgtGetFirstVisiblePart", LuaGetFirstVisiblePart) ; + lua_register( L, "EgtGetNextVisiblePart", LuaGetNextVisiblePart) ; + lua_register( L, "EgtGetFirstVisibleLayer", LuaGetFirstVisibleLayer) ; + lua_register( L, "EgtGetNextVisibleLayer", LuaGetNextVisibleLayer) ; + lua_register( L, "EgtSelectPartObjs", LuaSelectPartObjs) ; + lua_register( L, "EgtDeselectPartObjs", LuaDeselectPartObjs) ; + lua_register( L, "EgtSelectLayerObjs", LuaSelectLayerObjs) ; + lua_register( L, "EgtDeselectLayerObjs", LuaDeselectLayerObjs) ; + } + catch ( ...) { + return false ; + } + return true ; +} diff --git a/LUA_General.cpp b/LUA_General.cpp index 7b03204..bb82b2c 100644 --- a/LUA_General.cpp +++ b/LUA_General.cpp @@ -79,6 +79,10 @@ LuaInit( void) LOG_ERROR( GetLogger(), "Error in LuaInstallGdbModifyCurve (" __FUNCTION__ ")") return false ; } + if ( ! LuaInstallGdbPartLayer( s_L)) { + LOG_ERROR( GetLogger(), "Error in LuaInstallGdbPartLayer (" __FUNCTION__ ")") + return false ; + } if ( ! LuaInstallGdbObjects( s_L)) { LOG_ERROR( GetLogger(), "Error in LuaInstallGdbObjects (" __FUNCTION__ ")") return false ;