From a19a8be2ccf3aa7ef4dfb99ab52af4a5ea37d83d Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 29 Oct 2018 07:35:46 +0000 Subject: [PATCH] EgtGeomKernel : - deselezione ora riporta allo stato precedente a selezione - a CurveComposite aggiunte Set/GetCurveTempProp . --- Attribs.h | 5 +++-- CurveComposite.cpp | 30 ++++++++++++++++++++++++++++++ CurveComposite.h | 2 ++ GeomDB.cpp | 12 ++++++++---- GeomDB.h | 2 +- 5 files changed, 44 insertions(+), 7 deletions(-) diff --git a/Attribs.h b/Attribs.h index 7df7fd8..7f332ae 100644 --- a/Attribs.h +++ b/Attribs.h @@ -59,10 +59,11 @@ class Attribs int GetMode( void) const { return m_Data[MODE] ; } void SetStatus( int nStat) - { m_OldData[STATUS] = m_Data[STATUS] ; + { if ( m_Data[STATUS] != GDB_ST_SEL) + m_OldData[STATUS] = m_Data[STATUS] ; m_Data[STATUS] = CLIP( nStat, GDB_ST_OFF, GDB_ST_SEL) ; } void RevertStatus( void) - { std::swap( m_Data[STATUS], m_OldData[STATUS]) ; } + { SetStatus( m_OldData[STATUS]) ; } int GetStatus( void) const { return m_Data[STATUS] ; } void SetMark( void) diff --git a/CurveComposite.cpp b/CurveComposite.cpp index 4e381fb..be1ac22 100644 --- a/CurveComposite.cpp +++ b/CurveComposite.cpp @@ -2879,3 +2879,33 @@ CurveComposite::IsACircle( double dLinTol, Point3d& ptCen, Vector3d& vtN, double return false ; return CrvTemp.IsOneCircle( ptCen, vtN, dRad, bCCW) ; } + +//---------------------------------------------------------------------------- +bool +CurveComposite::SetCurveTempProp( int nCrv, int nProp) +{ + // la curva deve essere validata + if ( m_nStatus != OK) + return false ; + // verifico che l'indice sia nei limiti + if ( nCrv < 0 || nCrv >= int( m_CrvSmplS.size())) + return false ; + // eseguo assegnazione + m_CrvSmplS[nCrv]->SetTempProp( nProp) ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +CurveComposite::GetCurveTempProp( int nCrv, int& nProp) const +{ + // la curva deve essere validata + if ( m_nStatus != OK) + return false ; + // verifico che l'indice sia nei limiti + if ( nCrv < 0 || nCrv >= int( m_CrvSmplS.size())) + return false ; + // eseguo recupero + nProp = m_CrvSmplS[nCrv]->GetTempProp() ; + return true ; +} diff --git a/CurveComposite.h b/CurveComposite.h index 856d485..7ad0026 100644 --- a/CurveComposite.h +++ b/CurveComposite.h @@ -153,6 +153,8 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW bool MergeCurves( double dLinTol, double dAngTolDeg, bool bStartEnd = true) override ; bool RemoveUndercutOnY( double dLinTol, double dAngTolDeg) override ; bool IsACircle( double dLinTol, Point3d& ptCen, Vector3d& vtN, double& dRad, bool& bCCW) const override ; + bool SetCurveTempProp( int nCrv, int nProp) override ; + bool GetCurveTempProp( int nCrv, int& nProp) const override ; public : // IGeoObjRW int GetNgeId( void) const override ; diff --git a/GeomDB.cpp b/GeomDB.cpp index a0f0a49..4e991c8 100644 --- a/GeomDB.cpp +++ b/GeomDB.cpp @@ -1709,7 +1709,7 @@ GeomDB::DeselectObj( int nId) // se selezionato, lo deseleziono if ( pGdbObj->IsSelected()) - return SetStatus( pGdbObj, GDB_ST_ON) ; + return RevertStatus( pGdbObj, false) ; // altrimenti, va già bene else return true ; @@ -1768,7 +1768,7 @@ GeomDB::DeselectGroupObjs( int nId) while ( pGdbObj != nullptr) { // se selezionato, lo deseleziono if ( pGdbObj->IsSelected()) { - if ( ! SetStatus( pGdbObj, GDB_ST_ON)) + if ( ! RevertStatus( pGdbObj, false)) return false ; } pGdbObj = pGdbObj->GetNext() ; @@ -1839,7 +1839,7 @@ GeomDB::ClearSelection( void) GdbObj* pGObj = m_SelManager.GetFirstObj() ; while ( pGObj != nullptr) { m_SelManager.RemoveObj( pGObj) ; - pGObj->SetStatus( GDB_ST_ON) ; + RevertStatus( pGObj, false) ; pGObj = m_SelManager.GetFirstObj() ; } @@ -2041,7 +2041,7 @@ GeomDB::RevertStatus( int nId) //---------------------------------------------------------------------------- bool -GeomDB::RevertStatus( GdbObj* pGdbObj) +GeomDB::RevertStatus( GdbObj* pGdbObj, bool bOkSel) { // verifico validità oggetto if ( pGdbObj == nullptr) @@ -2059,6 +2059,10 @@ GeomDB::RevertStatus( GdbObj* pGdbObj) int nStat = GDB_ST_ON ; pGdbObj->GetStatus( nStat) ; + // se inibito ritorno a selezionato e selezionato, imposto visibile + if ( ! bOkSel && nStat == GDB_ST_SEL) + pGdbObj->SetStatus( GDB_ST_ON) ; + // se lo stato è cambiato if ( nStat != nOldStat) { // se il nuovo stato è di selezionato, inserisco oggetto in lista selezionati diff --git a/GeomDB.h b/GeomDB.h index 13de0fd..d604144 100644 --- a/GeomDB.h +++ b/GeomDB.h @@ -239,7 +239,7 @@ class GeomDB : public IGeomDB bool SaveHeader( NgeWriter& ngeOut) const ; bool SaveFooter( NgeWriter& ngeOut) const ; bool SetStatus( GdbObj* pGdbObj, int nStat) ; - bool RevertStatus( GdbObj* pGdbObj) ; + bool RevertStatus( GdbObj* pGdbObj, bool bOkSel = true) ; bool SetMaterial( GdbObj* pGdbObj, int nMat) ; bool SetMaterial( GdbObj* pGdbObj, const std::string& sMatName) ; bool GetMaterial( const GdbObj* pGdbObj, Material& mMat) const ;