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
This commit is contained in:
mgn 2015-02-20 16:58:58 +03:00 committed by vsr
parent 12a5d6420b
commit 55a306227f
4 changed files with 303 additions and 102 deletions

View File

@ -318,6 +318,7 @@ int CurveCreator_Widget::changeInteractionStyle( int theStyle )
//======================================================================= //=======================================================================
void CurveCreator_Widget::reset() void CurveCreator_Widget::reset()
{ {
stopActionMode();
} }
void CurveCreator_Widget::setCurve( CurveCreator_ICurve* theCurve ) void CurveCreator_Widget::setCurve( CurveCreator_ICurve* theCurve )
@ -618,8 +619,6 @@ void CurveCreator_Widget::onModifySection()
mySectionView->sectionChanged(mySection); mySectionView->sectionChanged(mySection);
updateUndoRedo(); updateUndoRedo();
onCancelSection(); onCancelSection();
emit curveModified();
} }
void CurveCreator_Widget::onJoin() void CurveCreator_Widget::onJoin()
@ -653,8 +652,6 @@ void CurveCreator_Widget::onJoin()
if( aNewSectSize != aMainSectSize ) if( aNewSectSize != aMainSectSize )
mySectionView->pointsAdded( aMainSect, aMainSectSize, aNewSectSize-aMainSectSize );*/ mySectionView->pointsAdded( aMainSect, aMainSectSize, aNewSectSize-aMainSectSize );*/
updateUndoRedo(); updateUndoRedo();
emit curveModified();
} }
void CurveCreator_Widget::onRemove() void CurveCreator_Widget::onRemove()
@ -683,8 +680,6 @@ void CurveCreator_Widget::onClearAll()
mySectionView->reset(); mySectionView->reset();
updateActionsStates(); updateActionsStates();
updateUndoRedo(); updateUndoRedo();
emit curveModified();
} }
void CurveCreator_Widget::onJoinAll() void CurveCreator_Widget::onJoinAll()
@ -702,8 +697,6 @@ void CurveCreator_Widget::onJoinAll()
mySectionView->reset(); mySectionView->reset();
updateActionsStates(); updateActionsStates();
updateUndoRedo(); updateUndoRedo();
emit curveModified();
} }
void CurveCreator_Widget::onUndoSettings() void CurveCreator_Widget::onUndoSettings()
@ -722,8 +715,6 @@ void CurveCreator_Widget::onSetSpline()
mySectionView->sectionChanged(aSelSections[i]); mySectionView->sectionChanged(aSelSections[i]);
} }
updateUndoRedo(); updateUndoRedo();
emit curveModified();
} }
void CurveCreator_Widget::onSetPolyline() void CurveCreator_Widget::onSetPolyline()
@ -737,8 +728,6 @@ void CurveCreator_Widget::onSetPolyline()
mySectionView->sectionChanged( aSelSections[i] ); mySectionView->sectionChanged( aSelSections[i] );
} }
updateUndoRedo(); updateUndoRedo();
emit curveModified();
} }
void CurveCreator_Widget::onCloseSections() void CurveCreator_Widget::onCloseSections()
@ -752,8 +741,6 @@ void CurveCreator_Widget::onCloseSections()
mySectionView->sectionChanged(aSelSections[i]); mySectionView->sectionChanged(aSelSections[i]);
} }
updateUndoRedo(); updateUndoRedo();
emit curveModified();
} }
void CurveCreator_Widget::onUncloseSections() void CurveCreator_Widget::onUncloseSections()
@ -767,8 +754,6 @@ void CurveCreator_Widget::onUncloseSections()
mySectionView->sectionChanged(aSelSections[i]); mySectionView->sectionChanged(aSelSections[i]);
} }
updateUndoRedo(); updateUndoRedo();
emit curveModified();
} }
void CurveCreator_Widget::onUndo() void CurveCreator_Widget::onUndo()
@ -781,8 +766,6 @@ void CurveCreator_Widget::onUndo()
myCurve->undo(); myCurve->undo();
finishCurveModification(); finishCurveModification();
mySectionView->reset(); mySectionView->reset();
emit curveModified();
} }
void CurveCreator_Widget::onRedo() void CurveCreator_Widget::onRedo()
@ -794,8 +777,6 @@ void CurveCreator_Widget::onRedo()
myCurve->redo(); myCurve->redo();
finishCurveModification(); finishCurveModification();
mySectionView->reset(); mySectionView->reset();
emit curveModified();
} }
void CurveCreator_Widget::updateUndoRedo() void CurveCreator_Widget::updateUndoRedo()
@ -1005,8 +986,9 @@ void CurveCreator_Widget::onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent
if ( theEvent->button() != Qt::LeftButton ) if ( theEvent->button() != Qt::LeftButton )
return; return;
myPressedX = theEvent->x(); // Initialize the starting point
myPressedY = theEvent->y(); myStartPoint.setX( theEvent->x() );
myStartPoint.setY( theEvent->y() );
switch( getActionMode() ) { switch( getActionMode() ) {
case ModificationMode: { case ModificationMode: {
@ -1028,11 +1010,61 @@ void CurveCreator_Widget::onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent
* \param theWindow an owner of the signal * \param theWindow an owner of the signal
* \param theEvent a mouse event * \param theEvent a mouse event
*/ */
void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEvent ) void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow* theWindow, QMouseEvent* theEvent )
{ {
if ( getActionMode() != ModificationMode )
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; 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 ) { if ( myDragStarted ) {
bool isDragged = myDragged; bool isDragged = myDragged;
CurveCreator_ICurve::SectionToPointList aDraggedPoints; CurveCreator_ICurve::SectionToPointList aDraggedPoints;
@ -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 else // check whether the segment is clicked an a new point should be added to the segment
{ {
int aReleasedX = theEvent->x(); if ( myStartPoint.x() == myEndPoint.x() && myStartPoint.y() == myEndPoint.y() )
int aReleasedY = theEvent->y(); insertPointToSelectedSegment( myEndPoint.x(), myStartPoint.y() );
if ( myPressedX == aReleasedX && myPressedY == aReleasedY )
insertPointToSelectedSegment( aReleasedX, aReleasedY );
} }
// updates the input panel table to show the selected point coordinates // updates the input panel table to show the selected point coordinates
updateLocalPointView(); updateLocalPointView();
updateUndoRedo(); updateUndoRedo();
emit curveModified();
} }
/** /**
@ -1182,8 +1210,6 @@ void CurveCreator_Widget::onCellChanged( int theRow, int theColumn )
myCurve->setPoint( aCurrSect, aPntIndex, aChangedPos ); myCurve->setPoint( aCurrSect, aPntIndex, aChangedPos );
finishCurveModification( aSelPoints ); finishCurveModification( aSelPoints );
emit curveModified();
} }
/** /**
@ -1201,8 +1227,6 @@ void CurveCreator_Widget::removeSection()
} }
mySectionView->clearSelection(); mySectionView->clearSelection();
updateUndoRedo(); updateUndoRedo();
emit curveModified();
} }
/** /**
@ -1221,8 +1245,6 @@ void CurveCreator_Widget::removePoint()
myCurve->removeSeveralPoints( aPoints ); myCurve->removeSeveralPoints( aPoints );
finishCurveModification( CurveCreator_ICurve::SectionToPointList() ); finishCurveModification( CurveCreator_ICurve::SectionToPointList() );
mySectionView->reset(); mySectionView->reset();
emit curveModified();
} }
void CurveCreator_Widget::addNewPoint(const CurveCreator::Coordinates& theCoords) 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 ) ); mySectionView->pointsAdded( aSection, myCurve->getNbPoints( aSection ) );
updateActionsStates(); updateActionsStates();
updateUndoRedo(); updateUndoRedo();
emit curveModified();
} }
void CurveCreator_Widget::insertPointToSelectedSegment( const int theX, void CurveCreator_Widget::insertPointToSelectedSegment( const int theX,
@ -1306,8 +1326,6 @@ void CurveCreator_Widget::insertPointToSelectedSegment( const int theX,
finishCurveModification( aSelPoints ); finishCurveModification( aSelPoints );
setSelectedPoints(); setSelectedPoints();
emit curveModified();
} }
void CurveCreator_Widget::moveSelectedPoints( const int theXPosition, void CurveCreator_Widget::moveSelectedPoints( const int theXPosition,
@ -1355,8 +1373,6 @@ void CurveCreator_Widget::moveSelectedPoints( const int theXPosition,
myDragged = true; myDragged = true;
finishCurveModification( myDragPoints ); finishCurveModification( myDragPoints );
emit curveModified();
} }
void CurveCreator_Widget::updateLocalPointView() void CurveCreator_Widget::updateLocalPointView()

View File

@ -100,7 +100,6 @@ signals:
void selectionChanged(); void selectionChanged();
void subOperationStarted( QWidget*, bool ); void subOperationStarted( QWidget*, bool );
void subOperationFinished( QWidget* ); void subOperationFinished( QWidget* );
void curveModified();
public slots: public slots:
@ -205,6 +204,11 @@ private:
bool contains( const CurveCreator_ICurve::SectionToPointList& theList, bool contains( const CurveCreator_ICurve::SectionToPointList& theList,
const CurveCreator_ICurve::SectionToPoint& theValue ) const; const CurveCreator_ICurve::SectionToPoint& theValue ) const;
protected:
// Boundary points of mouse to select the points
QPoint myStartPoint;
QPoint myEndPoint;
private: private:
QMap<ActionId, QAction*> myActionMap; QMap<ActionId, QAction*> myActionMap;
CurveCreator_ICurve* myCurve; CurveCreator_ICurve* myCurve;
@ -223,8 +227,6 @@ private:
QMap<CurveCreator_ICurve::SectionToPoint, CurveCreator::Coordinates> myInitialDragPointsCoords; QMap<CurveCreator_ICurve::SectionToPoint, CurveCreator::Coordinates> myInitialDragPointsCoords;
bool myDragged; bool myDragged;
QByteArray myGuiState; QByteArray myGuiState;
int myPressedX;
int myPressedY;
OCCViewer_ViewWindow::Mode2dType myOld2DMode; OCCViewer_ViewWindow::Mode2dType myOld2DMode;
}; };

View File

@ -22,6 +22,7 @@
#include "EntityGUI_PolylineDlg.h" #include "EntityGUI_PolylineDlg.h"
#include <CurveCreator_Curve.hxx> #include <CurveCreator_Curve.hxx>
#include <CurveCreator_Displayer.hxx>
#include <CurveCreator_Utils.hxx> #include <CurveCreator_Utils.hxx>
#include <CurveCreator_Widget.h> #include <CurveCreator_Widget.h>
#include <DlgRef.h> #include <DlgRef.h>
@ -40,6 +41,7 @@
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <Geom_Surface.hxx> #include <Geom_Surface.hxx>
#include <GeomLib_IsPlanarSurface.hxx> #include <GeomLib_IsPlanarSurface.hxx>
#include <Prs3d_LineAspect.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <QGroupBox> #include <QGroupBox>
@ -63,7 +65,9 @@ EntityGUI_PolylineDlg::EntityGUI_PolylineDlg
myWPlaneLineEdit (0), myWPlaneLineEdit (0),
myPolylineSelButton (0), myPolylineSelButton (0),
myPolylineEdit (0), myPolylineEdit (0),
myEditCurrentArgument (0) myEditCurrentArgument (0),
myPreviewManager(0),
myPreviewZLayer(-1)
{ {
QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_POLYLINE"))); QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); 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" ) ); myPlnButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
aPlaneLayout->addWidget(myPlnButton, 0, 3); aPlaneLayout->addWidget(myPlnButton, 0, 3);
bool isCS = false;
#ifdef SET_PLANE
isCS = true;
#endif
myPlnComboBox->setVisible( isCS );
myPlnButton->setVisible( isCS );
#ifdef SET_PLANE #ifdef SET_PLANE
QLabel *aPlaneLbl = new QLabel(tr("GEOM_PLANE"), aGroupBox1); QLabel *aPlaneLbl = new QLabel(tr("GEOM_PLANE"), aGroupBox1);
@ -104,6 +115,7 @@ EntityGUI_PolylineDlg::EntityGUI_PolylineDlg
myPolylineSelButton = new QPushButton (aGroupBox1); myPolylineSelButton = new QPushButton (aGroupBox1);
myPolylineSelButton->setIcon(image1); myPolylineSelButton->setIcon(image1);
myPolylineSelButton->setCheckable(true);
myPolylineEdit = new QLineEdit (aGroupBox1); myPolylineEdit = new QLineEdit (aGroupBox1);
myPolylineEdit->setReadOnly(true); myPolylineEdit->setReadOnly(true);
@ -139,7 +151,7 @@ EntityGUI_PolylineDlg::EntityGUI_PolylineDlg
setHelpFileName( "create_polyline_page.html" ); setHelpFileName( "create_polyline_page.html" );
/* Initialisations */ /* Initializations */
Init(); Init();
} }
@ -149,7 +161,7 @@ EntityGUI_PolylineDlg::EntityGUI_PolylineDlg
//================================================================================= //=================================================================================
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(); LightApp_SelectionMgr *aSelMgr = myGeomGUI->getApp()->selectionMgr();
myEditorWidget->setOCCViewer(aViewManager ? aViewManager->getOCCViewer() : 0); myEditorWidget->setOCCViewer(aViewManager ? aViewManager->getOCCViewer() : 0);
setPreviewManager( aViewManager );
// Init the list of local coordinate system // Init the list of local coordinate system
gp_Pnt aPnt(0., 0., 0.); gp_Pnt aPnt(0., 0., 0.);
@ -178,35 +191,32 @@ void EntityGUI_PolylineDlg::Init()
myWPlaneList.push_back(GEOM::GeomObjPtr()); myWPlaneList.push_back(GEOM::GeomObjPtr());
myLCSList.push_back(aLCS); myLCSList.push_back(aLCS);
connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
#ifdef SET_PLANE #ifdef SET_PLANE
connect(myPlnSelButton, SIGNAL(clicked()), connect( myPlnSelButton, SIGNAL(toggled(bool)),
this, SLOT(SetEditCurrentArgument())); this, SLOT(SetEditCurrentArgument(bool)) );
#endif #endif
connect(myPolylineSelButton, SIGNAL(clicked()), connect( myPolylineSelButton, SIGNAL(toggled(bool)),
this, SLOT(SetEditCurrentArgument())); this, SLOT(SetEditCurrentArgument(bool)) );
connect(aSelMgr, SIGNAL(currentSelectionChanged()), connect( aSelMgr, SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument())); this, SLOT(SelectionIntoArgument()) );
connect(myEditorWidget, SIGNAL(subOperationStarted(QWidget*, bool)), connect( myEditorWidget, SIGNAL(subOperationStarted(QWidget*, bool)),
this, SLOT(processStartedSubOperation(QWidget*, bool))); this, SLOT(processStartedSubOperation(QWidget*, bool)) );
connect(myEditorWidget, SIGNAL(subOperationFinished(QWidget*)), connect( myEditorWidget, SIGNAL(subOperationFinished(QWidget*)),
this, SLOT(processFinishedSubOperation(QWidget*))); this, SLOT(processFinishedSubOperation(QWidget*)) );
connect(myEditorWidget, SIGNAL(curveModified()),
this, SLOT(onUpdatePreview()));
#ifdef SET_PLANE #ifdef SET_PLANE
connect(myPlnComboBox, SIGNAL(activated(int)), connect( myPlnComboBox, SIGNAL(activated(int)),
this, SLOT(ActivateLocalCS())); this, SLOT(ActivateLocalCS()) );
connect(myPlnButton, SIGNAL(clicked()), connect( myPlnButton, SIGNAL(clicked()),
this, SLOT(ActivateLocalCS())); this, SLOT(ActivateLocalCS()) );
#endif #endif
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect( buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()) );
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect( buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()) );
myAddElementBox->hide(); myAddElementBox->hide();
myPolylineSelButton->click();
SelectionIntoArgument(); // Processing of the selected object
myPolylineSelButton->setChecked( true );
SelectionIntoArgument( true );
} }
//================================================================================= //=================================================================================
@ -365,6 +375,9 @@ bool EntityGUI_PolylineDlg::ClickOnApply()
initName(); initName();
// Reset actions
myEditorWidget->reset();
return true; return true;
} }
@ -432,17 +445,19 @@ bool EntityGUI_PolylineDlg::deleteEnabled()
// function : SelectionIntoArgument // function : SelectionIntoArgument
// purpose : Called when selection is changed // 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); GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_SHAPE);
TopoDS_Shape aShape; TopoDS_Shape aShape;
if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) &&
!aShape.IsNull()) { !aShape.IsNull())
{
QString aName = GEOMBase::GetName(aSelectedObject.get()); QString aName = GEOMBase::GetName(aSelectedObject.get());
if (myEditCurrentArgument == myPolylineEdit) { if ( myEditCurrentArgument == myPolylineEdit && isCheckToSelect() )
{
// Import a curve // Import a curve
CurveCreator_Curve *aNewCurve = CurveCreator_Curve *aNewCurve =
new CurveCreator_Curve(CurveCreator::Dim2d); new CurveCreator_Curve(CurveCreator::Dim2d);
@ -458,15 +473,22 @@ void EntityGUI_PolylineDlg::SelectionIntoArgument()
#ifdef SET_PLANE #ifdef SET_PLANE
AddLocalCS(aSelectedObject.get(), false, aLocalCS); AddLocalCS(aSelectedObject.get(), false, aLocalCS);
myWPlaneLineEdit->clear(); myWPlaneLineEdit->clear();
myPlnSelButton->setDown(false); myPlnSelButton->setChecked(false);
#endif #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 { } else {
// Does nothing, just clears selection. // Does nothing, just clears selection.
delete aNewCurve; delete aNewCurve;
} }
}
#ifdef SET_PLANE #ifdef SET_PLANE
} else if (myEditCurrentArgument == myWPlaneLineEdit) { else if ( myEditCurrentArgument == myWPlaneLineEdit && isCheckToSelect() )
{
// Import planar face. // Import planar face.
if (aShape.ShapeType() == TopAbs_FACE) { if (aShape.ShapeType() == TopAbs_FACE) {
// Check if the face is planar // Check if the face is planar
@ -479,47 +501,65 @@ void EntityGUI_PolylineDlg::SelectionIntoArgument()
AddLocalCS(aSelectedObject.get(), true, AddLocalCS(aSelectedObject.get(), true,
WPlaneToLCS(aSelectedObject.get())); WPlaneToLCS(aSelectedObject.get()));
isModified = true; isModified = true;
myPlnSelButton->setDown(true); myPlnSelButton->setChecked(false);
myPolylineSelButton->setDown(false); myPolylineSelButton->setChecked(false);
} }
} }
if (!isModified) { if (!isModified) {
myEditCurrentArgument->setText(tr("GEOM_SKETCHER_WPLANE")); myEditCurrentArgument->setText(tr("GEOM_SKETCHER_WPLANE"));
} }
}
#endif #endif
} }
else
{
if (isForced)
{
#ifdef SET_PLANE
myPlnSelButton->setChecked(false);
#endif
myPolylineSelButton->setChecked(false);
}
} }
if (!isModified) { if (!isModified)
{
// Does nothing, just clears selection. // Does nothing, just clears selection.
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected(); myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument())); this, SLOT(SelectionIntoArgument()));
} }
else
displayPreview();
} }
//================================================================================= //=================================================================================
// function : SetEditCurrentArgument() // function : SetEditCurrentArgument()
// purpose : // purpose :
//================================================================================= //=================================================================================
void EntityGUI_PolylineDlg::SetEditCurrentArgument() void EntityGUI_PolylineDlg::SetEditCurrentArgument( bool isChecked )
{ {
if (sender() == myPlnSelButton) { if (sender() == myPlnSelButton)
{
#ifdef SET_PLANE #ifdef SET_PLANE
myEditCurrentArgument = myWPlaneLineEdit; myEditCurrentArgument = myWPlaneLineEdit;
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
myPlnSelButton->setDown(true); myPolylineSelButton->blockSignals(true);
myPolylineSelButton->setDown(false); myPolylineSelButton->setChecked(false);
myPolylineSelButton->blockSignals(false);
#endif #endif
} else if (sender() == myPolylineSelButton) { }
else if (sender() == myPolylineSelButton)
{
myEditCurrentArgument = myPolylineEdit; myEditCurrentArgument = myPolylineEdit;
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
#ifdef SET_PLANE #ifdef SET_PLANE
myPlnSelButton->setDown(false); myPlnSelButton->blockSignals(true);
myPlnSelButton->setChecked(false);
myPlnSelButton->blockSignals(false);
#endif #endif
myPolylineSelButton->setDown(true);
} }
} }
@ -545,15 +585,6 @@ void EntityGUI_PolylineDlg::enterEvent (QEvent*)
ActivateThisDialog(); ActivateThisDialog();
} }
//=================================================================================
// function : onUpdatePreview
// purpose :
//=================================================================================
void EntityGUI_PolylineDlg::onUpdatePreview()
{
displayPreview(true);
}
//================================================================================= //=================================================================================
// function : ActivateLocalCS // function : ActivateLocalCS
// purpose : Activate & Fit Working plane // purpose : Activate & Fit Working plane
@ -680,3 +711,126 @@ QList<GEOM::GeomObjPtr> EntityGUI_PolylineDlg::getSourceObjects()
{ {
return myWPlaneList; 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();
}

View File

@ -23,15 +23,14 @@
#ifndef ENTITYGUI_POLYLINEDLG_H #ifndef ENTITYGUI_POLYLINEDLG_H
#define ENTITYGUI_POLYLINEDLG_H #define ENTITYGUI_POLYLINEDLG_H
#include <GEOMBase_Skeleton.h> #include <GEOMBase_Skeleton.h>
class CurveCreator_Curve; class CurveCreator_Curve;
class CurveCreator_Widget; class CurveCreator_Widget;
class OCCViewer_ViewManager;
class QGroupBox; class QGroupBox;
class QComboBox; class QComboBox;
//================================================================================= //=================================================================================
// class : EntityGUI_PolylineDlg // class : EntityGUI_PolylineDlg
// purpose : // purpose :
@ -50,6 +49,9 @@ public:
void deleteSelected(); void deleteSelected();
bool deleteEnabled(); bool deleteEnabled();
void setPreviewZLayer( int theLayer );
int getPreviewZLayer() const;
protected: protected:
// redefined from GEOMBase_Helper // redefined from GEOMBase_Helper
@ -58,6 +60,20 @@ protected:
virtual bool execute( ObjectList& ); virtual bool execute( ObjectList& );
virtual QList<GEOM::GeomObjPtr> getSourceObjects(); virtual QList<GEOM::GeomObjPtr> 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: private:
void Init(); void Init();
@ -103,7 +119,7 @@ private:
* This method add a local coordinate system of the selected object. * This method add a local coordinate system of the selected object.
* *
* \param theSelectedObject the selected object. It can be a planar face * \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 IsPlane true for planar face; false for imported polyline.
* \param theLCS the local coordinate system. * \param theLCS the local coordinate system.
*/ */
@ -120,6 +136,18 @@ private:
*/ */
gp_Ax3 WPlaneToLCS(GEOM::GeomObjPtr theGeomObj); 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: protected slots:
void ClickOnOk(); void ClickOnOk();
@ -127,10 +155,9 @@ protected slots:
void ClickOnCancel(); void ClickOnCancel();
void processStartedSubOperation( QWidget*, bool ); void processStartedSubOperation( QWidget*, bool );
void processFinishedSubOperation( QWidget* ); void processFinishedSubOperation( QWidget* );
void SetEditCurrentArgument(); void SetEditCurrentArgument( bool );
void SelectionIntoArgument(); void SelectionIntoArgument( bool isForced = false );
void ActivateThisDialog(); void ActivateThisDialog();
void onUpdatePreview();
void ActivateLocalCS(); void ActivateLocalCS();
private: private:
@ -147,6 +174,8 @@ private:
QLineEdit *myEditCurrentArgument; /* Current LineEdit */ QLineEdit *myEditCurrentArgument; /* Current LineEdit */
QList<gp_Ax3> myLCSList; QList<gp_Ax3> myLCSList;
QList<GEOM::GeomObjPtr> myWPlaneList; QList<GEOM::GeomObjPtr> myWPlaneList;
OCCViewer_ViewManager* myPreviewManager;
int myPreviewZLayer;
}; };