diff --git a/EXE_GdbCreate.cpp b/EXE_GdbCreate.cpp index 78baf0c..94ebfc8 100644 --- a/EXE_GdbCreate.cpp +++ b/EXE_GdbCreate.cpp @@ -62,20 +62,20 @@ ExeCreateGroup( int nParentId, const Frame3d& frFrame, int nRefType) if ( AreSameFrame( frFrame, GLOB_FRM)) { if ( nRefType == RTY_LOC) sLua = "EgtGroup(" + IdToString( nParentId) + ")" + - " -- Id=" + ToString( nId) ; + " -- Id=" + ToString( nId) ; else sLua = "EgtGroup(" + IdToString( nParentId) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; } else sLua = "EgtGroup(" + IdToString( nParentId) + ",{{" + - ToString( frFrame.Orig()) + "},{" + - ToString( frFrame.VersX()) + "},{" + - ToString( frFrame.VersY()) + "},{" + - ToString( frFrame.VersZ()) + "}}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( frFrame.Orig()) + "},{" + + ToString( frFrame.VersX()) + "},{" + + ToString( frFrame.VersY()) + "},{" + + ToString( frFrame.VersZ()) + "}}," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del nuovo gruppo @@ -106,9 +106,9 @@ ExeCreateGeoPoint( int nParentId, const Point3d& ptP, int nRefType) // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtPoint(" + IdToString( nParentId) + ",{" + - ToString( ptP) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( ptP) + "}," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo della nuova entit� @@ -142,15 +142,15 @@ ExeCreateGeoVector( int nParentId, const Vector3d& vtV, const Point3d& ptB, int string sLua ; if ( ptB.IsSmall()) sLua = "EgtVector(" + IdToString( nParentId) + ",{" + - ToString( vtV) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( vtV) + "}," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; else sLua = "EgtVector(" + IdToString( nParentId) + ",{" + - ToString( vtV) + "},{" + - ToString( ptB) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( vtV) + "},{" + + ToString( ptB) + "}," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo della nuova entit� @@ -183,12 +183,12 @@ ExeCreateGeoFrame( int nParentId, const Frame3d& frFrame, int nRefType) // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtFrame(" + IdToString( nParentId) + ",{{" + - ToString( frFrame.Orig()) + "},{" + - ToString( frFrame.VersX()) + "},{" + - ToString( frFrame.VersY()) + "},{" + - ToString( frFrame.VersZ()) + "}}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( frFrame.Orig()) + "},{" + + ToString( frFrame.VersX()) + "},{" + + ToString( frFrame.VersY()) + "},{" + + ToString( frFrame.VersZ()) + "}}," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del nuovo gruppo @@ -221,11 +221,11 @@ ExeCreateText( int nParentId, const Point3d& ptP, // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtText(" + IdToString( nParentId) + ",{" + - ToString( ptP) + "},'" + - StringToLuaString( sText) + "'," + - ToString( dH) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( ptP) + "},'" + + StringToLuaString( sText) + "'," + + ToString( dH) + "," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del oggetto @@ -258,14 +258,14 @@ ExeCreateTextEx( int nParentId, const Point3d& ptP, double dAngRotDeg, // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtTextEx(" + IdToString( nParentId) + ",{" + - ToString( ptP) + "}," + - ToString( dAngRotDeg) + ",'" + - StringToLuaString( sText) + "','" + - StringToLuaString( sFont) + "'," + - ( bItalic ? "'I'" : "'S'") + "," + - ToString( dH) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( ptP) + "}," + + ToString( dAngRotDeg) + ",'" + + StringToLuaString( sText) + "','" + + StringToLuaString( sFont) + "'," + + ( bItalic ? "'I'" : "'S'") + "," + + ToString( dH) + "," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del oggetto @@ -299,18 +299,18 @@ ExeCreateTextAdv( int nParentId, const Point3d& ptP, double dAngRotDeg, // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtTextAdv(" + IdToString( nParentId) + ",{" + - ToString( ptP) + "}," + - ToString( dAngRotDeg) + ",'" + - StringToLuaString( sText) + "','" + - StringToLuaString( sFont) + "'," + - ToString( nW) + "," + - ( bItalic ? "'I'" : "'S'") + "," + - ToString( dH) + "," + - ToString( dRat) + "," + - ToString( dAddAdv) + "," + - ETxtInsPosToString( nInsPos) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( ptP) + "}," + + ToString( dAngRotDeg) + ",'" + + StringToLuaString( sText) + "','" + + StringToLuaString( sFont) + "'," + + ToString( nW) + "," + + ( bItalic ? "'I'" : "'S'") + "," + + ToString( dH) + "," + + ToString( dRat) + "," + + ToString( dAddAdv) + "," + + ETxtInsPosToString( nInsPos) + "," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del oggetto @@ -397,12 +397,12 @@ ExeCreateHorizontalDimension( int nParentId, const Point3d& ptP1, const Point3d& // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtHorizontalDimension(" + IdToString( nParentId) + ",{" + - ToString( ptP1) + "},{" + - ToString( ptP2) + "},{" + - ToString( ptDim) + "},'" + - StringToLuaString( sText) + "'," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( ptP1) + "},{" + + ToString( ptP2) + "},{" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del oggetto @@ -420,12 +420,12 @@ ExeCreateVerticalDimension( int nParentId, const Point3d& ptP1, const Point3d& p // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtVerticalDimension(" + IdToString( nParentId ) + ",{" + - ToString( ptP1) + "},{" + - ToString( ptP2) + "},{" + - ToString( ptDim) + "},'" + - StringToLuaString( sText) + "'," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( ptP1) + "},{" + + ToString( ptP2) + "},{" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del oggetto @@ -443,12 +443,138 @@ ExeCreateAlignedDimension( int nParentId, const Point3d& ptP1, const Point3d& pt // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtAlignedDimension(" + IdToString( nParentId) + ",{" + - ToString( ptP1) + "},{" + - ToString( ptP2) + "},{" + - ToString( ptDim) + "},'" + - StringToLuaString( sText) + "'," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( ptP1) + "},{" + + ToString( ptP2) + "},{" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo del oggetto + return nId ; +} + +//------------------------------------------------------------------------------- +static int +MyCreateRadialDimension( int nParentId, int nCrvId, const Point3d& ptDim, + const string& sText, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + // recupero il riferimento locale + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + // recupero l'arco di circonferenza e il suo frame + ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nCrvId)) ; + if ( pArc == nullptr) + return GDB_ID_NULL ; + Frame3d frArc ; + if ( ! pGeomDB->GetGlobFrame( nCrvId, frArc)) + return GDB_ID_NULL ; + // porto il punto nel riferimento locale + Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ; + // recupero il centro e la normale e li porto nel riferimento locale + Point3d ptCenL = pArc->GetCenter() ; + ptCenL.LocToLoc( frArc, frLoc) ; + Vector3d vtNL = pArc->GetNormVersor() ; + vtNL.LocToLoc( frArc, frLoc) ; + // porto ptDimL sulla circonferenza cui appartiene l'arco + Vector3d vtDir = ptDimL - ptCenL ; + if ( ! vtDir.Normalize()) + return GDB_ID_NULL ; + ptDimL = ptCenL + pArc->GetRadius() * vtDir ; + // creo la quota + PtrOwner pDim( CreateExtDimension()) ; + if ( IsNull( pDim) || + ! MySetDimensionStyle( pDim) || + ! pDim->SetRadial( ptCenL, ptDimL, vtNL, sText)) + return GDB_ID_NULL ; + // inserisco la quota nel DB + return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ; +} + +//------------------------------------------------------------------------------- +int +ExeCreateRadialDimension( int nParentId, int nCrvId, const Point3d& ptDim, + const string& sText, int nRefType) +{ + // eseguo + int nId = MyCreateRadialDimension( nParentId, nCrvId, ptDim, sText, nRefType) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtRadialDimension(" + IdToString( nParentId) + "," + + IdToString( nCrvId) + ",{" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo del oggetto + return nId ; +} + +//------------------------------------------------------------------------------- +static int +MyCreateDiametralDimension( int nParentId, int nCrvId, const Point3d& ptDim, + const string& sText, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + // recupero il riferimento locale + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + // recupero l'arco e il suo frame + ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nCrvId)) ; + if ( pArc == nullptr) + return GDB_ID_NULL ; + Frame3d frArc ; + if ( ! pGeomDB->GetGlobFrame( nCrvId, frArc)) + return GDB_ID_NULL ; + // porto il punto nel riferimento locale + Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ; + // recupero il centro e la normale e li porto nel riferimento locale + Point3d ptCenL = pArc->GetCenter() ; + ptCenL.LocToLoc( frArc, frLoc) ; + Vector3d vtNL = pArc->GetNormVersor() ; + vtNL.LocToLoc( frArc, frLoc) ; + // porto ptDimL sulla circonferenza + Vector3d vtDir = ptDimL - ptCenL ; + if ( ! vtDir.Normalize()) + return GDB_ID_NULL ; + ptDimL = ptCenL + pArc->GetRadius() * vtDir ; + // creo la quota + PtrOwner pDim( CreateExtDimension()) ; + if ( IsNull( pDim) || + ! MySetDimensionStyle( pDim) || + ! pDim->SetDiametral( ptCenL, ptDimL, vtNL, sText)) + return GDB_ID_NULL ; + // inserisco la quota nel DB + return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ; +} + +//------------------------------------------------------------------------------- +int +ExeCreateDiametralDimension( int nParentId, int nCrvId, const Point3d& ptDim, + const string& sText, int nRefType) +{ + // eseguo + int nId = MyCreateDiametralDimension( nParentId, nCrvId, ptDim, sText, nRefType) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtDiametralDimension(" + IdToString( nParentId) + "," + + IdToString( nCrvId) + ",{" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del oggetto @@ -494,13 +620,13 @@ ExeCreateAngularDimension( int nParentId, const Point3d& ptP1, const Point3d& pt // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtAngularDimension(" + IdToString( nParentId) + ",{" + - ToString( ptP0) + "},{" + - ToString( ptP1) + "},{" + - ToString( ptP2) + "},{" + - ToString( ptDim) + "},'" + - StringToLuaString( sText) + "'," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( ptP0) + "},{" + + ToString( ptP1) + "},{" + + ToString( ptP2) + "},{" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del oggetto @@ -654,10 +780,6 @@ MyCreateAngularDimensionFromLines( int nParentId, INTVECTOR vLineIds, const Poin ptP3L = ptP4L ; } - - - - // creo la quota PtrOwner pDim( CreateExtDimension()) ; if ( IsNull( pDim ) || @@ -679,12 +801,12 @@ ExeCreateAngularDimensionFromLines( int nParentId, const INTVECTOR vLineIds, con // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtAngularDimensionFromLines(" + IdToString( nParentId) + "," + - ToString( vLineIds[0]) + "," + - ToString( vLineIds[1]) + ",{" + - ToString( ptDim) + "},'" + - StringToLuaString( sText) + "'," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( vLineIds[0]) + "," + + ToString( vLineIds[1]) + ",{" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del oggetto @@ -698,13 +820,13 @@ MyCreateAngularDimensionFromArc( int nParentId, int nCrvId, const Point3d& ptDim { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - nParentId = AdjustId( nParentId) ; + nParentId = AdjustId( nParentId) ; // recupero il riferimento locale Frame3d frLoc ; if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) return GDB_ID_NULL ; - //recupero l'arco e il suo frame + // recupero l'arco e il suo frame ICurveArc* pCurve = GetCurveArc( pGeomDB->GetGeoObj( nCrvId)) ; if ( pCurve == nullptr) return GDB_ID_NULL ; @@ -763,11 +885,11 @@ ExeCreateAngularDimensionFromArc( int nParentId, int nCrvId, const Point3d& ptDi // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtAngularDimensionFromArc(" + IdToString( nParentId) + "," + - IdToString( nCrvId) + ",{" + - ToString( ptDim) + "},'" + - StringToLuaString( sText) + "'," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + IdToString( nCrvId) + ",{" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del oggetto @@ -781,13 +903,13 @@ MyCreateAngularDimensionFromCircle( int nParentId, int nCrvId, const Point3d& pt { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - nParentId = AdjustId( nParentId ) ; + nParentId = AdjustId( nParentId ) ; // recupero il riferimento locale Frame3d frLoc ; if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) return GDB_ID_NULL ; - //recupero il cerchio e il suo frame + // recupero il cerchio e il suo frame ICurveArc* pCurve = GetCurveArc( pGeomDB->GetGeoObj( nCrvId)) ; if ( pCurve == nullptr) return GDB_ID_NULL ; @@ -806,7 +928,7 @@ MyCreateAngularDimensionFromCircle( int nParentId, int nCrvId, const Point3d& pt Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ; Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ; - //recupero il centro + // recupero il centro Point3d ptP0L ; pCrv->GetCenterPoint( ptP0L) ; @@ -850,181 +972,15 @@ ExeCreateAngularDimensionFromCircle( int nParentId, int nCrvId, const Point3d& p // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtAngularDimensionFromCircle(" + IdToString( nParentId) + "," + - IdToString( nCrvId) + ",{" + - ToString( ptP1) + "},'" + - ToString( ptP2) + "},'" + - ToString( ptDim) + "},'" + - StringToLuaString( sText) + "'," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + IdToString( nCrvId) + ",{" + + ToString( ptP1) + "},'" + + ToString( ptP2) + "},'" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del oggetto return nId ; } - -//------------------------------------------------------------------------------- -static int -MyCreateRadialDimension( int nParentId, int nCrvId, const Point3d& ptDim, - const string& sText, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - nParentId = AdjustId( nParentId) ; - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; - - //recupero il cerchio e il suo frame - ICurveArc* pCurve = GetCurveArc( pGeomDB->GetGeoObj( nCrvId)) ; - if ( pCurve == nullptr) - return GDB_ID_NULL ; - Frame3d frCrv; - if ( ! pGeomDB->GetGlobFrame( nCrvId, frCrv)) - return GDB_ID_NULL ; - - PtrOwner pCrv( pCurve->Clone()) ; - if ( IsNull( pCrv ) || ! pCrv->IsValid()) - return GDB_ID_NULL ; - - // porto tutto nel frLoc - pCrv->LocToLoc( frCrv, frLoc ) ; - Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ; - Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ; - Vector3d vtXL = GetVectorLocal( pGeomDB, X_AX, nRefType, frLoc) ; - - //recupero il centro e il raggio - Point3d ptP0L ; - double dRad = pCrv->GetRadius() ; - pCrv->GetCenterPoint( ptP0L) ; - - // porto ptDimL sul cerchio - Point3d ptDimNew ; - Vector3d vtDir = ptDimL - ptP0L ; - vtDir.Normalize() ; - ptDimNew = ptP0L + dRad * vtDir ; - - // proietto il punto sul piano XY della griglia - Frame3d frGrid = pGeomDB->GetGridFrame() ; - if ( ! frGrid.IsValid()) - return GDB_ID_NULL ; - Point3d ptOrig = frGrid.Orig() ; - ptDimNew -= ( ptDimNew - ptOrig) * vtNL * vtNL; - - // creo la quota - PtrOwner pDim( CreateExtDimension()) ; - if ( IsNull( pDim) || - ! MySetDimensionStyle( pDim) || - ! pDim->SetRadial( ptP0L, ptDimNew, vtXL, vtNL, sText)) - return GDB_ID_NULL ; - // inserisco la quota nel DB - return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ; -} - -//------------------------------------------------------------------------------- -int -ExeCreateRadialDimension( int nParentId, int nCrvId, const Point3d& ptDim, - const string& sText, int nRefType) -{ - // eseguo - int nId = MyCreateRadialDimension( nParentId, nCrvId, ptDim, sText, nRefType) ; - ExeSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtRadialDimension(" + IdToString( nParentId) + "," + - IdToString( nCrvId) + ",{" + - ToString( ptDim) + "},'" + - StringToLuaString( sText) + "'," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo del oggetto - return nId ; -} - -//------------------------------------------------------------------------------- -static int -MyCreateDiametralDimension( int nParentId, int nCrvId, const Point3d& ptDim, - const string& sText, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - nParentId = AdjustId( nParentId) ; - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; - - //recupero il cerchio e il suo frame - ICurveArc* pCurve = GetCurveArc( pGeomDB->GetGeoObj( nCrvId)) ; - if ( pCurve == nullptr) - return GDB_ID_NULL ; - Frame3d frCrv; - if ( ! pGeomDB->GetGlobFrame( nCrvId, frCrv)) - return GDB_ID_NULL ; - - PtrOwner pCrv( pCurve->Clone()) ; - if ( IsNull( pCrv ) || ! pCrv->IsValid()) - return GDB_ID_NULL ; - - // porto tutto nel frLoc - pCrv->LocToLoc( frCrv, frLoc ) ; - Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ; - Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ; - Vector3d vtXL = GetVectorLocal( pGeomDB, X_AX, nRefType, frLoc) ; - - //recupero il centro e il raggio - Point3d ptP0L ; - double dRad = pCrv->GetRadius() ; - pCrv->GetCenterPoint( ptP0L) ; - - // porto ptDimL sul cerchio se non lo è già - Point3d ptDimNew ; - if ( pCrv->IsPointOn(ptDim)) - ptDimNew = ptDim ; - else { - Vector3d vtDir = ptDimL - ptP0L ; - vtDir.Normalize() ; - ptDimNew = ptP0L + dRad * vtDir ; - } - - // proietto il punto sul piano XY della griglia - Frame3d frGrid = pGeomDB->GetGridFrame() ; - if ( ! frGrid.IsValid()) - return GDB_ID_NULL ; - Point3d ptOrig = frGrid.Orig() ; - ptDimNew -= ( ptDimNew - ptOrig) * vtNL * vtNL; - - // creo la quota - PtrOwner pDim( CreateExtDimension()) ; - if ( IsNull( pDim) || - ! MySetDimensionStyle( pDim) || - ! pDim->SetDiametral( ptP0L, ptDimNew, vtXL, vtNL, sText)) - return GDB_ID_NULL ; - // inserisco la quota nel DB - return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ; -} - -//------------------------------------------------------------------------------- -int -ExeCreateDiametralDimension( int nParentId, int nCrvId, const Point3d& ptDim, - const string& sText, int nRefType) -{ - // eseguo - int nId = MyCreateDiametralDimension( nParentId, nCrvId, ptDim, sText, nRefType) ; - ExeSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtDiametralDimension(" + IdToString( nParentId) + "," + - IdToString( nCrvId) + ",{" + - ToString( ptDim) + "},'" + - StringToLuaString( sText) + "'," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo del oggetto - return nId ; -} \ No newline at end of file diff --git a/EgtExecutor.rc b/EgtExecutor.rc index ad09f97..fdde8b8 100644 Binary files a/EgtExecutor.rc and b/EgtExecutor.rc differ diff --git a/LUA_GdbCreate.cpp b/LUA_GdbCreate.cpp index b27e058..7857cbe 100644 --- a/LUA_GdbCreate.cpp +++ b/LUA_GdbCreate.cpp @@ -344,6 +344,58 @@ LuaCreateAlignedDimension( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCreateRadialDimension( lua_State* L) +{ + // 4 o 5 parametri : nParentId, nCrvId, ptDim, Text [, nRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + int nCrvId ; + LuaCheckParam( L, 2, nCrvId) ; + Point3d ptDim ; + LuaCheckParam( L, 3, ptDim) ; + string sText ; + LuaCheckParam( L, 4, sText) ; + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 5, nRefType) ; + LuaClearStack( L ) ; + // creo la quota allineata + int nId = ExeCreateRadialDimension( nParentId, nCrvId, ptDim, sText, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaCreateDiametralDimension( lua_State* L ) +{ + // 4 o 5 parametri : nParentId, nCrvId, ptDim, Text [, nRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + int nCrvId ; + LuaCheckParam( L, 2, nCrvId) ; + Point3d ptDim ; + LuaCheckParam( L, 3, ptDim) ; + string sText ; + LuaCheckParam( L, 4, sText) ; + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 5, nRefType) ; + LuaClearStack( L) ; + // creo la quota allineata + int nId = ExeCreateDiametralDimension( nParentId, nCrvId, ptDim, sText, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaCreateAngularDimension(lua_State* L) @@ -374,6 +426,7 @@ LuaCreateAngularDimension(lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- static int LuaCreateAngularDimensionFromLines( lua_State* L) { @@ -399,6 +452,7 @@ LuaCreateAngularDimensionFromLines( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- static int LuaCreateAngularDimensionFromArc( lua_State* L) { @@ -424,6 +478,7 @@ LuaCreateAngularDimensionFromArc( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- static int LuaCreateAngularDimensionFromCircle( lua_State* L) { @@ -453,56 +508,6 @@ LuaCreateAngularDimensionFromCircle( lua_State* L) return 1 ; } -static int -LuaCreateRadialDimension( lua_State* L) -{ - // 4 o 5 parametri : nParentId, nCrvId, ptDim, Text [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - int nCrvId ; - LuaCheckParam( L, 2, nCrvId) ; - Point3d ptDim ; - LuaCheckParam( L, 3, ptDim) ; - string sText ; - LuaCheckParam( L, 4, sText) ; - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 5, nRefType) ; - LuaClearStack( L ) ; - // creo la quota allineata - int nId = ExeCreateRadialDimension( nParentId, nCrvId, ptDim, sText, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetParam( L, nId) ; - else - LuaSetParam( L) ; - return 1 ; -} - -static int -LuaCreateDiametralDimension( lua_State* L ) -{ - // 4 o 5 parametri : nParentId, nCrvId, ptDim, Text [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - int nCrvId ; - LuaCheckParam( L, 2, nCrvId) ; - Point3d ptDim ; - LuaCheckParam( L, 3, ptDim) ; - string sText ; - LuaCheckParam( L, 4, sText) ; - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 5, nRefType) ; - LuaClearStack( L) ; - // creo la quota allineata - int nId = ExeCreateDiametralDimension( nParentId, nCrvId, ptDim, sText, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetParam( L, nId) ; - else - LuaSetParam( L) ; - return 1 ; -} - //------------------------------------------------------------------------------- bool LuaInstallGdbCreate( LuaMgr& luaMgr) @@ -520,11 +525,11 @@ LuaInstallGdbCreate( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtHorizontalDimension", LuaCreateHorizontalDimension) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVerticalDimension", LuaCreateVerticalDimension) ; bOk = bOk && luaMgr.RegisterFunction( "EgtAlignedDimension", LuaCreateAlignedDimension) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtRadialDimension", LuaCreateRadialDimension) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtDiametralDimension", LuaCreateDiametralDimension) ; bOk = bOk && luaMgr.RegisterFunction( "EgtAngularDimension", LuaCreateAngularDimension); bOk = bOk && luaMgr.RegisterFunction( "EgtAngularDimensionFromLines", LuaCreateAngularDimensionFromLines) ; bOk = bOk && luaMgr.RegisterFunction( "EgtAngularDimensionFromArc", LuaCreateAngularDimensionFromArc) ; bOk = bOk && luaMgr.RegisterFunction( "EgtAngularDimensionFromCircle", LuaCreateAngularDimensionFromCircle) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtRadialDimension", LuaCreateRadialDimension) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtDiametralDimension", LuaCreateDiametralDimension) ; return bOk ; }