diff --git a/EXE_Exchange.cpp b/EXE_Exchange.cpp index a86b0e7..eb3f15f 100644 --- a/EXE_Exchange.cpp +++ b/EXE_Exchange.cpp @@ -88,7 +88,7 @@ ExeImportDxf( const string& sFilePath, double dScaleFactor) bOk = bOk && pImpDxf->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId, dScaleFactor) ; // aggiorno stato file corrente pGseCtx->m_sFilePath = sFilePath ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtImportDxf('" + StringToLuaString( sFilePath) + "'," + @@ -118,7 +118,7 @@ ExeImportStl( const string& sFilePath, double dScaleFactor) bOk = bOk && pImpStl->Import( sFilePath, pGseCtx->m_pGeomDB, nLayerId, dScaleFactor) ; // aggiorno stato file corrente pGseCtx->m_sFilePath = sFilePath ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtImportStl('" + StringToLuaString( sFilePath) + "'," + @@ -147,7 +147,7 @@ ExeImportCnc( const string& sFilePath) bOk = bOk && pImpCnc->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId) ; // aggiorno stato file corrente pGseCtx->m_sFilePath = sFilePath ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtImportCnc('" + StringToLuaString( sFilePath) + "')" + @@ -173,7 +173,7 @@ ExeImportCsf( const string& sFilePath) bOk = bOk && pImpCsf->Import( sFilePath, pGseCtx->m_pGeomDB) ; // aggiorno stato file corrente pGseCtx->m_sFilePath = sFilePath ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtImportCsf('" + StringToLuaString( sFilePath) + "')" + @@ -199,7 +199,7 @@ ExeImportBtl( const string& sFilePath, bool bFlatPos) bOk = bOk && pImpBtl->Import( sFilePath, pGseCtx->m_pGeomDB, bFlatPos) ; // aggiorno stato file corrente pGseCtx->m_sFilePath = sFilePath ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtImportBtl('" + StringToLuaString( sFilePath) + "'," + diff --git a/EXE_GdbModifySurf.cpp b/EXE_GdbModifySurf.cpp index c5c1a16..c50c9b9 100644 --- a/EXE_GdbModifySurf.cpp +++ b/EXE_GdbModifySurf.cpp @@ -187,6 +187,7 @@ ExeSurfFrAdd( int nId1, int nId2) if ( ! AreSameFrame( frSurf1, frSurf2)) { pTmp.Set( CloneSurfFlatRegion( pSfr2)) ; bOk = bOk && ! IsNull( pTmp) ; + bOk = bOk && pTmp->LocToLoc( frSurf2, frSurf1) ; pSfr2L = Get( pTmp) ; } // eseguo l'unione tra le due superfici @@ -226,6 +227,7 @@ ExeSurfFrSubtract( int nId1, int nId2) if ( ! AreSameFrame( frSurf1, frSurf2)) { pTmp.Set( CloneSurfFlatRegion( pSfr2)) ; bOk = bOk && ! IsNull( pTmp) ; + bOk = bOk && pTmp->LocToLoc( frSurf2, frSurf1) ; pSfr2L = Get( pTmp) ; } // eseguo la sottrazione della seconda superficie dalla prima @@ -265,6 +267,7 @@ ExeSurfFrIntersect( int nId1, int nId2) if ( ! AreSameFrame( frSurf1, frSurf2)) { pTmp.Set( CloneSurfFlatRegion( pSfr2)) ; bOk = bOk && ! IsNull( pTmp) ; + bOk = bOk && pTmp->LocToLoc( frSurf2, frSurf1) ; pSfr2L = Get( pTmp) ; } // eseguo l'intersezione tra le due superfici diff --git a/EXE_GeomDB.cpp b/EXE_GeomDB.cpp index d37f5be..711b8de 100644 --- a/EXE_GeomDB.cpp +++ b/EXE_GeomDB.cpp @@ -249,7 +249,7 @@ ExeNewFile( void) bOk = bOk && pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ; // aggiorno stato file corrente pGseCtx->m_sFilePath.clear() ; - pGseCtx->m_bModified = false ; + ExeResetModified() ; // aggiornamento gestore lavorazioni ExeUpdateMachMgr() ; // se richiesto, salvo il comando Lua equivalente @@ -276,7 +276,7 @@ ExeOpenFile( const string& sFilePath) bOk = bOk && pGseCtx->m_pGeomDB->Load( sFilePath) ; // aggiorno stato file corrente pGseCtx->m_sFilePath = sFilePath ; - pGseCtx->m_bModified = false ; + ExeResetModified() ; // aggiornamento gestore lavorazioni ExeUpdateMachMgr() ; // se richiesto, salvo il comando Lua equivalente @@ -314,12 +314,13 @@ ExeInsertFile( const string& sFilePath) // passo al prossimo nId = nNextId ; } - // sistemo le lavorazioni - bOk = bOk && ExeInsertMachMgr( nGrp) ; + // se gestite, sistemo le lavorazioni + if ( GetCurrMachMgr() != nullptr) + bOk = bOk && ExeInsertMachMgr( nGrp) ; // cancello il gruppo temporaneo pGeomDB->Erase( nGrp) ; // aggiorno stato file corrente - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtInsertFile('" + StringToLuaString( sFilePath) + "')" + @@ -347,7 +348,7 @@ ExeSaveFile( const string& sFilePath, int nFlag) // aggiorno stato file corrente pGseCtx->m_sFilePath = sFilePath ; if ( bOk) - pGseCtx->m_bModified = false ; + ExeResetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSaveFile('" + StringToLuaString( sFilePath) + "'," + diff --git a/EXE_MachMgr.cpp b/EXE_MachMgr.cpp index e9e3caa..1c92a6b 100644 --- a/EXE_MachMgr.cpp +++ b/EXE_MachMgr.cpp @@ -104,7 +104,7 @@ ExeAddMachGroup( const string& sName, const string& sMachineName) VERIFY_CTX_MACHMGR( pGseCtx, GDB_ID_NULL) // aggiungo la macchinata (gruppo di lavorazione) int nId = pGseCtx->m_pMachMgr->AddMachGroup( sName, sMachineName) ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtAddMachGroup('" + sName + "','" + @@ -124,7 +124,7 @@ ExeRemoveMachGroup( int nMGroupId) VERIFY_CTX_MACHMGR( pGseCtx, false) // rimuovo la macchinata (gruppo di lavorazione) bool bOk = pGseCtx->m_pMachMgr->RemoveMachGroup( nMGroupId) ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtRemoveMachGroup(" + ToString( nMGroupId) + ")" + @@ -242,7 +242,7 @@ ExeAddRawPart( Point3d ptOrig, double dWidth, double dLength, double dHeight, Co VERIFY_CTX_MACHMGR( pGseCtx, GDB_ID_NULL) // inserisco grezzo nella macchinata corrente int nId = pGseCtx->m_pMachMgr->AddRawPart( ptOrig, dWidth, dLength, dHeight, cCol) ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtAddRawPart({" + ToString( ptOrig) + "}," + @@ -265,7 +265,7 @@ ExeAddRawPartWithPart( int nPartId, int nCrvId, double dOverMat, Color cCol) VERIFY_CTX_MACHMGR( pGseCtx, GDB_ID_NULL) // inserisco grezzo con pezzo nella macchinata corrente int nId = pGseCtx->m_pMachMgr->AddRawPartWithPart( nPartId, nCrvId, dOverMat, cCol) ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtAddRawPartWithPart(" + ToString( nPartId) + "," + @@ -287,7 +287,7 @@ ExeModifyRawPartHeight( int nRawId, double dHeight) VERIFY_CTX_MACHMGR( pGseCtx, false) // modifico lo spessore del grezzo bool bOk = pGseCtx->m_pMachMgr->ModifyRawPartHeight( nRawId, dHeight) ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtModifyRawPartHeight(" + ToString( nRawId) + "," + @@ -307,7 +307,7 @@ ExeRemoveRawPart( int nRawId) VERIFY_CTX_MACHMGR( pGseCtx, false) // elimino grezzo dalla macchinata corrente bool bOk = pGseCtx->m_pMachMgr->RemoveRawPart( nRawId) ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtRemoveRawPart(" + ToString( nRawId) + ")" + @@ -326,7 +326,7 @@ ExeRotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) VERIFY_CTX_MACHMGR( pGseCtx, false) // ruoto il grezzo bool bOk = pGseCtx->m_pMachMgr->RotateRawPart( nRawId, vtAx, dAngRotDeg) ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtRotateRawPart(" + ToString( nRawId) + ",{" + @@ -347,7 +347,7 @@ ExeMoveToCornerRawPart( int nRawId, const Point3d& ptCorner, int nFlag) VERIFY_CTX_MACHMGR( pGseCtx, false) // mando il grezzo nel corner bool bOk = pGseCtx->m_pMachMgr->MoveToCornerRawPart( nRawId, ptCorner, nFlag) ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtMoveToCornerRawPart(" + ToString( nRawId) + ",{" + @@ -368,7 +368,7 @@ ExeMoveToCenterRawPart( int nRawId, const Point3d& ptCenter, int nFlag) VERIFY_CTX_MACHMGR( pGseCtx, false) // mando il grezzo nel corner bool bOk = pGseCtx->m_pMachMgr->MoveToCenterRawPart( nRawId, ptCenter, nFlag) ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtMoveToCenterRawPart(" + ToString( nRawId) + ",{" + @@ -389,7 +389,7 @@ ExeMoveRawPart( int nRawId, const Vector3d& vtMove) VERIFY_CTX_MACHMGR( pGseCtx, false) // traslo il grezzo bool bOk = pGseCtx->m_pMachMgr->MoveRawPart( nRawId, vtMove) ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtMoveRawPart(" + ToString( nRawId) + ",{" + @@ -439,7 +439,7 @@ ExeAddPartToRawPart( int nPartId, const Point3d& ptPos, int nRawId) VERIFY_CTX_MACHMGR( pGseCtx, false) // inserisco pezzo in un grezzo della macchinata corrente bool bOk = pGseCtx->m_pMachMgr->AddPartToRawPart( nPartId, ptPos, nRawId) ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtAddPartToRawPart(" + ToString( nPartId) + ",{" + @@ -460,7 +460,7 @@ ExeRemovePartFromRawPart( int nPartId) VERIFY_CTX_MACHMGR( pGseCtx, false) // elimino pezzo da grezzo della macchinata corrente bool bOk = pGseCtx->m_pMachMgr->RemovePartFromRawPart( nPartId) ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtRemovePartFromRawPart(" + ToString( nPartId) + ")" + @@ -479,7 +479,7 @@ ExeTranslatePartInRawPart( int nPartId, const Vector3d& vtMove) VERIFY_CTX_MACHMGR( pGseCtx, false) // traslo il pezzo nel grezzo bool bOk = pGseCtx->m_pMachMgr->TranslatePartInRawPart( nPartId, vtMove) ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtMovePartInRawPart(" + ToString( nPartId) + ",{" + @@ -499,7 +499,7 @@ ExeRotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg) VERIFY_CTX_MACHMGR( pGseCtx, false) // ruoto il pezzo nel grezzo bool bOk = pGseCtx->m_pMachMgr->RotatePartInRawPart( nPartId, vtAx, dAngRotDeg) ; - pGseCtx->m_bModified = true ; + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtRotatePartInRawPart(" + ToString( nPartId) + ",{" + diff --git a/EXE_Nesting.cpp b/EXE_Nesting.cpp index 9d3e30e..a5b0d28 100644 --- a/EXE_Nesting.cpp +++ b/EXE_Nesting.cpp @@ -598,7 +598,10 @@ ExePackPart( int nId, double dXmin, double dYmin, double dXmax, double dYmax, do else if ( ! bBottomUp && b3Part.GetMin().y - ptPart.y + dYok < dYmin - dOffs - EPS_SMALL) return false ; // Porto il pezzo nella giusta posizione - return pGeomDB->TranslateGlob( nId, Point3d( dXok, dYok, 0) - ptPart) ; + if ( ! pGeomDB->TranslateGlob( nId, Point3d( dXok, dYok, 0) - ptPart)) + return false ; + ExeSetModified() ; + return true ; } //---------------------------------------------------------------------------- @@ -623,6 +626,9 @@ ExePackCluster( const INTVECTOR& vIds, double dXmin, double dYmin, double dXmax, nTrueId = (( nId != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; } } + // Se non sono rimasti oggetti, esco con successo + if ( vTrueIds.empty()) + return true ; // Flag per calcolo box const int BBF_MY_FLAG = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ; // Determino il box del cluster (insieme di pezzi) @@ -698,6 +704,7 @@ ExePackCluster( const INTVECTOR& vIds, double dXmin, double dYmin, double dXmax, for ( auto nTrueId : vTrueIds) { pGeomDB->TranslateGlob( nTrueId, Point3d( dXok, dYok, 0) - ptCluster) ; } + ExeSetModified() ; return true ; } @@ -825,7 +832,7 @@ VerifyBoxMoveOutBox( const BBox3d& b3Other, const BBox3d& b3Box, Vector3d& vtMov //---------------------------------------------------------------------------- bool -ExeMoveCluster( const INTVECTOR& vIds, const Vector3d& vtMove, +ExeMoveCluster( const INTVECTOR& vIds, Vector3d& vtMove, double dXmin, double dYmin, double dXmax, double dYmax, double dOffs) { IGeomDB* pGeomDB = GetCurrGeomDB() ; @@ -838,6 +845,7 @@ ExeMoveCluster( const INTVECTOR& vIds, const Vector3d& vtMove, // Vettore movimento nel solo piano XY Vector3d vtMoveXY( vtMove.x, vtMove.y, 0) ; + vtMove = V_NULL ; if ( vtMoveXY.IsSmall()) return true ; @@ -926,6 +934,8 @@ ExeMoveCluster( const INTVECTOR& vIds, const Vector3d& vtMove, // Eseguo movimento dei pezzi del cluster for ( auto nTrueId : vTrueIds) pGeomDB->TranslateGlob( nTrueId, vtMoveXY) ; + ExeSetModified() ; + vtMove = vtMoveXY ; return true ; } \ No newline at end of file diff --git a/EgtExecutor.rc b/EgtExecutor.rc index cc3ccd8..cda94f9 100644 Binary files a/EgtExecutor.rc and b/EgtExecutor.rc differ