From 9f8e032d92ac2366efee367a847e44f49b9fe1c0 Mon Sep 17 00:00:00 2001 From: asl Date: Fri, 14 Apr 2017 11:34:47 +0300 Subject: [PATCH 01/11] refs #1211: crash in two polylines creation --- src/CurveCreator/CurveCreator_TreeView.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/CurveCreator/CurveCreator_TreeView.cxx b/src/CurveCreator/CurveCreator_TreeView.cxx index 6a8ecec53..89f2606c3 100644 --- a/src/CurveCreator/CurveCreator_TreeView.cxx +++ b/src/CurveCreator/CurveCreator_TreeView.cxx @@ -212,9 +212,13 @@ int CurveCreator_TreeViewModel::getPoint( const QModelIndex& theIndx ) const void CurveCreator_TreeViewModel::setCurve( CurveCreator_ICurve* theCurve ) { - myCurve = theCurve; #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + myCurve = theCurve; reset(); +#else + beginResetModel(); + myCurve = theCurve; + endResetModel(); #endif } From 81f3aca1cb8465936e7cf352d48948deebf48622 Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 21 Sep 2017 16:34:35 +0300 Subject: [PATCH 02/11] refs #1331: sorting of profiles points by column --- src/CurveCreator/CurveCreator_TableView.cxx | 14 ++++++++++++-- src/CurveCreator/CurveCreator_TableView.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/CurveCreator/CurveCreator_TableView.cxx b/src/CurveCreator/CurveCreator_TableView.cxx index bda45103e..6cd0b35ae 100644 --- a/src/CurveCreator/CurveCreator_TableView.cxx +++ b/src/CurveCreator/CurveCreator_TableView.cxx @@ -94,10 +94,13 @@ void CurveCreator_TableItemDelegate::setModelData( QWidget* theEditor, QItemDelegate::setModelData( theEditor, theModel, theIndex ); } + + + CurveCreator_TableView::CurveCreator_TableView( CurveCreator_ICurve* theCurve, QWidget* theParent, const QStringList& theCoordTitles ) -: QTableWidget( theParent ), myCurve( theCurve ) + : QTableWidget( theParent ), myCurve( theCurve ), myCurrentSortId( -1 ), myCurrentSortOrder( Qt::AscendingOrder ) { setItemDelegate( new CurveCreator_TableItemDelegate( this ) ); setVisible( false ); @@ -199,5 +202,12 @@ int CurveCreator_TableView::getPointId( const int theRowId ) const void CurveCreator_TableView::OnHeaderClick( int theLogicalId ) { - sortByColumn( theLogicalId, Qt::AscendingOrder ); + if( theLogicalId == myCurrentSortId ) + if( myCurrentSortOrder == Qt::AscendingOrder ) + myCurrentSortOrder = Qt::DescendingOrder; + else + myCurrentSortOrder = Qt::AscendingOrder; + + sortByColumn( theLogicalId, myCurrentSortOrder ); + myCurrentSortId = theLogicalId; } diff --git a/src/CurveCreator/CurveCreator_TableView.h b/src/CurveCreator/CurveCreator_TableView.h index bfc0e9b69..67d813c17 100644 --- a/src/CurveCreator/CurveCreator_TableView.h +++ b/src/CurveCreator/CurveCreator_TableView.h @@ -69,6 +69,8 @@ private slots: private: CurveCreator_ICurve* myCurve; + int myCurrentSortId; + Qt::SortOrder myCurrentSortOrder; }; #endif // CURVECREATOR_TABLEVIEW_H From 28c4349bd99a8875631511b725a20ade0f42475e Mon Sep 17 00:00:00 2001 From: asl Date: Fri, 22 Sep 2017 09:19:37 +0300 Subject: [PATCH 03/11] refs #1331: disabling automatic sorting of points in the GUI table --- src/CurveCreator/CurveCreator_Curve.cxx | 10 ++++-- src/CurveCreator/CurveCreator_Curve.hxx | 4 ++- src/CurveCreator/CurveCreator_Diff.cxx | 4 +-- src/CurveCreator/CurveCreator_ICurve.hxx | 5 ++- src/CurveCreator/CurveCreator_Section.cxx | 11 ++++--- src/CurveCreator/CurveCreator_Section.hxx | 4 +-- src/CurveCreator/CurveCreator_Utils.cxx | 38 +++++++++++------------ src/EntityGUI/EntityGUI_PolylineDlg.cxx | 2 +- 8 files changed, 43 insertions(+), 35 deletions(-) diff --git a/src/CurveCreator/CurveCreator_Curve.cxx b/src/CurveCreator/CurveCreator_Curve.cxx index e307e8160..fb85db9d8 100644 --- a/src/CurveCreator/CurveCreator_Curve.cxx +++ b/src/CurveCreator/CurveCreator_Curve.cxx @@ -971,11 +971,17 @@ CurveCreator::Coordinates CurveCreator_Curve::getPoint( const int theISection, // function: getPoints // purpose: //======================================================================= -CurveCreator::Coordinates CurveCreator_Curve::getPoints( const int theISection ) const +CurveCreator::Coordinates CurveCreator_Curve::getCoords( int theISection ) const +{ + CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection ); + return aSection ? aSection->myPoints : CurveCreator::Coordinates(); +} + +Handle(TColgp_HArray1OfPnt) CurveCreator_Curve::GetDifferentPoints( int theISection ) const { //DEBTRACE("getPoints"); CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection ); - return aSection ? aSection->myPoints : CurveCreator::Coordinates(); + return aSection ? aSection->GetDifferentPoints( (int)myDimension ) : Handle(TColgp_HArray1OfPnt)(); } void CurveCreator_Curve::constructAISObject() diff --git a/src/CurveCreator/CurveCreator_Curve.hxx b/src/CurveCreator/CurveCreator_Curve.hxx index 74667f4f0..5763d1fff 100644 --- a/src/CurveCreator/CurveCreator_Curve.hxx +++ b/src/CurveCreator/CurveCreator_Curve.hxx @@ -261,7 +261,9 @@ public: /** * Get points of a section (the total points in Curve if theISection is equal to -1).. */ - virtual CurveCreator::Coordinates getPoints( const int theISection = -1 ) const; + virtual Handle(TColgp_HArray1OfPnt) GetDifferentPoints( int theISection = -1 ) const; + + CurveCreator::Coordinates getCoords( int theISection = -1 ) const; /** diff --git a/src/CurveCreator/CurveCreator_Diff.cxx b/src/CurveCreator/CurveCreator_Diff.cxx index a9f08d302..c4e1f9212 100644 --- a/src/CurveCreator/CurveCreator_Diff.cxx +++ b/src/CurveCreator/CurveCreator_Diff.cxx @@ -336,7 +336,7 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve, aSectionId = anIt->first; aPointId = anIt->second; const CurveCreator::Coordinates &aPoints = - theCurve->getPoints(aSectionId); + theCurve->getCoords(aSectionId); CurveCreator::Coordinates::const_iterator anIterBegin = aPoints.begin() + (aDim*aPointId); CurveCreator::Coordinates::const_iterator anIterEnd = @@ -526,7 +526,7 @@ bool CurveCreator_Diff::addSectionToUndo CurveCreator_Operation &theOperation) const { const std::string aName = theCurve->getSectionName(theIndex); - const CurveCreator::Coordinates &aPnts = theCurve->getPoints(theIndex); + const CurveCreator::Coordinates &aPnts = theCurve->getCoords(theIndex); const CurveCreator::SectionType aType = theCurve->getSectionType(theIndex); const bool isClosed = theCurve->isClosed(theIndex); diff --git a/src/CurveCreator/CurveCreator_ICurve.hxx b/src/CurveCreator/CurveCreator_ICurve.hxx index 150e37d2e..d1a2e48bc 100644 --- a/src/CurveCreator/CurveCreator_ICurve.hxx +++ b/src/CurveCreator/CurveCreator_ICurve.hxx @@ -59,8 +59,7 @@ struct CURVECREATOR_EXPORT CurveCreator_ISection virtual ~CurveCreator_ISection() {} //! Calculates the different points of the section. - virtual void GetDifferentPoints( - const int theDimension, Handle(TColgp_HArray1OfPnt)& thePoints) const = 0; + virtual Handle(TColgp_HArray1OfPnt) GetDifferentPoints( int theDimension ) const = 0; }; /** @@ -192,7 +191,7 @@ public: /** * Get points of a section (the total points in Curve if theISection is equal to -1).. */ - virtual CurveCreator::Coordinates getPoints( const int theISection = -1 ) const = 0; + virtual Handle(TColgp_HArray1OfPnt) GetDifferentPoints( int theISection = -1 ) const = 0; /** * Get number of points in specified section or (the total number of points diff --git a/src/CurveCreator/CurveCreator_Section.cxx b/src/CurveCreator/CurveCreator_Section.cxx index e2298c092..2b9beda57 100644 --- a/src/CurveCreator/CurveCreator_Section.cxx +++ b/src/CurveCreator/CurveCreator_Section.cxx @@ -30,9 +30,10 @@ const double POINT_CONFUSION = 1e-4; // function: GetDifferentPoints // purpose: //======================================================================= -void CurveCreator_Section::GetDifferentPoints( - const int theDimension, Handle(TColgp_HArray1OfPnt)& thePoints) const +Handle(TColgp_HArray1OfPnt) CurveCreator_Section::GetDifferentPoints( int theDimension ) const { + Handle(TColgp_HArray1OfPnt) points; + std::vector aTmpPoints; CurveCreator::Coordinates::const_iterator aPIt = myPoints.begin(); CurveCreator::Coordinates::const_iterator aPItLast = myPoints.end(); @@ -62,9 +63,11 @@ void CurveCreator_Section::GetDifferentPoints( } } - thePoints = new TColgp_HArray1OfPnt(1, aPointCount); + points = new TColgp_HArray1OfPnt(1, aPointCount); for (int aPI = 0; aPI < aPointCount; ++aPI) { - thePoints->SetValue(aPI + 1, aTmpPoints[aPI]); + points->SetValue(aPI + 1, aTmpPoints[aPI]); } + + return points; } diff --git a/src/CurveCreator/CurveCreator_Section.hxx b/src/CurveCreator/CurveCreator_Section.hxx index 9ad98048a..07b1bc973 100644 --- a/src/CurveCreator/CurveCreator_Section.hxx +++ b/src/CurveCreator/CurveCreator_Section.hxx @@ -36,13 +36,13 @@ struct CURVECREATOR_EXPORT CurveCreator_Section : CurveCreator_Section() : myName("Section"),myType(CurveCreator::Polyline), myIsClosed(false) { } - std::string myName; //!< section name + std::string myName; //!< section name CurveCreator::Coordinates myPoints; //!< points coordinates CurveCreator::SectionType myType; //!< type of the section bool myIsClosed; //!< closed or not //! A virtual method. - void GetDifferentPoints(const int theDimension, Handle(TColgp_HArray1OfPnt)& thePoints) const; + Handle(TColgp_HArray1OfPnt) GetDifferentPoints( int theDimension ) const; }; #endif diff --git a/src/CurveCreator/CurveCreator_Utils.cxx b/src/CurveCreator/CurveCreator_Utils.cxx index 5f53caea4..20b16f4c4 100644 --- a/src/CurveCreator/CurveCreator_Utils.cxx +++ b/src/CurveCreator/CurveCreator_Utils.cxx @@ -311,9 +311,7 @@ void CurveCreator_Utils::constructShape( } // Get the different points. - const CurveCreator_ISection* aSection = theCurve->getSection(aSectionI); - Handle(TColgp_HArray1OfPnt) aPoints; - aSection->GetDifferentPoints(theCurve->getDimension(), aPoints); + Handle(TColgp_HArray1OfPnt) aPoints = theCurve->GetDifferentPoints( aSectionI ); const int aPointCount = aPoints->Length(); const bool isClosed = theCurve->isClosed(aSectionI); @@ -619,28 +617,28 @@ void CurveCreator_Utils::setSelectedPoints( Handle(AIS_InteractiveContext) theCo theContext->SetAutomaticHilight( Standard_False ); Handle(SelectMgr_Selection) aSelection = anAISShape->Selection( AIS_Shape::SelectionMode( TopAbs_VERTEX ) ); - for( aSelection->Init(); aSelection->More(); aSelection->Next() ) - { + + CurveCreator_ICurve::SectionToPointList::const_iterator anIt = thePoints.begin(), + aLast = thePoints.end(); + bool isFound = false; + for( int i=0; iInit(); aSelection->More(); aSelection->Next() ) + { #if OCC_VERSION_LARGE > 0x06080100 - const Handle(SelectMgr_SensitiveEntity) aHSenEntity = aSelection->Sensitive(); - if( aHSenEntity.IsNull() ) - continue; - Handle(SelectBasics_SensitiveEntity) aSenEntity = aHSenEntity->BaseSensitive(); + const Handle(SelectMgr_SensitiveEntity) aHSenEntity = aSelection->Sensitive(); + if( aHSenEntity.IsNull() ) + continue; + Handle(SelectBasics_SensitiveEntity) aSenEntity = aHSenEntity->BaseSensitive(); #else - Handle(SelectBasics_SensitiveEntity) aSenEntity = aSelection->Sensitive(); + Handle(SelectBasics_SensitiveEntity) aSenEntity = aSelection->Sensitive(); #endif - Handle(Select3D_SensitivePoint) aSenPnt = Handle(Select3D_SensitivePoint)::DownCast( aSenEntity ); + Handle(Select3D_SensitivePoint) aSenPnt = Handle(Select3D_SensitivePoint)::DownCast( aSenEntity ); + + gp_Pnt anOwnerPnt = aSenPnt->Point(); + Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast( aSenPnt->OwnerId() ); - gp_Pnt anOwnerPnt = aSenPnt->Point(); - Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast( aSenPnt->OwnerId() ); - - - CurveCreator_ICurve::SectionToPointList::const_iterator anIt = thePoints.begin(), - aLast = thePoints.end(); - bool isFound = false; - for( int i=0; igetPoints(i); + CurveCreator::Coordinates aCoords = myCurve->getCoords(i); const int aNbPoints = aCoords.size(); theCoords[i].length(aNbPoints); From e7c4b29a9ed55a5e32f69885cd1b4ceaa0414100 Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 28 Sep 2017 10:26:37 +0300 Subject: [PATCH 04/11] refs #1331: profiles points sorting --- src/CurveCreator/CurveCreator_TableView.cxx | 16 ++++++++++++++-- src/CurveCreator/CurveCreator_TableView.h | 5 ++++- src/CurveCreator/CurveCreator_Widget.h | 5 +++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/CurveCreator/CurveCreator_TableView.cxx b/src/CurveCreator/CurveCreator_TableView.cxx index 6cd0b35ae..a6d819dcd 100644 --- a/src/CurveCreator/CurveCreator_TableView.cxx +++ b/src/CurveCreator/CurveCreator_TableView.cxx @@ -19,6 +19,7 @@ #include "CurveCreator_TableView.h" #include "CurveCreator_UtilsICurve.hxx" +#include "CurveCreator_Widget.h" #include @@ -98,9 +99,10 @@ void CurveCreator_TableItemDelegate::setModelData( QWidget* theEditor, CurveCreator_TableView::CurveCreator_TableView( CurveCreator_ICurve* theCurve, - QWidget* theParent, + CurveCreator_Widget* theParent, const QStringList& theCoordTitles ) - : QTableWidget( theParent ), myCurve( theCurve ), myCurrentSortId( -1 ), myCurrentSortOrder( Qt::AscendingOrder ) + : QTableWidget( theParent ), myWidget( theParent ), + myCurve( theCurve ), myCurrentSortId( -1 ), myCurrentSortOrder( Qt::AscendingOrder ) { setItemDelegate( new CurveCreator_TableItemDelegate( this ) ); setVisible( false ); @@ -209,5 +211,15 @@ void CurveCreator_TableView::OnHeaderClick( int theLogicalId ) myCurrentSortOrder = Qt::AscendingOrder; sortByColumn( theLogicalId, myCurrentSortOrder ); + + CurveCreator_ICurve::SectionToPointList selected; + for( int r=0, n=rowCount(); rdata( Qt::UserRole ).toInt(); + int point = item( r, 1 )->data( Qt::UserRole ).toInt(); + selected.push_back( CurveCreator_ICurve::SectionToPoint( section, point ) ); + } + myWidget->setSelectedPoints( selected ); + myCurrentSortId = theLogicalId; } diff --git a/src/CurveCreator/CurveCreator_TableView.h b/src/CurveCreator/CurveCreator_TableView.h index 67d813c17..c293e8344 100644 --- a/src/CurveCreator/CurveCreator_TableView.h +++ b/src/CurveCreator/CurveCreator_TableView.h @@ -25,6 +25,8 @@ #include #include +class CurveCreator_Widget; + class CurveCreator_TableItemDelegate : public QItemDelegate { public: @@ -44,7 +46,7 @@ class CurveCreator_TableView : public QTableWidget Q_OBJECT public: - CurveCreator_TableView( CurveCreator_ICurve* theCurve, QWidget* theParent = 0, + CurveCreator_TableView( CurveCreator_ICurve* theCurve, CurveCreator_Widget* theParent, const QStringList& theCoordTitles = QStringList() ); ~CurveCreator_TableView() {}; @@ -67,6 +69,7 @@ private slots: void OnHeaderClick( int ); private: + CurveCreator_Widget* myWidget; CurveCreator_ICurve* myCurve; int myCurrentSortId; diff --git a/src/CurveCreator/CurveCreator_Widget.h b/src/CurveCreator/CurveCreator_Widget.h index da38404a6..bcde2f6d6 100644 --- a/src/CurveCreator/CurveCreator_Widget.h +++ b/src/CurveCreator/CurveCreator_Widget.h @@ -95,6 +95,9 @@ public: void SetViewer2DMode(const bool To2D); + void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& = + CurveCreator_ICurve::SectionToPointList() ); + signals: void selectionChanged(); void subOperationStarted( QWidget*, bool ); @@ -185,8 +188,6 @@ private: void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() ); void getSelectedPoints( CurveCreator_ICurve::SectionToPointList& thePoints ); - void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& = - CurveCreator_ICurve::SectionToPointList() ); void stopActionMode(); From 19eba9530f4f08c00db5926394f7c64808d83660 Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 28 Sep 2017 11:48:12 +0300 Subject: [PATCH 05/11] refs #1331: access to methods for testing purposes --- src/CurveCreator/CurveCreator_Widget.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/CurveCreator/CurveCreator_Widget.h b/src/CurveCreator/CurveCreator_Widget.h index bcde2f6d6..d72d842e8 100644 --- a/src/CurveCreator/CurveCreator_Widget.h +++ b/src/CurveCreator/CurveCreator_Widget.h @@ -98,14 +98,15 @@ public: void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& = CurveCreator_ICurve::SectionToPointList() ); + void updateLocalPointView(); + void setLocalPointContext( const bool theOpen, const bool isUpdateTable = false ); + signals: void selectionChanged(); void subOperationStarted( QWidget*, bool ); void subOperationFinished( QWidget* ); public slots: - -protected slots: void onAdditionMode(bool checked); void onModificationMode(bool checked); void onDetectionMode(bool checked); @@ -165,13 +166,15 @@ protected: BRING_TOGETHER_ID }; +public: + QAction* getAction(ActionId theId); + QAction* getAction(ActionMode theMode); + private: OCCViewer_Viewer* getOCCViewer(); QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage, const QString& theToolTip, const QKeySequence& theShortcut ); - QAction* getAction(ActionId theId); - QAction* getAction(ActionMode theMode); void updateActionsStates(); void updateUndoRedo(); @@ -182,8 +185,6 @@ private: void insertPointToSelectedSegment( const int theXPosition, const int theYPosition ); void moveSelectedPoints( const int theXPosition, const int theYPosition ); - void updateLocalPointView(); - void setLocalPointContext( const bool theOpen, const bool isUpdateTable = false ); void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() ); From 19d83677d431387614608739217818faebd329c4 Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 28 Sep 2017 11:57:31 +0300 Subject: [PATCH 06/11] refs #1331: access to methods for testing purposes --- src/CurveCreator/CurveCreator_TableView.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CurveCreator/CurveCreator_TableView.h b/src/CurveCreator/CurveCreator_TableView.h index c293e8344..16db23856 100644 --- a/src/CurveCreator/CurveCreator_TableView.h +++ b/src/CurveCreator/CurveCreator_TableView.h @@ -41,7 +41,7 @@ public: const QModelIndex& theIndex ) const; }; -class CurveCreator_TableView : public QTableWidget +class CURVECREATOR_EXPORT CurveCreator_TableView : public QTableWidget { Q_OBJECT @@ -65,7 +65,7 @@ public: */ int getPointId( const int theRowId ) const; -private slots: +public slots: void OnHeaderClick( int ); private: From ed9a2d484b95a3b016133cf12d31e806f489d227 Mon Sep 17 00:00:00 2001 From: isn Date: Wed, 18 Oct 2017 20:24:10 +0300 Subject: [PATCH 07/11] HYDRO / refs #1334 --- src/CurveCreator/CurveCreator_Curve.cxx | 47 ++++++++++++--------- src/CurveCreator/CurveCreator_Curve.hxx | 8 +++- src/CurveCreator/CurveCreator_Displayer.cxx | 19 ++++++++- src/CurveCreator/CurveCreator_Displayer.hxx | 2 + 4 files changed, 52 insertions(+), 24 deletions(-) diff --git a/src/CurveCreator/CurveCreator_Curve.cxx b/src/CurveCreator/CurveCreator_Curve.cxx index fb85db9d8..a2add5ddb 100644 --- a/src/CurveCreator/CurveCreator_Curve.cxx +++ b/src/CurveCreator/CurveCreator_Curve.cxx @@ -56,7 +56,10 @@ CurveCreator_Curve::CurveCreator_Curve( const CurveCreator::Dimension theDimensi myNbRedos (0), myUndoDepth (-1), myOpLevel(0), - mySkipSorting(false) + mySkipSorting(false), + myPointAspectColor (Quantity_NOC_ROYALBLUE4), + myCurveColor (Quantity_NOC_RED), + myLineWidth(1) { } @@ -249,13 +252,16 @@ void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double& } } -void CurveCreator_Curve::redisplayCurve() +void CurveCreator_Curve::redisplayCurve(bool preEraseAllObjects) { //DEBTRACE("redisplayCurve"); - if( myDisplayer ) { - myDisplayer->eraseAll( false ); + if( myDisplayer ) + { + if (preEraseAllObjects) + myDisplayer->eraseAll( false ); + else + myDisplayer->erase( myAISShape, false); myAISShape = NULL; - myDisplayer->display( getAISObject( true ), true ); } } @@ -422,7 +428,7 @@ bool CurveCreator_Curve::joinInternal( const std::list& theSections ) break; } - redisplayCurve(); + redisplayCurve(false); return res; } @@ -465,7 +471,7 @@ int CurveCreator_Curve::addSectionInternal aSection->myIsClosed = theIsClosed; aSection->myPoints = thePoints; mySections.push_back(aSection); - redisplayCurve(); + redisplayCurve(false); return mySections.size()-1; } @@ -525,7 +531,7 @@ bool CurveCreator_Curve::removeSectionInternal( const int theISection ) delete *anIterRm; mySections.erase(anIterRm); } - redisplayCurve(); + redisplayCurve(false); return true; } @@ -616,14 +622,14 @@ bool CurveCreator_Curve::setClosedInternal( const int theISection, aSection = (CurveCreator_Section*)getSection( i ); if( aSection ) { aSection->myIsClosed = theIsClosed; - redisplayCurve(); + redisplayCurve(false); } } } else { aSection = (CurveCreator_Section*)getSection( theISection ); if ( aSection ) { aSection->myIsClosed = theIsClosed; - redisplayCurve(); + redisplayCurve(false); } } return true; @@ -706,12 +712,12 @@ bool CurveCreator_Curve::setSectionTypeInternal( const int theISection, if ( aSection ) aSection->myType = theType; } - redisplayCurve(); + redisplayCurve(false); } else { aSection = (CurveCreator_Section*)getSection( theISection ); if ( aSection && aSection->myType != theType ){ aSection->myType = theType; - redisplayCurve(); + redisplayCurve(false); } } return true; @@ -772,7 +778,7 @@ bool CurveCreator_Curve::addPointsInternal( const CurveCreator::SectionsMap &the } } if(res) - redisplayCurve(); + redisplayCurve(false); return res; } @@ -830,7 +836,7 @@ bool CurveCreator_Curve::setPointInternal( const CurveCreator::SectionsMap &theS } } if(res) - redisplayCurve(); + redisplayCurve(false); return res; } @@ -914,7 +920,7 @@ bool CurveCreator_Curve::removePointsInternal( const SectionToPointList &thePoin aRes = removeSectionPoints(aSectionId, anIt->second); } if( aRes) - redisplayCurve(); + redisplayCurve(false); return aRes; } @@ -989,20 +995,21 @@ void CurveCreator_Curve::constructAISObject() //DEBTRACE("constructAISObject"); TopoDS_Shape aShape; CurveCreator_Utils::constructShape( this, aShape ); - - myAISShape = new AIS_Shape( aShape ); + myAISShape = new AIS_Shape( aShape ); + myAISShape->SetColor( myCurveColor ); + myAISShape->SetWidth( myLineWidth ); Handle(Prs3d_PointAspect) anAspect = myAISShape->Attributes()->PointAspect(); anAspect->SetScale( 3.0 ); anAspect->SetTypeOfMarker(Aspect_TOM_O_POINT); - anAspect->SetColor(Quantity_NOC_ROYALBLUE4); + anAspect->SetColor(myPointAspectColor); myAISShape->Attributes()->SetPointAspect( anAspect ); - } Handle(AIS_InteractiveObject) CurveCreator_Curve::getAISObject( const bool theNeedToBuild ) const { //DEBTRACE("getAISObject"); - if ( !myAISShape && theNeedToBuild ) { + if ( !myAISShape && theNeedToBuild ) + { CurveCreator_Curve* aCurve = (CurveCreator_Curve*)this; aCurve->constructAISObject(); } diff --git a/src/CurveCreator/CurveCreator_Curve.hxx b/src/CurveCreator/CurveCreator_Curve.hxx index 5763d1fff..7a4cbb9ec 100644 --- a/src/CurveCreator/CurveCreator_Curve.hxx +++ b/src/CurveCreator/CurveCreator_Curve.hxx @@ -36,6 +36,7 @@ struct CurveCreator_Section; class CurveCreator_Displayer; class AIS_Shape; class AIS_InteractiveObject; +class Quantity_Color; /** * The CurveCreator_Curve object is represented as one or more sets of @@ -108,7 +109,7 @@ protected: public: // TODO: remove public void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const; protected: // TODO: remove public - void redisplayCurve(); + void redisplayCurve(bool preEraseAllObjects = true); public: /************ Implementation of INTERFACE methods ************/ @@ -294,7 +295,7 @@ public: /** * Get the curve AIS object */ - virtual Handle(AIS_InteractiveObject) getAISObject( const bool theNeedToBuild = false ) const; + virtual Handle(AIS_InteractiveObject) getAISObject( const bool theNeedToBuild = false) const; protected: /** @@ -324,6 +325,9 @@ public: CurveCreator::Sections mySections; //!< curve data CurveCreator::Dimension myDimension; //!< curve dimension CurveCreator_Displayer* myDisplayer; //!< curve displayer + Quantity_Color myPointAspectColor; + Quantity_Color myCurveColor; + double myLineWidth; private: diff --git a/src/CurveCreator/CurveCreator_Displayer.cxx b/src/CurveCreator/CurveCreator_Displayer.cxx index 61285c962..4ac2e0450 100644 --- a/src/CurveCreator/CurveCreator_Displayer.cxx +++ b/src/CurveCreator/CurveCreator_Displayer.cxx @@ -54,14 +54,22 @@ void CurveCreator_Displayer::eraseAll( bool isUpdate ) { if(myObjects.empty()) return; - for( int i = 0 ; i < myObjects.size() ; i++ ){ + for( int i = 0 ; i < myObjects.size() ; i++ ) myContext->Erase(myObjects[i], Standard_False); - } myObjects.clear(); if( isUpdate ) myContext->UpdateCurrentViewer(); } +void CurveCreator_Displayer::erase( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate ) +{ + if(theObject.IsNull()) + return; + myContext->Erase(theObject, Standard_False); + if( isUpdate ) + myContext->UpdateCurrentViewer(); +} + Quantity_Color CurveCreator_Displayer::getActiveColor( bool isHL ) { if( isHL ){ @@ -70,6 +78,13 @@ Quantity_Color CurveCreator_Displayer::getActiveColor( bool isHL ) return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB ); } +void CurveCreator_Displayer::Update() +{ + for( int i = 0 ; i < myObjects.size() ; i++ ) + myContext->Update(myObjects[i], Standard_True); + myContext->UpdateCurrentViewer(); +} + /*void CurveCreator_Displayer::highlight( const AISObjectsList& theObjects, bool isHL ) { return; diff --git a/src/CurveCreator/CurveCreator_Displayer.hxx b/src/CurveCreator/CurveCreator_Displayer.hxx index d78b2a2f2..9528c8616 100644 --- a/src/CurveCreator/CurveCreator_Displayer.hxx +++ b/src/CurveCreator/CurveCreator_Displayer.hxx @@ -38,6 +38,8 @@ public: void display( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate ); void eraseAll( bool isUpdate ); + void erase( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate ); + void Update(); //void highlight( const AISObjectsList& theObjects, bool isHL ); protected: From 190ad709e40fe26daaecb81dcd1b875a2d235b17 Mon Sep 17 00:00:00 2001 From: isn Date: Wed, 8 Nov 2017 15:12:27 +0300 Subject: [PATCH 08/11] refs #1373 comment out the limit of selected points in the local-point-list --- src/CurveCreator/CurveCreator_Widget.cxx | 19 +++++++++---------- src/CurveCreator/CurveCreator_Widget.h | 3 +-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/CurveCreator/CurveCreator_Widget.cxx b/src/CurveCreator/CurveCreator_Widget.cxx index 1906c758d..5d000b1f8 100644 --- a/src/CurveCreator/CurveCreator_Widget.cxx +++ b/src/CurveCreator/CurveCreator_Widget.cxx @@ -80,11 +80,10 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent, CurveCreator_ICurve *theCurve, const int theActionFlags, const QStringList& theCoordTitles, - Qt::WindowFlags fl, - int theLocalPointRowLimit ) + Qt::WindowFlags fl ) : QWidget(parent), myNewSectionEditor(NULL), myCurve(theCurve), mySection(0), myDragStarted( false ), myDragInteractionStyle( SUIT_ViewModel::STANDARD ), - myOCCViewer( 0 ), myLocalPointRowLimit( theLocalPointRowLimit ), + myOCCViewer( 0 ), myOld2DMode(OCCViewer_ViewWindow::No2dMode) { bool isToEnableClosed = !( theActionFlags & DisableClosedSection ); @@ -1460,16 +1459,16 @@ void CurveCreator_Widget::updateLocalPointView() CurveCreator_Utils::getSelectedPoints( aContext, myCurve, myLocalPoints ); int aNbPoints = myLocalPoints.size(); - bool isRowLimit = aNbPoints > myLocalPointRowLimit; - myLocalPointView->setVisible( getActionMode() == ModificationMode && !isRowLimit ); + //bool isRowLimit = aNbPoints > myLocalPointRowLimit; + myLocalPointView->setVisible( getActionMode() == ModificationMode/* && !isRowLimit */); - if ( !isRowLimit ) { - bool isBlocked = myLocalPointView->blockSignals(true); + //if ( !isRowLimit ) { + bool isBlocked = myLocalPointView->blockSignals(true); - myLocalPointView->setLocalPointsToTable( myLocalPoints ); + myLocalPointView->setLocalPointsToTable( myLocalPoints ); - myLocalPointView->blockSignals( isBlocked ); - } + myLocalPointView->blockSignals( isBlocked ); + //} } /** diff --git a/src/CurveCreator/CurveCreator_Widget.h b/src/CurveCreator/CurveCreator_Widget.h index d72d842e8..e91e50249 100644 --- a/src/CurveCreator/CurveCreator_Widget.h +++ b/src/CurveCreator/CurveCreator_Widget.h @@ -71,8 +71,7 @@ public: CurveCreator_ICurve *theCurve, const int theActionFlags = NoFlags, const QStringList& theCoordTitles = QStringList(), - Qt::WindowFlags fl=0, - int theLocalPointRowLimit = 20); + Qt::WindowFlags fl=0); // OCC viewer manipulation void setOCCViewer( OCCViewer_Viewer* theViewer ); From 412e3db8f2d6967b5cb1d1c4d5ef1c3dc18a3353 Mon Sep 17 00:00:00 2001 From: isn Date: Wed, 8 Nov 2017 15:14:12 +0300 Subject: [PATCH 09/11] additional erase-all flag in CurveCreator_Curve --- src/CurveCreator/CurveCreator_Curve.cxx | 26 +++++++++++++++++++++++-- src/CurveCreator/CurveCreator_Curve.hxx | 9 +++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/CurveCreator/CurveCreator_Curve.cxx b/src/CurveCreator/CurveCreator_Curve.cxx index a2add5ddb..35843c83a 100644 --- a/src/CurveCreator/CurveCreator_Curve.cxx +++ b/src/CurveCreator/CurveCreator_Curve.cxx @@ -59,6 +59,7 @@ CurveCreator_Curve::CurveCreator_Curve( const CurveCreator::Dimension theDimensi mySkipSorting(false), myPointAspectColor (Quantity_NOC_ROYALBLUE4), myCurveColor (Quantity_NOC_RED), + myEraseAll(true), myLineWidth(1) { } @@ -363,8 +364,12 @@ bool CurveCreator_Curve::redo() bool CurveCreator_Curve::clearInternal() { // erase curve from the viewer - if( myDisplayer ) { - myDisplayer->eraseAll( true ); + if( myDisplayer ) + { + if (myEraseAll) + myDisplayer->eraseAll( true ); + else + myDisplayer->erase(myAISShape, false); myAISShape = NULL; } // Delete all allocated data. @@ -400,6 +405,23 @@ bool CurveCreator_Curve::clear() return res; } +//======================================================================= +// function: clear +// purpose: +//======================================================================= +void CurveCreator_Curve::SetEraseAllState(bool toEraseAll) +{ + myEraseAll = toEraseAll; +} +//======================================================================= +// function: clear +// purpose: +//======================================================================= +bool CurveCreator_Curve::GetEraseAllState() const +{ + return myEraseAll; +} + //! For internal use only! Undo/Redo are not used here. bool CurveCreator_Curve::joinInternal( const std::list& theSections ) { diff --git a/src/CurveCreator/CurveCreator_Curve.hxx b/src/CurveCreator/CurveCreator_Curve.hxx index 7a4cbb9ec..08239f4e7 100644 --- a/src/CurveCreator/CurveCreator_Curve.hxx +++ b/src/CurveCreator/CurveCreator_Curve.hxx @@ -140,6 +140,14 @@ public: //! Clear the polyline (remove all sections) virtual bool clear(); + //! set erase-all state + //! if true => erase all objects from viever, else remove only the current curve + void SetEraseAllState(bool toEraseAll); + + //! get erase-all state + //! if true => erase all objects from viever, else remove only the current curve + bool GetEraseAllState() const; + //! For internal use only! Undo/Redo are not used here. virtual bool joinInternal( const std::list& theSections ); @@ -338,6 +346,7 @@ private: int myUndoDepth; int myOpLevel; AIS_Shape* myAISShape; //!< AIS shape + bool myEraseAll; }; #endif From 6dc51244491d9a127b22f2af96786b12190304af Mon Sep 17 00:00:00 2001 From: asl Date: Fri, 10 Nov 2017 13:21:34 +0300 Subject: [PATCH 10/11] patch for crash --- src/CurveCreator/CurveCreator_Section.cxx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/CurveCreator/CurveCreator_Section.cxx b/src/CurveCreator/CurveCreator_Section.cxx index 2b9beda57..0052bcbec 100644 --- a/src/CurveCreator/CurveCreator_Section.cxx +++ b/src/CurveCreator/CurveCreator_Section.cxx @@ -35,12 +35,16 @@ Handle(TColgp_HArray1OfPnt) CurveCreator_Section::GetDifferentPoints( int theDim Handle(TColgp_HArray1OfPnt) points; std::vector aTmpPoints; - CurveCreator::Coordinates::const_iterator aPIt = myPoints.begin(); - CurveCreator::Coordinates::const_iterator aPItLast = myPoints.end(); - const gp_Pnt aFirstPoint( - *aPIt, *(aPIt + 1), (theDimension == 2) ? 0 : *(aPIt + 2)); - gp_Pnt aPoint = aFirstPoint; - aTmpPoints.push_back(aPoint); + + if( myPoints.size() > 0 ) + { + CurveCreator::Coordinates::const_iterator aPIt = myPoints.begin(); + CurveCreator::Coordinates::const_iterator aPItLast = myPoints.end(); + const gp_Pnt aFirstPoint( + *aPIt, *(aPIt + 1), (theDimension == 2) ? 0 : *(aPIt + 2)); + gp_Pnt aPoint = aFirstPoint; + aTmpPoints.push_back(aPoint); + } for (; aPIt != aPItLast; aPIt += theDimension) { From bd364504cc2b874b84e822bcb663b1c54847db05 Mon Sep 17 00:00:00 2001 From: asl Date: Fri, 10 Nov 2017 17:16:14 +0300 Subject: [PATCH 11/11] patch for incorrect compilation --- src/CurveCreator/CurveCreator_Section.cxx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/CurveCreator/CurveCreator_Section.cxx b/src/CurveCreator/CurveCreator_Section.cxx index 0052bcbec..51f83fab6 100644 --- a/src/CurveCreator/CurveCreator_Section.cxx +++ b/src/CurveCreator/CurveCreator_Section.cxx @@ -36,13 +36,16 @@ Handle(TColgp_HArray1OfPnt) CurveCreator_Section::GetDifferentPoints( int theDim std::vector aTmpPoints; + CurveCreator::Coordinates::const_iterator aPIt = myPoints.begin(); + CurveCreator::Coordinates::const_iterator aPItLast = myPoints.end(); + + gp_Pnt aFirstPoint; + gp_Pnt aPoint; + if( myPoints.size() > 0 ) { - CurveCreator::Coordinates::const_iterator aPIt = myPoints.begin(); - CurveCreator::Coordinates::const_iterator aPItLast = myPoints.end(); - const gp_Pnt aFirstPoint( - *aPIt, *(aPIt + 1), (theDimension == 2) ? 0 : *(aPIt + 2)); - gp_Pnt aPoint = aFirstPoint; + aFirstPoint = gp_Pnt(*aPIt, *(aPIt + 1), (theDimension == 2) ? 0 : *(aPIt + 2)); + aPoint = aFirstPoint; aTmpPoints.push_back(aPoint); }