From 55a306227fa1243900e41290e4fbca147c0b605c Mon Sep 17 00:00:00 2001 From: mgn Date: Fri, 20 Feb 2015 16:58:58 +0300 Subject: [PATCH] Issues 0022843, 0022845, 0022846 * Issue 0022845: EDF GEOM: [HYDRO] Hiding the coordinates system part of the dialog box in the polyline editor - Disabled display of coordinate system combo box * Issue 0022843: EDF GEOM: [HYDRO] Polyline using a former polyline - Changed algorithm of polyline and spline construction * Issue 0022846: EDF GEOM: [HYDRO] Creation of a polyline: add intermediate points and remove points - Added possibility to add/remove/modify new or intermediate points, select and modify them - Added possibility to drag and drop points in a view - Set violet color for preview in temporary Z layer - Changed behavior of selected object --- src/CurveCreator/CurveCreator_Widget.cxx | 98 +++++---- src/CurveCreator/CurveCreator_Widget.h | 8 +- src/EntityGUI/EntityGUI_PolylineDlg.cxx | 258 ++++++++++++++++++----- src/EntityGUI/EntityGUI_PolylineDlg.h | 41 +++- 4 files changed, 303 insertions(+), 102 deletions(-) diff --git a/src/CurveCreator/CurveCreator_Widget.cxx b/src/CurveCreator/CurveCreator_Widget.cxx index f63b71f31..7bd5f4155 100644 --- a/src/CurveCreator/CurveCreator_Widget.cxx +++ b/src/CurveCreator/CurveCreator_Widget.cxx @@ -318,6 +318,7 @@ int CurveCreator_Widget::changeInteractionStyle( int theStyle ) //======================================================================= void CurveCreator_Widget::reset() { + stopActionMode(); } void CurveCreator_Widget::setCurve( CurveCreator_ICurve* theCurve ) @@ -618,8 +619,6 @@ void CurveCreator_Widget::onModifySection() mySectionView->sectionChanged(mySection); updateUndoRedo(); onCancelSection(); - - emit curveModified(); } void CurveCreator_Widget::onJoin() @@ -653,8 +652,6 @@ void CurveCreator_Widget::onJoin() if( aNewSectSize != aMainSectSize ) mySectionView->pointsAdded( aMainSect, aMainSectSize, aNewSectSize-aMainSectSize );*/ updateUndoRedo(); - - emit curveModified(); } void CurveCreator_Widget::onRemove() @@ -683,8 +680,6 @@ void CurveCreator_Widget::onClearAll() mySectionView->reset(); updateActionsStates(); updateUndoRedo(); - - emit curveModified(); } void CurveCreator_Widget::onJoinAll() @@ -702,8 +697,6 @@ void CurveCreator_Widget::onJoinAll() mySectionView->reset(); updateActionsStates(); updateUndoRedo(); - - emit curveModified(); } void CurveCreator_Widget::onUndoSettings() @@ -722,8 +715,6 @@ void CurveCreator_Widget::onSetSpline() mySectionView->sectionChanged(aSelSections[i]); } updateUndoRedo(); - - emit curveModified(); } void CurveCreator_Widget::onSetPolyline() @@ -737,8 +728,6 @@ void CurveCreator_Widget::onSetPolyline() mySectionView->sectionChanged( aSelSections[i] ); } updateUndoRedo(); - - emit curveModified(); } void CurveCreator_Widget::onCloseSections() @@ -752,8 +741,6 @@ void CurveCreator_Widget::onCloseSections() mySectionView->sectionChanged(aSelSections[i]); } updateUndoRedo(); - - emit curveModified(); } void CurveCreator_Widget::onUncloseSections() @@ -767,8 +754,6 @@ void CurveCreator_Widget::onUncloseSections() mySectionView->sectionChanged(aSelSections[i]); } updateUndoRedo(); - - emit curveModified(); } void CurveCreator_Widget::onUndo() @@ -781,8 +766,6 @@ void CurveCreator_Widget::onUndo() myCurve->undo(); finishCurveModification(); mySectionView->reset(); - - emit curveModified(); } void CurveCreator_Widget::onRedo() @@ -794,8 +777,6 @@ void CurveCreator_Widget::onRedo() myCurve->redo(); finishCurveModification(); mySectionView->reset(); - - emit curveModified(); } void CurveCreator_Widget::updateUndoRedo() @@ -1005,8 +986,9 @@ void CurveCreator_Widget::onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent if ( theEvent->button() != Qt::LeftButton ) return; - myPressedX = theEvent->x(); - myPressedY = theEvent->y(); + // Initialize the starting point + myStartPoint.setX( theEvent->x() ); + myStartPoint.setY( theEvent->y() ); switch( getActionMode() ) { case ModificationMode: { @@ -1028,10 +1010,60 @@ void CurveCreator_Widget::onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent * \param theWindow an owner of the signal * \param theEvent a mouse event */ -void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEvent ) +void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow* theWindow, QMouseEvent* theEvent ) { + + if (theEvent->button() != Qt::LeftButton) return; + if (!theWindow->inherits("OCCViewer_ViewWindow")) return; + + // Initialize the ending point + myEndPoint.setX( theEvent->x() ); + myEndPoint.setY( theEvent->y() ); + + bool aHasShift = ( theEvent->modifiers() & Qt::ShiftModifier ); + + // Highlight detected objects + Handle(AIS_InteractiveContext) aCtx = getAISContext(); + if ( !aCtx.IsNull() ) + { + OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow; + if (!aView) + return; + + if (!aHasShift) + aCtx->ClearCurrents( false ); + + Handle(V3d_View) aView3d = aView->getViewPort()->getView(); + if ( !aView3d.IsNull() ) + { + // Initialize the single selection if start and end points are equal, + // otherwise a rectangular selection. + if ( myStartPoint == myEndPoint ) + { + aCtx->MoveTo( myEndPoint.x(), myEndPoint.y(), aView3d ); + if ( aHasShift ) + aCtx->ShiftSelect(); + else + aCtx->Select(); + } + else + { + if ( aHasShift ) + aCtx->ShiftSelect( myStartPoint.x(), myStartPoint.y(), myEndPoint.x(), myEndPoint.y(), + aView3d, Standard_False ); + else + aCtx->Select( myStartPoint.x(), myStartPoint.y(), myEndPoint.x(), myEndPoint.y(), + aView3d, Standard_False ); + } + } + } + if ( getActionMode() != ModificationMode ) + { + // Emit selectionChanged() signal + getOCCViewer()->performSelectionChanged(); return; + } if ( myDragStarted ) { bool isDragged = myDragged; @@ -1104,17 +1136,13 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEven } else // check whether the segment is clicked an a new point should be added to the segment { - int aReleasedX = theEvent->x(); - int aReleasedY = theEvent->y(); - if ( myPressedX == aReleasedX && myPressedY == aReleasedY ) - insertPointToSelectedSegment( aReleasedX, aReleasedY ); + if ( myStartPoint.x() == myEndPoint.x() && myStartPoint.y() == myEndPoint.y() ) + insertPointToSelectedSegment( myEndPoint.x(), myStartPoint.y() ); } // updates the input panel table to show the selected point coordinates updateLocalPointView(); updateUndoRedo(); - - emit curveModified(); } /** @@ -1182,8 +1210,6 @@ void CurveCreator_Widget::onCellChanged( int theRow, int theColumn ) myCurve->setPoint( aCurrSect, aPntIndex, aChangedPos ); finishCurveModification( aSelPoints ); - - emit curveModified(); } /** @@ -1201,8 +1227,6 @@ void CurveCreator_Widget::removeSection() } mySectionView->clearSelection(); updateUndoRedo(); - - emit curveModified(); } /** @@ -1221,8 +1245,6 @@ void CurveCreator_Widget::removePoint() myCurve->removeSeveralPoints( aPoints ); finishCurveModification( CurveCreator_ICurve::SectionToPointList() ); mySectionView->reset(); - - emit curveModified(); } void CurveCreator_Widget::addNewPoint(const CurveCreator::Coordinates& theCoords) @@ -1238,8 +1260,6 @@ void CurveCreator_Widget::addNewPoint(const CurveCreator::Coordinates& theCoords mySectionView->pointsAdded( aSection, myCurve->getNbPoints( aSection ) ); updateActionsStates(); updateUndoRedo(); - - emit curveModified(); } void CurveCreator_Widget::insertPointToSelectedSegment( const int theX, @@ -1306,8 +1326,6 @@ void CurveCreator_Widget::insertPointToSelectedSegment( const int theX, finishCurveModification( aSelPoints ); setSelectedPoints(); - - emit curveModified(); } void CurveCreator_Widget::moveSelectedPoints( const int theXPosition, @@ -1355,8 +1373,6 @@ void CurveCreator_Widget::moveSelectedPoints( const int theXPosition, myDragged = true; finishCurveModification( myDragPoints ); - - emit curveModified(); } void CurveCreator_Widget::updateLocalPointView() diff --git a/src/CurveCreator/CurveCreator_Widget.h b/src/CurveCreator/CurveCreator_Widget.h index 682896f9b..1fa317f56 100644 --- a/src/CurveCreator/CurveCreator_Widget.h +++ b/src/CurveCreator/CurveCreator_Widget.h @@ -100,7 +100,6 @@ signals: void selectionChanged(); void subOperationStarted( QWidget*, bool ); void subOperationFinished( QWidget* ); - void curveModified(); public slots: @@ -205,6 +204,11 @@ private: bool contains( const CurveCreator_ICurve::SectionToPointList& theList, const CurveCreator_ICurve::SectionToPoint& theValue ) const; +protected: + // Boundary points of mouse to select the points + QPoint myStartPoint; + QPoint myEndPoint; + private: QMap myActionMap; CurveCreator_ICurve* myCurve; @@ -223,8 +227,6 @@ private: QMap myInitialDragPointsCoords; bool myDragged; QByteArray myGuiState; - int myPressedX; - int myPressedY; OCCViewer_ViewWindow::Mode2dType myOld2DMode; }; diff --git a/src/EntityGUI/EntityGUI_PolylineDlg.cxx b/src/EntityGUI/EntityGUI_PolylineDlg.cxx index 94773a51f..71aeef103 100644 --- a/src/EntityGUI/EntityGUI_PolylineDlg.cxx +++ b/src/EntityGUI/EntityGUI_PolylineDlg.cxx @@ -22,6 +22,7 @@ #include "EntityGUI_PolylineDlg.h" #include +#include #include #include #include @@ -40,6 +41,7 @@ #include #include #include +#include #include #include @@ -63,7 +65,9 @@ EntityGUI_PolylineDlg::EntityGUI_PolylineDlg myWPlaneLineEdit (0), myPolylineSelButton (0), myPolylineEdit (0), - myEditCurrentArgument (0) + myEditCurrentArgument (0), + myPreviewManager(0), + myPreviewZLayer(-1) { QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_POLYLINE"))); QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); @@ -91,6 +95,13 @@ EntityGUI_PolylineDlg::EntityGUI_PolylineDlg myPlnButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) ); aPlaneLayout->addWidget(myPlnButton, 0, 3); + bool isCS = false; +#ifdef SET_PLANE + isCS = true; +#endif + myPlnComboBox->setVisible( isCS ); + myPlnButton->setVisible( isCS ); + #ifdef SET_PLANE QLabel *aPlaneLbl = new QLabel(tr("GEOM_PLANE"), aGroupBox1); @@ -104,6 +115,7 @@ EntityGUI_PolylineDlg::EntityGUI_PolylineDlg myPolylineSelButton = new QPushButton (aGroupBox1); myPolylineSelButton->setIcon(image1); + myPolylineSelButton->setCheckable(true); myPolylineEdit = new QLineEdit (aGroupBox1); myPolylineEdit->setReadOnly(true); @@ -139,7 +151,7 @@ EntityGUI_PolylineDlg::EntityGUI_PolylineDlg setHelpFileName( "create_polyline_page.html" ); - /* Initialisations */ + /* Initializations */ Init(); } @@ -149,7 +161,7 @@ EntityGUI_PolylineDlg::EntityGUI_PolylineDlg //================================================================================= EntityGUI_PolylineDlg::~EntityGUI_PolylineDlg() { - delete myCurve; + erasePreview(); } //================================================================================= @@ -166,6 +178,7 @@ void EntityGUI_PolylineDlg::Init() LightApp_SelectionMgr *aSelMgr = myGeomGUI->getApp()->selectionMgr(); myEditorWidget->setOCCViewer(aViewManager ? aViewManager->getOCCViewer() : 0); + setPreviewManager( aViewManager ); // Init the list of local coordinate system gp_Pnt aPnt(0., 0., 0.); @@ -178,35 +191,32 @@ void EntityGUI_PolylineDlg::Init() myWPlaneList.push_back(GEOM::GeomObjPtr()); myLCSList.push_back(aLCS); - connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); - connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); - #ifdef SET_PLANE - connect(myPlnSelButton, SIGNAL(clicked()), - this, SLOT(SetEditCurrentArgument())); + connect( myPlnSelButton, SIGNAL(toggled(bool)), + this, SLOT(SetEditCurrentArgument(bool)) ); #endif - connect(myPolylineSelButton, SIGNAL(clicked()), - this, SLOT(SetEditCurrentArgument())); - connect(aSelMgr, SIGNAL(currentSelectionChanged()), - this, SLOT(SelectionIntoArgument())); - connect(myEditorWidget, SIGNAL(subOperationStarted(QWidget*, bool)), - this, SLOT(processStartedSubOperation(QWidget*, bool))); - connect(myEditorWidget, SIGNAL(subOperationFinished(QWidget*)), - this, SLOT(processFinishedSubOperation(QWidget*))); - connect(myEditorWidget, SIGNAL(curveModified()), - this, SLOT(onUpdatePreview())); + connect( myPolylineSelButton, SIGNAL(toggled(bool)), + this, SLOT(SetEditCurrentArgument(bool)) ); + connect( aSelMgr, SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument()) ); + connect( myEditorWidget, SIGNAL(subOperationStarted(QWidget*, bool)), + this, SLOT(processStartedSubOperation(QWidget*, bool)) ); + connect( myEditorWidget, SIGNAL(subOperationFinished(QWidget*)), + this, SLOT(processFinishedSubOperation(QWidget*)) ); #ifdef SET_PLANE - connect(myPlnComboBox, SIGNAL(activated(int)), - this, SLOT(ActivateLocalCS())); - connect(myPlnButton, SIGNAL(clicked()), - this, SLOT(ActivateLocalCS())); + connect( myPlnComboBox, SIGNAL(activated(int)), + this, SLOT(ActivateLocalCS()) ); + connect( myPlnButton, SIGNAL(clicked()), + this, SLOT(ActivateLocalCS()) ); #endif - connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect( buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()) ); + connect( buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()) ); myAddElementBox->hide(); - myPolylineSelButton->click(); - SelectionIntoArgument(); + + // Processing of the selected object + myPolylineSelButton->setChecked( true ); + SelectionIntoArgument( true ); } //================================================================================= @@ -365,6 +375,9 @@ bool EntityGUI_PolylineDlg::ClickOnApply() initName(); + // Reset actions + myEditorWidget->reset(); + return true; } @@ -432,17 +445,19 @@ bool EntityGUI_PolylineDlg::deleteEnabled() // function : SelectionIntoArgument // purpose : Called when selection is changed //================================================================================= -void EntityGUI_PolylineDlg::SelectionIntoArgument() +void EntityGUI_PolylineDlg::SelectionIntoArgument( bool isForced ) { - bool isModified = false; + bool isModified = isForced; GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_SHAPE); TopoDS_Shape aShape; if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && - !aShape.IsNull()) { + !aShape.IsNull()) + { QString aName = GEOMBase::GetName(aSelectedObject.get()); - if (myEditCurrentArgument == myPolylineEdit) { + if ( myEditCurrentArgument == myPolylineEdit && isCheckToSelect() ) + { // Import a curve CurveCreator_Curve *aNewCurve = new CurveCreator_Curve(CurveCreator::Dim2d); @@ -458,15 +473,22 @@ void EntityGUI_PolylineDlg::SelectionIntoArgument() #ifdef SET_PLANE AddLocalCS(aSelectedObject.get(), false, aLocalCS); myWPlaneLineEdit->clear(); - myPlnSelButton->setDown(false); + myPlnSelButton->setChecked(false); #endif - myPolylineSelButton->setDown(true); + myPolylineSelButton->setChecked(false); + + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + myGeomGUI->getApp()->selectionMgr()->clearSelected(); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); } else { // Does nothing, just clears selection. delete aNewCurve; } + } #ifdef SET_PLANE - } else if (myEditCurrentArgument == myWPlaneLineEdit) { + else if ( myEditCurrentArgument == myWPlaneLineEdit && isCheckToSelect() ) + { // Import planar face. if (aShape.ShapeType() == TopAbs_FACE) { // Check if the face is planar @@ -479,47 +501,65 @@ void EntityGUI_PolylineDlg::SelectionIntoArgument() AddLocalCS(aSelectedObject.get(), true, WPlaneToLCS(aSelectedObject.get())); isModified = true; - myPlnSelButton->setDown(true); - myPolylineSelButton->setDown(false); + myPlnSelButton->setChecked(false); + myPolylineSelButton->setChecked(false); } } if (!isModified) { myEditCurrentArgument->setText(tr("GEOM_SKETCHER_WPLANE")); } + } #endif + } + else + { + if (isForced) + { +#ifdef SET_PLANE + myPlnSelButton->setChecked(false); +#endif + myPolylineSelButton->setChecked(false); } } - if (!isModified) { + if (!isModified) + { // Does nothing, just clears selection. disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); myGeomGUI->getApp()->selectionMgr()->clearSelected(); connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); } + else + displayPreview(); } //================================================================================= // function : SetEditCurrentArgument() // purpose : //================================================================================= -void EntityGUI_PolylineDlg::SetEditCurrentArgument() +void EntityGUI_PolylineDlg::SetEditCurrentArgument( bool isChecked ) { - if (sender() == myPlnSelButton) { + if (sender() == myPlnSelButton) + { #ifdef SET_PLANE myEditCurrentArgument = myWPlaneLineEdit; myEditCurrentArgument->setFocus(); - myPlnSelButton->setDown(true); - myPolylineSelButton->setDown(false); + myPolylineSelButton->blockSignals(true); + myPolylineSelButton->setChecked(false); + myPolylineSelButton->blockSignals(false); #endif - } else if (sender() == myPolylineSelButton) { + } + else if (sender() == myPolylineSelButton) + { myEditCurrentArgument = myPolylineEdit; myEditCurrentArgument->setFocus(); #ifdef SET_PLANE - myPlnSelButton->setDown(false); + myPlnSelButton->blockSignals(true); + myPlnSelButton->setChecked(false); + myPlnSelButton->blockSignals(false); #endif - myPolylineSelButton->setDown(true); } } @@ -545,15 +585,6 @@ void EntityGUI_PolylineDlg::enterEvent (QEvent*) ActivateThisDialog(); } -//================================================================================= -// function : onUpdatePreview -// purpose : -//================================================================================= -void EntityGUI_PolylineDlg::onUpdatePreview() -{ - displayPreview(true); -} - //================================================================================= // function : ActivateLocalCS // purpose : Activate & Fit Working plane @@ -680,3 +711,126 @@ QList EntityGUI_PolylineDlg::getSourceObjects() { return myWPlaneList; } + +//================================================================================= +// function : setPreviewManager ( OCCViewer_ViewManager ) +// purpose : Sets view manager to control the displayed objects. +//================================================================================= +void EntityGUI_PolylineDlg::setPreviewManager( OCCViewer_ViewManager* theManager ) +{ + myPreviewManager = theManager; + + if ( getPreviewManager() ) + { + if( OCCViewer_Viewer* aViewer = getPreviewManager()->getOCCViewer() ) + { + Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); + if( !aCtx.IsNull() ) + { + // Add Z layer to show temporary objects + int aZLayer = -1; + aViewer->getViewer3d()->AddZLayer( aZLayer ); + setPreviewZLayer( aZLayer ); + } + } + } +} + +//================================================================================= +// function : getPreviewManager() +// purpose : +//================================================================================= +OCCViewer_ViewManager* EntityGUI_PolylineDlg::getPreviewManager() +{ + return myPreviewManager; +} + +//================================================================================= +// function : setPreviewZLayer( theZLayer ) +// purpose : Sets Z layer to show temporary objects. +//================================================================================= +void EntityGUI_PolylineDlg::setPreviewZLayer( int theZLayer ) +{ + if ( theZLayer != myPreviewZLayer ) + myPreviewZLayer = theZLayer; +} + +//================================================================================= +// function : getPreviewZLayer() +// purpose : +//================================================================================= +int EntityGUI_PolylineDlg::getPreviewZLayer() const +{ + return myPreviewZLayer; +} + +//================================================================================= +// function : displayPreview() +// purpose : +//================================================================================= +void EntityGUI_PolylineDlg::displayPreview() +{ + if ( getPreviewManager() ) + { + if ( OCCViewer_Viewer* aViewer = getPreviewManager()->getOCCViewer() ) + { + // Disable changing of OCCViewer's selection to use vertex of curve selection + disconnect(getPreviewManager(), SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), + aViewer, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); + + Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); + if ( !aCtx.IsNull() ) + { + CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx, getPreviewZLayer() ); + myCurve->setDisplayer( aDisplayer ); + + Handle(AIS_InteractiveObject) anAISObj = myCurve->getAISObject( true ); + aDisplayer->display( anAISObj, true ); + + // Set color for temporary AIS_InteractiveObject + anAISObj->Attributes()->WireAspect()->SetColor( Quantity_NOC_VIOLET ); + } + } + } +} + +//================================================================================= +// function : erasePreview() +// purpose : +//================================================================================= +void EntityGUI_PolylineDlg::erasePreview() +{ + CurveCreator_Displayer* aDisplayer = myCurve ? myCurve->getDisplayer() : 0; + if( getPreviewManager() ) + { + if( OCCViewer_Viewer* aViewer = getPreviewManager()->getOCCViewer() ) + { + Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); + if( !aCtx.IsNull() && aDisplayer ) + aDisplayer->eraseAll( true ); + + // Enable changing of OCCViewer's selection + connect(getPreviewManager(), SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), + aViewer, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); + } + } + + setPreviewManager( NULL ); + if ( myCurve ) + { + delete myCurve; + myCurve = NULL; + } +} + +//================================================================================= +// function : isCheckToSelect() +// purpose : +//================================================================================= +bool EntityGUI_PolylineDlg::isCheckToSelect() +{ +#ifdef SET_PLANE + return myPlnSelButton->isChecked(); +#endif + return myPolylineSelButton->isChecked(); +} diff --git a/src/EntityGUI/EntityGUI_PolylineDlg.h b/src/EntityGUI/EntityGUI_PolylineDlg.h index 0c1778f7d..53ff8dfc9 100644 --- a/src/EntityGUI/EntityGUI_PolylineDlg.h +++ b/src/EntityGUI/EntityGUI_PolylineDlg.h @@ -23,15 +23,14 @@ #ifndef ENTITYGUI_POLYLINEDLG_H #define ENTITYGUI_POLYLINEDLG_H - #include class CurveCreator_Curve; class CurveCreator_Widget; +class OCCViewer_ViewManager; class QGroupBox; class QComboBox; - //================================================================================= // class : EntityGUI_PolylineDlg // purpose : @@ -50,6 +49,9 @@ public: void deleteSelected(); bool deleteEnabled(); + void setPreviewZLayer( int theLayer ); + int getPreviewZLayer() const; + protected: // redefined from GEOMBase_Helper @@ -58,6 +60,20 @@ protected: virtual bool execute( ObjectList& ); virtual QList getSourceObjects(); + /** + * This method sets/gets the view manager to control the temporary + * displayed objects on Z layer. + * \param theManager the view manager. + */ + void setPreviewManager( OCCViewer_ViewManager* theManager ); + OCCViewer_ViewManager* getPreviewManager(); + + /** + * This method defines a state of selection button. + * \return true if selection button is checked, otherwise false. + */ + bool isCheckToSelect(); + private: void Init(); @@ -103,7 +119,7 @@ private: * This method add a local coordinate system of the selected object. * * \param theSelectedObject the selected object. It can be a planar face - * or an inported polyline. + * or an imported polyline. * \param IsPlane true for planar face; false for imported polyline. * \param theLCS the local coordinate system. */ @@ -120,6 +136,18 @@ private: */ gp_Ax3 WPlaneToLCS(GEOM::GeomObjPtr theGeomObj); + /** + * This method displays the AIS_InteractiveObject(s) to preview + * on the Z layer and sets VIOLET color. + */ + void displayPreview(); + + /** + * This method erases AIS_InteractiveObject(s) from + * AIS_InteractiveContext and release memory. + */ + void erasePreview(); + protected slots: void ClickOnOk(); @@ -127,10 +155,9 @@ protected slots: void ClickOnCancel(); void processStartedSubOperation( QWidget*, bool ); void processFinishedSubOperation( QWidget* ); - void SetEditCurrentArgument(); - void SelectionIntoArgument(); + void SetEditCurrentArgument( bool ); + void SelectionIntoArgument( bool isForced = false ); void ActivateThisDialog(); - void onUpdatePreview(); void ActivateLocalCS(); private: @@ -147,6 +174,8 @@ private: QLineEdit *myEditCurrentArgument; /* Current LineEdit */ QList myLCSList; QList myWPlaneList; + OCCViewer_ViewManager* myPreviewManager; + int myPreviewZLayer; }; -- 2.39.2