diff --git a/API.h b/API.h index 4df2f66..d540d42 100644 --- a/API.h +++ b/API.h @@ -42,7 +42,7 @@ BOOL __stdcall EgtModifyText( int nId, const std::string& sNewText) ; BOOL __stdcall EgtChangeTextFont( int nId, const std::string& sNewFont) ; //--------------------------- GdbObjAttribs ---------------------------------- -BOOL __stdcall EgtStdColor( const std::string& sName, int& nRed, int& nGreen, int& nBlue, int& nAlpha) ; +BOOL __stdcall EgtStdColor( const std::string& sName, Color& StdCol) ; BOOL __stdcall EgtSetName( int nId, const std::string& sName) ; BOOL __stdcall EgtGetName( int nId, std::string& sName) ; BOOL __stdcall EgtSetInfo( int nId, const std::string& sKey, const std::string& sInfo) ; @@ -53,6 +53,12 @@ BOOL __stdcall EgtRemoveInfo( int nId, const std::string& sKey) ; //--------------------------- GeoSnap ---------------------------------------- BOOL __stdcall EgtFrame( int nId, Frame3d& frFrame) ; +//--------------------------- Scene ------------------------------------------ +BOOL __stdcall EgtSetBackground( Color TopCol, Color BottomCol, BOOL bRedraw) ; +BOOL __stdcall EgtSetMarkAttribs( Color MarkCol) ; +BOOL __stdcall EgtSetGeoLineAttribs( Color GlCol) ; +BOOL __stdcall EgtSetWinRectAttribs( BOOL bOutline, Color WrCol) ; + //--------------------------- Exchange --------------------------------------- int __stdcall EgtGetFileType( const std::string& sFilePath) ; BOOL __stdcall EgtImportDxf( const std::string& sFilePath) ; diff --git a/API_CurveModif.cpp b/API_CurveModif.cpp index b04affb..aeee5a4 100644 --- a/API_CurveModif.cpp +++ b/API_CurveModif.cpp @@ -16,10 +16,8 @@ #include "API.h" #include "API_Macro.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EgkGeoPoint3d.h" -#include "/EgtDev/Include/EgkGeoVector3d.h" #include "/EgtDev/Include/EgkCurve.h" -#include "/EgtDev/Include/EgkExtText.h" +#include "/EgtDev/Include/EgkCurveArc.h" //---------------------------------------------------------------------------- @@ -161,3 +159,51 @@ __stdcall EgtTrimCurveStartEndAtParam( int nId, double dParS, double dParE) // taglio la curva all'inizio return ( pCurve->TrimStartEndAtParam( dParS, dParE) ? TRUE : FALSE) ; } + +//------------------------------------------------------------------------------- +BOOL +__stdcall EgtModifyCurveArc3P( int nId, const double ptMid[3]) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // recupero l'arco e i suoi punti notevoli + ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ; + if ( pArc == nullptr) + return FALSE ; + Point3d ptStart, ptOldMid, ptEnd ; + if ( ! pArc->GetStartPoint( ptStart) || ! pArc->GetMidPoint( ptOldMid) || ! pArc->GetEndPoint( ptEnd)) + return false ; + // imposto il nuovo punto medio + if ( pArc->Set3P( ptStart, ptMid, ptEnd)) + return TRUE ; + // in caso di errore, ripristino i vecchi dati + else { + pArc->Set3P( ptStart, ptOldMid, ptEnd) ; + return FALSE ; + } +} + +//------------------------------------------------------------------------------- +BOOL +__stdcall EgtModifyCurveArcC2PN( int nId, const double ptEnd[3]) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // recupero l'arco e i suoi dati + ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ; + if ( pArc == nullptr) + return FALSE ; + Point3d ptCen = pArc->GetCenter() ; + Vector3d vtN = pArc->GetNormVersor() ; + Point3d ptStart, ptOldEnd ; + if ( ! pArc->GetStartPoint( ptStart) || ! pArc->GetEndPoint( ptOldEnd)) + return FALSE ; + // imposto il nuovo punto finale + if ( pArc->SetC2PN( ptCen, ptStart, ptEnd, vtN)) + return TRUE ; + // in caso di errore, ripristino i vecchi dati + else { + pArc->SetC2PN( ptCen, ptStart, ptOldEnd, vtN) ; + return FALSE ; + } +} diff --git a/API_GdbCreate.cpp b/API_GdbCreate.cpp index 5fe62b6..2f273ce 100644 --- a/API_GdbCreate.cpp +++ b/API_GdbCreate.cpp @@ -269,6 +269,24 @@ __stdcall EgtCreateCurveArc3P( int nParentId, return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; } +//------------------------------------------------------------------------------- +int +__stdcall EgtCreateCurveArcC2PN( int nParentId, + const double ptCen[3], const double ptStart[3], const double ptNearEnd[3], const double vtNorm[3]) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // creo l'arco + PtrOwner pCrvArc( CreateCurveArc()) ; + if ( IsNull( pCrvArc)) + return GDB_ID_NULL ; + // setto l'arco + if ( ! pCrvArc->SetC2PN( ptCen, ptStart, ptNearEnd, vtNorm)) + return GDB_ID_NULL ; + // inserisco l'arco nel DB + return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; +} + //------------------------------------------------------------------------------- int __stdcall EgtCreateCurveBezier( int nParentId, int nDegree, const double ptCtrls[]) diff --git a/API_GdbModify.cpp b/API_GdbModify.cpp index 40fac82..6b0a0cd 100644 --- a/API_GdbModify.cpp +++ b/API_GdbModify.cpp @@ -19,10 +19,6 @@ #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EgkGeoPoint3d.h" #include "/EgtDev/Include/EgkGeoVector3d.h" -#include "/EgtDev/Include/EgkCurveLine.h" -#include "/EgtDev/Include/EgkCurveArc.h" -#include "/EgtDev/Include/EgkCurveBezier.h" -#include "/EgtDev/Include/EgkCurveComposite.h" #include "/EgtDev/Include/EgkSurfTriMesh.h" #include "/EgtDev/Include/EgkExtText.h" #include "/EgtDev/Include/EGnStringConverter.h" @@ -31,6 +27,25 @@ using namespace std ; +//------------------------------------------------------------------------------- +BOOL +__stdcall EgtChangeGroupFrame( int nId, + double ptOrig[3], double vtX[3], double vtY[3], double vtZ[3]) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // recupero il riferimento del gruppo + Frame3d* pFrame = pGeomDB->GetGroupFrame( nId) ; + if ( pFrame == nullptr) + return FALSE ; + // imposto il nuovo riferimento + Frame3d frNew ; + if ( ! frNew.Set( ptOrig, vtX, vtY, vtZ)) + return FALSE ; + *pFrame = frNew ; + return TRUE ; +} + //------------------------------------------------------------------------------- BOOL __stdcall EgtChangeVectorBase( int nId, const double ptB[3]) diff --git a/API_GdbObjAttribs.cpp b/API_GdbObjAttribs.cpp index ca43378..07ca22c 100644 --- a/API_GdbObjAttribs.cpp +++ b/API_GdbObjAttribs.cpp @@ -209,52 +209,51 @@ __stdcall EgtGetCalcMark( int nId, BOOL* pbMark) //----------------------------------------------------------------------------- BOOL -__stdcall EgtStdColor( const wchar_t* wsName, int& nRed, int& nGreen, int& nBlue, int& nAlpha) +__stdcall EgtStdColor( const wchar_t* wsName, int StdCol[4]) { - return EgtStdColor( wstrztoA( wsName), nRed, nGreen, nBlue, nAlpha) ; -} - -//----------------------------------------------------------------------------- -BOOL -__stdcall EgtStdColor( const string& sName, int& nRed, int& nGreen, int& nBlue, int& nAlpha) -{ - // recupero il colore standard - Color cCol ; - if ( GetStdColor( sName, cCol)) { - nRed = cCol.GetIntRed() ; - nGreen = cCol.GetIntGreen() ; - nBlue = cCol.GetIntBlue() ; - nAlpha = cCol.GetIntAlpha() ; + Color ColStd ; + if ( EgtStdColor( wstrztoA( wsName), ColStd) != FALSE) { + StdCol[0] = ColStd.GetIntRed() ; + StdCol[1] = ColStd.GetIntGreen() ; + StdCol[2] = ColStd.GetIntBlue() ; + StdCol[3] = ColStd.GetIntAlpha() ; return TRUE ; } - else - return FALSE ; + return FALSE ; } //----------------------------------------------------------------------------- BOOL -__stdcall EgtSetColor( int nId, int nRed, int nGreen, int nBlue, int nAlpha) +__stdcall EgtStdColor( const string& sName, Color& StdCol) +{ + // recupero il colore standard + return ( GetStdColor( sName, StdCol) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetColor( int nId, const int ObjCol[4]) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // assegno il colore - Color cCol( nRed, nGreen, nBlue, nAlpha) ; + Color cCol( ObjCol) ; return ( pGeomDB->SetMaterial( nId, cCol) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL -__stdcall EgtGetColor( int nId, int& nRed, int& nGreen, int& nBlue, int& nAlpha) +__stdcall EgtGetColor( int nId, int ObjCol[4]) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // recupero il colore Color cCol ; if ( pGeomDB->GetMaterial( nId, cCol)) { - nRed = cCol.GetIntRed() ; - nGreen = cCol.GetIntGreen() ; - nBlue = cCol.GetIntBlue() ; - nAlpha = cCol.GetIntAlpha() ; + ObjCol[0] = cCol.GetIntRed() ; + ObjCol[1] = cCol.GetIntGreen() ; + ObjCol[2] = cCol.GetIntBlue() ; + ObjCol[3] = cCol.GetIntAlpha() ; return TRUE ; } else @@ -263,17 +262,17 @@ __stdcall EgtGetColor( int nId, int& nRed, int& nGreen, int& nBlue, int& nAlpha) //----------------------------------------------------------------------------- BOOL -__stdcall EgtGetCalcColor( int nId, int& nRed, int& nGreen, int& nBlue, int& nAlpha) +__stdcall EgtGetCalcColor( int nId, int ObjCol[4]) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // recupero il colore Color cCol ; if ( pGeomDB->GetCalcMaterial( nId, cCol)) { - nRed = cCol.GetIntRed() ; - nGreen = cCol.GetIntGreen() ; - nBlue = cCol.GetIntBlue() ; - nAlpha = cCol.GetIntAlpha() ; + ObjCol[0] = cCol.GetIntRed() ; + ObjCol[1] = cCol.GetIntGreen() ; + ObjCol[2] = cCol.GetIntBlue() ; + ObjCol[3] = cCol.GetIntAlpha() ; return TRUE ; } else diff --git a/API_GdbObjects.cpp b/API_GdbObjects.cpp index 8239000..88b8763 100644 --- a/API_GdbObjects.cpp +++ b/API_GdbObjects.cpp @@ -33,6 +33,34 @@ BOOL return ( pGeomDB->ExistsObj( nId) ? TRUE : FALSE) ; } +//----------------------------------------------------------------------------- +int +__stdcall EgtGetParent( int nId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // verifico se esiste l'oggetto + return pGeomDB->GetParentId( nId) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetGroupGlobFrame( int nId, double ptOrig[3], double vtX[3], double vtY[3], double vtZ[3]) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // recupero il riferimento globale del gruppo + Frame3d frGlob ; + if ( ! pGeomDB->GetGroupGlobFrame( nId, frGlob)) + return FALSE ; + // aggiorno i parametri del frame + VEC_FROM_3D( ptOrig, frGlob.Orig()) + VEC_FROM_3D( vtX, frGlob.VersX()) + VEC_FROM_3D( vtY, frGlob.VersY()) + VEC_FROM_3D( vtZ, frGlob.VersZ()) + return TRUE ; +} + //----------------------------------------------------------------------------- int __stdcall EgtGetGroupObjs( int nId) @@ -40,7 +68,7 @@ int IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero il numero di oggetti nel gruppo - return ( pGeomDB->GetGroupObjs( nId)) ; + return pGeomDB->GetGroupObjs( nId) ; } //----------------------------------------------------------------------------- @@ -83,6 +111,46 @@ __stdcall EgtGetPrev( int nId) return pGeomDB->GetPrev( nId) ; } +//----------------------------------------------------------------------------- +int +__stdcall EgtGetFirstGroupInGroup( int nGroupId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero il primo gruppo nel gruppo + return pGeomDB->GetFirstGroupInGroup( nGroupId) ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtGetNextGroup( int nId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero il prossimo gruppo nello stesso gruppo + return pGeomDB->GetNextGroup( nId) ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtGetLastGroupInGroup( int nGroupId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero l'ultimo gruppo nel gruppo + return pGeomDB->GetLastGroupInGroup( nGroupId) ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtGetPrevGroup( int nId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero il precedente gruppo nello stesso gruppo + return pGeomDB->GetPrevGroup( nId) ; +} + //----------------------------------------------------------------------------- BOOL __stdcall EgtGetBBox( int nId, int nFlag, double ptMin[3], double ptMax[3]) @@ -167,8 +235,21 @@ __stdcall EgtErase( int nId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // eseguo la cancellazione - return ( pGeomDB->Erase( nId) ? TRUE : FALSE) ; + // eseguo cancellazione singola + if ( nId != GDB_ID_SEL) { + return ( pGeomDB->Erase( nId) ? TRUE : FALSE) ; + } + // eseguo cancellazione dei selezionati + else { + bool bOk = true ; + int nI = pGeomDB->GetFirstSelectedObj() ; + while ( nI != GDB_ID_NULL && bOk) { + if ( ! pGeomDB->Erase( nI)) + bOk = false ; + nI = pGeomDB->GetFirstSelectedObj() ; + } + return ( bOk ? TRUE : FALSE) ; + } } //----------------------------------------------------------------------------- diff --git a/API_GeoBase.cpp b/API_GeoBase.cpp index e1b347d..b6fa341 100644 --- a/API_GeoBase.cpp +++ b/API_GeoBase.cpp @@ -20,9 +20,6 @@ using namespace std ; -//----------------------------------------------------------------------------- -#define VEC_FROM_3D( D, S) { (D)[0] = (S).x ; (D)[1] = (S).y ; (D)[2] = (S).z ; } - //----------------------------------------------------------------------------- // Vector3d //----------------------------------------------------------------------------- @@ -175,6 +172,19 @@ __stdcall EgtVectorLocToLoc( double* pdX, double* pdY, double* pdZ, return TRUE ; } +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetVectorRotation( const double vtS[3], const double vtE[3], const double vtAx[3], + double* pdAngRotDeg, BOOL* pbDet) +{ + Vector3d vtSou( vtS) ; + bool bDet ; + bool bOk = vtSou.GetRotation( vtE, vtAx, *pdAngRotDeg, bDet) ; + *pbDet = ( bDet ? TRUE : FALSE) ; + return ( bOk ? TRUE : FALSE) ; +} + + //----------------------------------------------------------------------------- // Point3d //----------------------------------------------------------------------------- diff --git a/API_GeoSnap.cpp b/API_GeoSnap.cpp index 1858190..d0504b4 100644 --- a/API_GeoSnap.cpp +++ b/API_GeoSnap.cpp @@ -403,4 +403,69 @@ __stdcall EgtFrame( int nId, Frame3d& frFrame) } // altrimenti errore return FALSE ; -} \ No newline at end of file +} + +//------------------------------------------------------------------------------- +// Geo Transforms +//------------------------------------------------------------------------------- +BOOL +__stdcall EgtVectorToIdGlob( double vtV[3], int nId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // recupero il riferimento + // se gruppo -> il suo proprio espresso in globale + // se oggetto -> quello del gruppo cui appartiene in globale + Frame3d frRef ; + if ( ! pGeomDB->GetGroupGlobFrame( nId, frRef) && + ! pGeomDB->GetGlobFrame( nId, frRef)) + return FALSE ; + // eseguo la trasformazione + Vector3d vtVG( vtV) ; + vtVG.ToGlob( frRef) ; + // aggiorno il parametro punto + VEC_FROM_3D( vtV, vtVG) + return TRUE ; +} + +//------------------------------------------------------------------------------- +BOOL +__stdcall EgtVectorToIdLoc( double vtV[3], int nId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // recupero il riferimento + // se gruppo -> il suo proprio espresso in globale + // se oggetto -> quello del gruppo cui appartiene in globale + Frame3d frRef ; + if ( ! pGeomDB->GetGroupGlobFrame( nId, frRef) && + ! pGeomDB->GetGlobFrame( nId, frRef)) + return FALSE ; + // eseguo la trasformazione + Vector3d vtVG( vtV) ; + vtVG.ToLoc( frRef) ; + // aggiorno il parametro punto + VEC_FROM_3D( vtV, vtVG) + return TRUE ; +} + +//------------------------------------------------------------------------------- +BOOL +__stdcall EgtPointToIdLoc( double ptP[3], int nId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // recupero il riferimento + // se gruppo -> il suo proprio espresso in globale + // se oggetto -> quello del gruppo cui appartiene in globale + Frame3d frRef ; + if ( ! pGeomDB->GetGroupGlobFrame( nId, frRef) && + ! pGeomDB->GetGlobFrame( nId, frRef)) + return FALSE ; + // eseguo la trasformazione + Point3d ptPL( ptP) ; + ptPL.ToLoc( frRef) ; + // aggiorno il parametro punto + VEC_FROM_3D( ptP, ptPL) + return TRUE ; +} diff --git a/API_GeoTransform.cpp b/API_GeoTransform.cpp index f088968..271f658 100644 --- a/API_GeoTransform.cpp +++ b/API_GeoTransform.cpp @@ -19,7 +19,6 @@ using namespace std ; - //------------------------------------------------------------------------------- BOOL __stdcall EgtMove( int nId, double vVtMove[3]) @@ -166,11 +165,25 @@ __stdcall EgtScale( int nId, const double vOrig[3], { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) - // eseguo scalatura + // costruisco il riferimento di scalatura Frame3d frFrame ; if ( ! frFrame.Set( vOrig, vX, vY, vZ)) return FALSE ; - return ( pGeomDB->Scale( nId, frFrame, dCoeffX, dCoeffY, dCoeffZ) ? TRUE : FALSE) ; + // eseguo scalatura singola + if ( nId != GDB_ID_SEL) { + return ( pGeomDB->Scale( nId, frFrame, dCoeffX, dCoeffY, dCoeffZ) ? TRUE : FALSE) ; + } + // eseguo scalatura dei selezionati + else { + bool bOk = true ; + int nI = pGeomDB->GetFirstSelectedObj() ; + while ( nI != GDB_ID_NULL && bOk) { + if ( ! pGeomDB->Scale( nI, frFrame, dCoeffX, dCoeffY, dCoeffZ)) + bOk = false ; + nI = pGeomDB->GetNextSelectedObj() ; + } + return ( bOk ? TRUE : FALSE) ; + } } //------------------------------------------------------------------------------- @@ -181,11 +194,25 @@ __stdcall EgtScaleGlob( int nId, const double vOrig[3], { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) - // eseguo scalatura + // costruisco il riferimento di scalatura Frame3d frFrame ; if ( ! frFrame.Set( vOrig, vX, vY, vZ)) return FALSE ; - return ( pGeomDB->ScaleGlob( nId, frFrame, dCoeffX, dCoeffY, dCoeffZ) ? TRUE : FALSE) ; + // eseguo scalatura singola + if ( nId != GDB_ID_SEL) { + return ( pGeomDB->ScaleGlob( nId, frFrame, dCoeffX, dCoeffY, dCoeffZ) ? TRUE : FALSE) ; + } + // eseguo scalatura dei selezionati + else { + bool bOk = true ; + int nI = pGeomDB->GetFirstSelectedObj() ; + while ( nI != GDB_ID_NULL && bOk) { + if ( ! pGeomDB->ScaleGlob( nI, frFrame, dCoeffX, dCoeffY, dCoeffZ)) + bOk = false ; + nI = pGeomDB->GetNextSelectedObj() ; + } + return ( bOk ? TRUE : FALSE) ; + } } //------------------------------------------------------------------------------- @@ -196,11 +223,25 @@ __stdcall EgtScaleGroup( int nId, const double vOrig[3], { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) - // eseguo scalatura + // costruisco il riferimento di scalatura Frame3d frFrame ; if ( ! frFrame.Set( vOrig, vX, vY, vZ)) return FALSE ; - return ( pGeomDB->ScaleGroup( nId, frFrame, dCoeffX, dCoeffY, dCoeffZ) ? TRUE : FALSE) ; + // eseguo scalatura singola + if ( nId != GDB_ID_SEL) { + return ( pGeomDB->ScaleGroup( nId, frFrame, dCoeffX, dCoeffY, dCoeffZ) ? TRUE : FALSE) ; + } + // eseguo scalatura dei selezionati + else { + bool bOk = true ; + int nI = pGeomDB->GetFirstSelectedObj() ; + while ( nI != GDB_ID_NULL && bOk) { + if ( ! pGeomDB->ScaleGroup( nI, frFrame, dCoeffX, dCoeffY, dCoeffZ)) + bOk = false ; + nI = pGeomDB->GetNextSelectedObj() ; + } + return ( bOk ? TRUE : FALSE) ; + } } //------------------------------------------------------------------------------- @@ -209,8 +250,21 @@ __stdcall EgtMirror( int nId, const double vPnt[3], const double vN[3]) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) - // eseguo specularità - return ( pGeomDB->Mirror( nId, vPnt, vN) ? TRUE : FALSE) ; + // eseguo specularità singola + if ( nId != GDB_ID_SEL) { + return ( pGeomDB->Mirror( nId, vPnt, vN) ? TRUE : FALSE) ; + } + // eseguo specularità dei selezionati + else { + bool bOk = true ; + int nI = pGeomDB->GetFirstSelectedObj() ; + while ( nI != GDB_ID_NULL && bOk) { + if ( ! pGeomDB->Mirror( nI, vPnt, vN)) + bOk = false ; + nI = pGeomDB->GetNextSelectedObj() ; + } + return ( bOk ? TRUE : FALSE) ; + } } //------------------------------------------------------------------------------- @@ -219,8 +273,21 @@ __stdcall EgtMirrorGlob( int nId, const double vPnt[3], const double vN[3]) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) - // eseguo specularità - return ( pGeomDB->MirrorGlob( nId, vPnt, vN) ? TRUE : FALSE) ; + // eseguo specularità singola + if ( nId != GDB_ID_SEL) { + return ( pGeomDB->MirrorGlob( nId, vPnt, vN) ? TRUE : FALSE) ; + } + // eseguo specularità dei selezionati + else { + bool bOk = true ; + int nI = pGeomDB->GetFirstSelectedObj() ; + while ( nI != GDB_ID_NULL && bOk) { + if ( ! pGeomDB->MirrorGlob( nI, vPnt, vN)) + bOk = false ; + nI = pGeomDB->GetNextSelectedObj() ; + } + return ( bOk ? TRUE : FALSE) ; + } } //------------------------------------------------------------------------------- @@ -229,8 +296,21 @@ __stdcall EgtMirrorGroup( int nId, const double vPnt[3], const double vN[3]) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) - // eseguo specularità - return ( pGeomDB->MirrorGroup( nId, vPnt, vN) ? TRUE : FALSE) ; + // eseguo specularità singola + if ( nId != GDB_ID_SEL) { + return ( pGeomDB->MirrorGroup( nId, vPnt, vN) ? TRUE : FALSE) ; + } + // eseguo specularità dei selezionati + else { + bool bOk = true ; + int nI = pGeomDB->GetFirstSelectedObj() ; + while ( nI != GDB_ID_NULL && bOk) { + if ( ! pGeomDB->MirrorGroup( nI, vPnt, vN)) + bOk = false ; + nI = pGeomDB->GetNextSelectedObj() ; + } + return ( bOk ? TRUE : FALSE) ; + } } //------------------------------------------------------------------------------- @@ -240,8 +320,21 @@ __stdcall EgtShear( int nId, const double vPnt[3], const double vN[3], { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) - // eseguo stiramento - return ( pGeomDB->Shear( nId, vPnt, vN, vDir, dCoeff) ? TRUE : FALSE) ; + // eseguo stiramento singolo + if ( nId != GDB_ID_SEL) { + return ( pGeomDB->Shear( nId, vPnt, vN, vDir, dCoeff) ? TRUE : FALSE) ; + } + // eseguo stiramento dei selezionati + else { + bool bOk = true ; + int nI = pGeomDB->GetFirstSelectedObj() ; + while ( nI != GDB_ID_NULL && bOk) { + if ( ! pGeomDB->Shear( nI, vPnt, vN, vDir, dCoeff)) + bOk = false ; + nI = pGeomDB->GetNextSelectedObj() ; + } + return ( bOk ? TRUE : FALSE) ; + } } //------------------------------------------------------------------------------- @@ -251,8 +344,21 @@ __stdcall EgtShearGlob( int nId, const double vPnt[3], const double vN[3], { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) - // eseguo stiramento - return ( pGeomDB->ShearGlob( nId, vPnt, vN, vDir, dCoeff) ? TRUE : FALSE) ; + // eseguo stiramento singolo + if ( nId != GDB_ID_SEL) { + return ( pGeomDB->ShearGlob( nId, vPnt, vN, vDir, dCoeff) ? TRUE : FALSE) ; + } + // eseguo stiramento dei selezionati + else { + bool bOk = true ; + int nI = pGeomDB->GetFirstSelectedObj() ; + while ( nI != GDB_ID_NULL && bOk) { + if ( ! pGeomDB->ShearGlob( nI, vPnt, vN, vDir, dCoeff)) + bOk = false ; + nI = pGeomDB->GetNextSelectedObj() ; + } + return ( bOk ? TRUE : FALSE) ; + } } //------------------------------------------------------------------------------- @@ -262,6 +368,19 @@ __stdcall EgtShearGroup( int nId, const double vPnt[3], const double vN[3], { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) - // eseguo stiramento - return ( pGeomDB->ShearGroup( nId, vPnt, vN, vDir, dCoeff) ? TRUE : FALSE) ; + // eseguo stiramento singolo + if ( nId != GDB_ID_SEL) { + return ( pGeomDB->ShearGroup( nId, vPnt, vN, vDir, dCoeff) ? TRUE : FALSE) ; + } + // eseguo stiramento dei selezionati + else { + bool bOk = true ; + int nI = pGeomDB->GetFirstSelectedObj() ; + while ( nI != GDB_ID_NULL && bOk) { + if ( ! pGeomDB->ShearGroup( nI, vPnt, vN, vDir, dCoeff)) + bOk = false ; + nI = pGeomDB->GetNextSelectedObj() ; + } + return ( bOk ? TRUE : FALSE) ; + } } diff --git a/API_GeomDB.cpp b/API_GeomDB.cpp index ec9b37b..3efc3b7 100644 --- a/API_GeomDB.cpp +++ b/API_GeomDB.cpp @@ -73,12 +73,12 @@ __stdcall EgtGetCurrentContext( void) //----------------------------------------------------------------------------- BOOL -__stdcall EgtSetDefaultMaterial( int nRed, int nGreen, int nBlue) +__stdcall EgtSetDefaultMaterial( const int vCol[4]) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_GEOMDB( pGseCtx, FALSE) // imposto il materiale di default - pGseCtx->m_colDef.Set( nRed, nGreen, nBlue) ; + pGseCtx->m_colDef.Set( vCol) ; pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ; return TRUE ; } diff --git a/API_Macro.h b/API_Macro.h index 5ca1865..1e73d48 100644 --- a/API_Macro.h +++ b/API_Macro.h @@ -43,3 +43,6 @@ //----------------------------------------------------------------------------- #define VERIFY_TSCEXEC( pT, Ret) VERIFY_NULL( pT, "TscExecutor invalid", Ret) + +//----------------------------------------------------------------------------- +#define VEC_FROM_3D( D, S) { (D)[0] = (S).x ; (D)[1] = (S).y ; (D)[2] = (S).z ; } diff --git a/API_Scene.cpp b/API_Scene.cpp index 03a606e..93160d7 100644 --- a/API_Scene.cpp +++ b/API_Scene.cpp @@ -55,14 +55,19 @@ __stdcall EgtInitScene( HWND hWnd, int nDriver, int b2Buff, int nColorBits, int //----------------------------------------------------------------------------- BOOL -__stdcall EgtSetBackground( int nTopRed, int nTopGreen, int nTopBlue, - int nBottomRed, int nBottomGreen, int nBottomBlue, BOOL bRedraw) +__stdcall EgtSetBackground( const int TopCol[4], const int BottomCol[4], BOOL bRedraw) +{ + return EgtSetBackground( Color( TopCol), Color( BottomCol), bRedraw) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetBackground( Color TopCol, Color BottomCol, BOOL bRedraw) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_SCENE( pGseCtx, FALSE) // imposto lo sfondo - pGseCtx->m_pScene->SetBackground( Color( nTopRed, nTopGreen, nTopBlue), - Color( nBottomRed, nBottomGreen, nBottomBlue)) ; + pGseCtx->m_pScene->SetBackground( TopCol, BottomCol) ; if ( bRedraw) pGseCtx->m_pScene->RedrawWindow() ; return TRUE ; @@ -70,35 +75,115 @@ __stdcall EgtSetBackground( int nTopRed, int nTopGreen, int nTopBlue, //----------------------------------------------------------------------------- BOOL -__stdcall EgtSetMarkAttribs( int nRed, int nGreen, int nBlue) +__stdcall EgtSetMarkAttribs( const int MarkCol[4]) +{ + return EgtSetMarkAttribs( Color( MarkCol)) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetMarkAttribs( Color MarkCol) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_SCENE( pGseCtx, FALSE) // imposto il colore del Mark - Color MKcol( nRed, nGreen, nBlue) ; - return ( pGseCtx->m_pScene->SetMark( MKcol) ? TRUE : FALSE) ; + return ( pGseCtx->m_pScene->SetMark( MarkCol) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL -__stdcall EgtSetGeoLineAttribs( int nRed, int nGreen, int nBlue) +__stdcall EgtSetGeoLineAttribs( const int GlCol[4]) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // imposto il colore della linea geometrica gestita direttamente dalla scena - Color Glcol( nRed, nGreen, nBlue) ; - return ( pGseCtx->m_pScene->SetGeoLineAttribs( Glcol) ? TRUE : FALSE) ; + return EgtSetGeoLineAttribs( Color( GlCol)) ; } //----------------------------------------------------------------------------- BOOL -__stdcall EgtSetWinRectAttribs( BOOL bOutline, int nRed, int nGreen, int nBlue, int nAlpha) +__stdcall EgtSetGeoLineAttribs( Color GlCol) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_SCENE( pGseCtx, FALSE) // imposto il colore della linea geometrica gestita direttamente dalla scena - Color WRcol( nRed, nGreen, nBlue, nAlpha) ; - return ( pGseCtx->m_pScene->SetWinRectAttribs( ( bOutline != FALSE), WRcol) ? TRUE : FALSE) ; + return ( pGseCtx->m_pScene->SetGeoLineAttribs( GlCol) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetWinRectAttribs( BOOL bOutline, const int WrCol[4]) +{ + return EgtSetWinRectAttribs( bOutline, Color( WrCol)) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetWinRectAttribs( BOOL bOutline, Color WrCol) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_SCENE( pGseCtx, FALSE) + // imposto il colore della linea geometrica gestita direttamente dalla scena + return ( pGseCtx->m_pScene->SetWinRectAttribs( ( bOutline != FALSE), WrCol) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetGridShow( BOOL bShowGrid, BOOL bShowFrame) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_SCENE( pGseCtx, FALSE) + // imposto stato visualizzazione griglia + return ( pGseCtx->m_pScene->SetGridShow( ( bShowGrid != FALSE), ( bShowFrame != FALSE)) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetGridFrame( const double ptOrig[3], const double vX[3], const double vY[3], const double vZ[3]) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_SCENE( pGseCtx, FALSE) + // costruisco il riferimento + Frame3d frFrame ; + if ( ! frFrame.Set( ptOrig, vX, vY, vZ)) + return GDB_ID_NULL ; + // imposto il riferimento della griglia + return ( pGseCtx->m_pScene->SetGridFrame( frFrame) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetGridFrame( double ptOrig[3], double vX[3], double vY[3], double vZ[3]) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_SCENE( pGseCtx, FALSE) + // recupero il riferimento della griglia + const Frame3d& frGrid = pGseCtx->m_pScene->GetGridFrame() ; + // assegno i valori di ritorno + VEC_FROM_3D( ptOrig, frGrid.Orig()) + VEC_FROM_3D( vX, frGrid.VersX()) + VEC_FROM_3D( vY, frGrid.VersY()) + VEC_FROM_3D( vZ, frGrid.VersZ()) + return TRUE ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetGridGeo( double dSnapStep, int nMinLineSstep, int nMajLineSstep, int nExtSstep) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_SCENE( pGseCtx, FALSE) + // imposto i parametri geometrici di griglia + return ( pGseCtx->m_pScene->SetGridGeo( dSnapStep, nMinLineSstep, nMajLineSstep, nExtSstep) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetGridColor( const int nMinCol[4], const int nMajCol[4]) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_SCENE( pGseCtx, FALSE) + // imposto i colori di griglia + Color colMin( nMinCol) ; + Color colMaj( nMajCol) ; + return ( pGseCtx->m_pScene->SetGridColor( colMin, colMaj) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -188,18 +273,16 @@ __stdcall EgtUnselectableClearAll( void) //----------------------------------------------------------------------------- BOOL -__stdcall EgtGetSelectedSnapPoint( int nSnap, int nWinX, int nWinY, int nSelW, int nSelH, - double ptP[3]) +__stdcall EgtGetGraphicSnapPoint( int nSnap, int nWinX, int nWinY, int nSelW, int nSelH, + double ptP[3]) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_SCENE( pGseCtx, FALSE) // trovo il punto snap da selezione Point3d ptSnap ; - if ( ! pGseCtx->m_pScene->GetSelectedSnapPoint( nSnap, Point3d( nWinX, nWinY), nSelW, nSelH, ptSnap)) + if ( ! pGseCtx->m_pScene->GetGraphicSnapPoint( nSnap, Point3d( nWinX, nWinY), nSelW, nSelH, ptSnap)) return FALSE ; - ptP[0] = ptSnap.x ; - ptP[1] = ptSnap.y ; - ptP[2] = ptSnap.z ; + VEC_FROM_3D( ptP, ptSnap) return TRUE ; } @@ -458,9 +541,7 @@ __stdcall EgtUnProjectPoint( int nWinX, int nWinY, double ptP[3]) Point3d ptWorld ; if ( ! pScene->UnProject( ptView, ptWorld)) return FALSE ; - ptP[0] = ptWorld.x ; - ptP[1] = ptWorld.y ; - ptP[2] = ptWorld.z ; + VEC_FROM_3D( ptP, ptWorld) return TRUE ; } @@ -474,8 +555,6 @@ __stdcall EgtProjectPoint( const double ptP[3], double ptWin[3]) Point3d ptView ; if ( ! pScene->Project( ptP, ptView)) return FALSE ; - ptWin[0] = ptView.x ; - ptWin[1] = ptView.y ; - ptWin[2] = ptView.z ; + VEC_FROM_3D( ptWin, ptView) return TRUE ; } diff --git a/EgtInterface.rc b/EgtInterface.rc index 354b429..7fa45d8 100644 Binary files a/EgtInterface.rc and b/EgtInterface.rc differ diff --git a/EgtInterface.vcxproj b/EgtInterface.vcxproj index 1c99d1d..865d134 100644 --- a/EgtInterface.vcxproj +++ b/EgtInterface.vcxproj @@ -93,6 +93,8 @@ Disabled WIN32;I_AM_EIN;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) ProgramDatabase + true + false Windows @@ -115,6 +117,8 @@ copy $(TargetPath) \EgtProg\DllD32 Disabled WIN32;I_AM_EIN;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) false + true + false Windows @@ -141,6 +145,7 @@ copy $(TargetPath) \EgtProg\DllD64 WIN32;I_AM_EIN;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) Speed AnySuitable + true Windows @@ -168,6 +173,7 @@ copy $(TargetPath) \EgtProg\Dll32 Speed AnySuitable false + true Windows @@ -185,6 +191,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/EgtInterface.vcxproj.filters b/EgtInterface.vcxproj.filters index 33110cb..4913e58 100644 --- a/EgtInterface.vcxproj.filters +++ b/EgtInterface.vcxproj.filters @@ -39,6 +39,9 @@ File di intestazione + + File di intestazione + diff --git a/LUA_GdbObjAttribs.cpp b/LUA_GdbObjAttribs.cpp index cbdbd44..93b376e 100644 --- a/LUA_GdbObjAttribs.cpp +++ b/LUA_GdbObjAttribs.cpp @@ -318,9 +318,8 @@ LuaStdColor( lua_State* L) LuaCheckParam( L, 1, sName) LuaClearStack( L) ; // recupero il colore con il nome indicato - int nRed, nGreen, nBlue, nAlpha ; - if ( EgtStdColor( sName, nRed, nGreen, nBlue, nAlpha)) { - Color cCol( nRed, nGreen, nBlue, nAlpha) ; + Color cCol ; + if ( EgtStdColor( sName, cCol)) { // restituisco il risultato LuaSetReturn( L, cCol) ; } @@ -340,10 +339,11 @@ LuaSetColor( lua_State* L) LuaCheckParam( L, 2, cCol) LuaClearStack( L) ; // assegno il colore + int vCol[4] ; + cCol.GetInt( vCol) ; bool bOk = true ; for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) { - if ( ! EgtSetColor( vId[i], cCol.GetIntRed(), - cCol.GetIntGreen(), cCol.GetIntBlue(), cCol.GetIntAlpha())) + if ( ! EgtSetColor( vId[i], vCol)) bOk = false ; } // restituisco il risultato @@ -360,9 +360,9 @@ LuaGetColor( lua_State* L) LuaCheckParam( L, 1, nId) LuaClearStack( L) ; // recupero il colore - int nRed, nGreen, nBlue, nAlpha ; - if ( EgtGetColor( nId, nRed, nGreen, nBlue, nAlpha)) { - Color cCol( nRed, nGreen, nBlue, nAlpha) ; + int vCol[4] ; + if ( EgtGetColor( nId, vCol)) { + Color cCol( vCol) ; // restituisco il risultato LuaSetReturn( L, cCol) ; } @@ -380,9 +380,9 @@ LuaGetCalcColor( lua_State* L) LuaCheckParam( L, 1, nId) LuaClearStack( L) ; // recupero il colore - int nRed, nGreen, nBlue, nAlpha ; - if ( EgtGetCalcColor( nId, nRed, nGreen, nBlue, nAlpha)) { - Color cCol( nRed, nGreen, nBlue, nAlpha) ; + int vCol[4] ; + if ( EgtGetCalcColor( nId, vCol)) { + Color cCol( vCol) ; // restituisco il risultato LuaSetReturn( L, cCol) ; } diff --git a/LUA_GeomDB.cpp b/LUA_GeomDB.cpp index 4126bdf..e710519 100644 --- a/LUA_GeomDB.cpp +++ b/LUA_GeomDB.cpp @@ -32,7 +32,9 @@ LuaSetDefaultMaterial( lua_State* L) return luaL_error( L, "Invalide first parameter") ; LuaClearStack( L) ; // imposto il colore di default - bool bOk = ( EgtSetDefaultMaterial( colDef.GetIntRed(), colDef.GetIntGreen(), colDef.GetIntBlue()) != FALSE) ; + int vCol[4] ; + colDef.GetInt( vCol) ; + bool bOk = ( EgtSetDefaultMaterial( vCol) != FALSE) ; // restituisco il risultato LuaSetReturn( L, bOk) ; return 1 ; diff --git a/LUA_Scene.cpp b/LUA_Scene.cpp index 34bb234..cf2f163 100644 --- a/LUA_Scene.cpp +++ b/LUA_Scene.cpp @@ -35,8 +35,7 @@ LuaSetBackground( lua_State* L) LuaCheckParam( L, 3, bRedraw) LuaClearStack( L) ; // imposto lo sfondo - bool bOk = ( EgtSetBackground( colTop.GetIntRed(), colTop.GetIntGreen(), colTop.GetIntBlue(), - colBot.GetIntRed(), colBot.GetIntGreen(), colBot.GetIntBlue(), bRedraw) != FALSE) ; + bool bOk = ( EgtSetBackground( colTop, colBot, bRedraw) != FALSE) ; // restituisco il risultato LuaSetReturn( L, bOk) ; return 1 ;