<b>Show/Hide Trihedron</b> - shows or hides coordinate axes.
<hr>
+\image html occ_view_preselection.png
+
+<b>Enable/Disable preselection</b> - enables or disables preselection in the view.
+<hr>
+
+\image html occ_view_selection.png
+
+<b>Enable/Disable selection</b> - enables or disables selection in the view.
+<hr>
+
\image html occ_view_fitall.png
<b>Fit all</b> - allows to select a point to be the center of a scene
if ( !title.isEmpty() )
theView->setWindowTitle( windowTitle() + " - " + title );
}
+
+void OCCViewer_ViewFrame::enableSelection( bool isEnabled )
+{
+ foreach (OCCViewer_ViewWindow* aView, myViews) {
+ aView->enableSelection(isEnabled);
+ }
+}
+
+void OCCViewer_ViewFrame::enablePreselection( bool isEnabled )
+{
+ foreach (OCCViewer_ViewWindow* aView, myViews) {
+ aView->enablePreselection(isEnabled);
+ }
+}
virtual int zoomingStyle() const { return getView(MAIN_VIEW)->zoomingStyle(); }
virtual void setZoomingStyle( const int );
+ virtual bool isSelectionEnabled() const { return getView(MAIN_VIEW)->isSelectionEnabled(); }
+ virtual void enableSelection( bool );
+
+ virtual bool isPreselectionEnabled() const { return getView(MAIN_VIEW)->isPreselectionEnabled(); }
+ virtual void enablePreselection( bool );
+
virtual void setViewManager( SUIT_ViewManager* );
virtual bool eventFilter(QObject* watched, QEvent* e) { return SUIT_ViewWindow::eventFilter(watched, e); }
// set zooming style to standard
myZoomingStyle = 0;
+ // preselection
+ myPreselectionEnabled = true;
+
// selection
mySelectionEnabled = true;
myMultiSelectionEnabled = true;
view->initSketchers();
view->setInteractionStyle( interactionStyle() );
view->setZoomingStyle( zoomingStyle() );
+ view->enablePreselection( isPreselectionEnabled() );
+ view->enableSelection( isSelectionEnabled() );
OCCViewer_ViewPort3d* vp3d = view->getViewPort();
if ( vp3d )
OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
- if ( isSelectionEnabled() ) {
+ myCurPnt.setX(theEvent->x()); myCurPnt.setY(theEvent->y());
+
+ if ( isSelectionEnabled() && isPreselectionEnabled() ) {
if (aView->getViewPort()->isBusy()) {
QCoreApplication::processEvents();
return; // Check that the ViewPort initialization completed
if (myStartPnt == myEndPnt)
{
+ if ( !isPreselectionEnabled() ) {
+ Handle(V3d_View) aView3d = aView->getViewPort()->getView();
+ if ( !aView3d.IsNull() ) {
+ myAISContext->MoveTo(myEndPnt.x(), myEndPnt.y(), aView3d);
+ }
+ }
+
if (aHasShift && myMultiSelectionEnabled)
myAISContext->ShiftSelect();
else
return;
emit deselection();
+
+ if ( !isPreselectionEnabled() ) {
+ Handle(V3d_View) aView3d = aView->getViewPort()->getView();
+ if ( !aView3d.IsNull() ) {
+ myAISContext->MoveTo(myCurPnt.x(), myCurPnt.y(), aView3d);
+ }
+ }
+
myAISContext->Select();
emit selectionChanged();
}
/*!
- Sets selection enabled status
+ \return true if preselection is enabled
+*/
+bool OCCViewer_Viewer::isPreselectionEnabled() const
+{
+ return myPreselectionEnabled;
+}
+
+/*!
+ Enables/disables preselection
+ \param isEnabled - new status
+*/
+void OCCViewer_Viewer::enablePreselection(bool isEnabled)
+{
+ myPreselectionEnabled = isEnabled;
+
+ if ( !myViewManager )
+ return;
+
+ QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+ for ( int i = 0; i < (int)wins.count(); i++ )
+ {
+ OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+ if ( win ) {
+ win->enablePreselection( isEnabled );
+ }
+ }
+}
+
+/*!
+ \return true if selection is enabled
+*/
+bool OCCViewer_Viewer::isSelectionEnabled() const
+{
+ return mySelectionEnabled;
+}
+
+/*!
+ Enables/disables selection
\param isEnabled - new status
*/
void OCCViewer_Viewer::enableSelection(bool isEnabled)
{
mySelectionEnabled = isEnabled;
+
//!! To be done for view windows
if ( !myViewManager )
return;
for ( int i = 0; i < (int)wins.count(); i++ )
{
OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
- if ( win )
+ if ( win ) {
win->updateEnabledDrawMode();
+ win->enableSelection( isEnabled );
+ }
}
}
Unhilights all objects in viewer
\param updateviewer - update current viewer
*/
-bool OCCViewer_Viewer::unHighlightAll( bool updateviewer )
+bool OCCViewer_Viewer::unHighlightAll( bool updateviewer, bool unselect )
{
- if ( myAISContext->HasOpenedContext() )
- myAISContext->ClearSelected( updateviewer );
- else
- myAISContext->ClearCurrents( updateviewer );
+ if ( myAISContext->HasOpenedContext() ) {
+ if ( unselect ) {
+ myAISContext->ClearSelected( updateviewer );
+ } else {
+ myAISContext->UnhilightSelected( updateviewer );
+ }
+ } else {
+ if ( unselect ) {
+ myAISContext->ClearCurrents( updateviewer );
+ } else {
+ myAISContext->UnhilightCurrents( updateviewer );
+ }
+ }
+
return false;
}
myTrihedron->SetSize(myTrihedronSize);
}
}
+
+/*!
+ Set number of isolines
+ \param u - u-isolines (first parametric co-ordinate)
+ \param v - v-isolines (second parametric co-ordinate)
+*/
+void OCCViewer_Viewer::setSelectionOptions( bool isPreselectionEnabled, bool isSelectionEnabled )
+{
+ myPreselectionEnabled = isPreselectionEnabled;
+ mySelectionEnabled = isSelectionEnabled;
+}
int zoomingStyle() const;
void setZoomingStyle( const int );
+ void enablePreselection(bool isEnabled);
+ bool isPreselectionEnabled() const;
+
void enableSelection(bool isEnabled);
- bool isSelectionEnabled() const { return mySelectionEnabled; }
+ bool isSelectionEnabled() const;
+
+ void setSelectionOptions( bool, bool );
void enableMultiselection(bool isEnable);
bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; }
/* Selection management */
bool highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true );
- bool unHighlightAll( bool=true );
+ bool unHighlightAll( bool=true, bool=true );
bool isInViewer( const Handle(AIS_InteractiveObject)&, bool=false );
bool isVisible( const Handle(AIS_InteractiveObject)& );
int myInteractionStyle;
int myZoomingStyle;
+ bool myPreselectionEnabled;
bool mySelectionEnabled;
bool myMultiSelectionEnabled;
bool myIsRelative;
int myTopLayerId;
//QColor myBgColor;
- QPoint myStartPnt, myEndPnt;
+ QPoint myStartPnt, myEndPnt, myCurPnt;
bool myShowStaticTrihedron;
my2dMode = No2dMode;
myInteractionStyle = SUIT_ViewModel::STANDARD;
+ myPreselectionEnabled = true;
+ mySelectionEnabled = true;
+
clearViewAspects();
connect(aAction, SIGNAL(triggered()), this, SLOT(onAxialScale()));
toolMgr()->registerAction( aAction, AxialScaleId );
+ // Enable/disable preselection
+ aAction = new QtxAction(tr("MNU_ENABLE_PRESELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PRESELECTION" ) ),
+ tr( "MNU_ENABLE_PRESELECTION" ), 0, this);
+ aAction->setStatusTip(tr("DSC_ENABLE_PRESELECTION"));
+ aAction->setCheckable(true);
+ connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchPreselection(bool)));
+ toolMgr()->registerAction( aAction, SwitchPreselectionId );
+
+ // Enable/disable selection
+ aAction = new QtxAction(tr("MNU_ENABLE_SELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SELECTION" ) ),
+ tr( "MNU_ENABLE_SELECTION" ), 0, this);
+ aAction->setStatusTip(tr("DSC_ENABLE_SELECTION"));
+ aAction->setCheckable(true);
+ connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchSelection(bool)));
+ toolMgr()->registerAction( aAction, SwitchSelectionId );
+
// Graduated axes
aAction = new QtxAction(tr("MNU_GRADUATED_AXES"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_GRADUATED_AXES" ) ),
tr( "MNU_GRADUATED_AXES" ), 0, this);
#if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
toolMgr()->append( SwitchZoomingStyleId, tid );
#endif
+ toolMgr()->append( SwitchPreselectionId, tid );
+ toolMgr()->append( SwitchSelectionId, tid );
if( myModel->trihedronActivated() )
toolMgr()->append( TrihedronShowId, tid );
myModel->toggleTrihedron();
}
+/*!
+ \brief Toggles preselection (highlighting) on/off
+*/
+void OCCViewer_ViewWindow::onSwitchPreselection( bool on )
+{
+ myPreselectionEnabled = on;
+ myModel->setSelectionOptions( isPreselectionEnabled(), myModel->isSelectionEnabled() );
+
+ // unhighlight all highlighted objects
+ /*if ( !on ) {
+ myModel->unHighlightAll( true, false );
+ }*/
+
+ // update action state if method is called outside
+ QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchPreselectionId ) );
+ if ( a && a->isChecked() != on ) {
+ a->setChecked( on );
+ }
+}
+
+/*!
+ \brief Toggles selection on/off
+*/
+void OCCViewer_ViewWindow::onSwitchSelection( bool on )
+{
+ mySelectionEnabled = on;
+ myModel->setSelectionOptions( myModel->isPreselectionEnabled(), isSelectionEnabled() );
+
+ // update action state if method is called outside
+
+ // preselection
+ QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchPreselectionId ) );
+ if ( a ) {
+ a->setEnabled( on );
+ }
+
+ // selection
+ a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchSelectionId ) );
+ if ( a && a->isChecked() != on ) {
+ a->setChecked( on );
+ }
+}
+
/*!
\brief Switches "keyboard free" interaction style on/off
*/
blockSignals( blocked );
}
+
+/*!
+ \brief Indicates whether preselection is enabled
+ \return true if preselection is enabled
+*/
+bool OCCViewer_ViewWindow::isPreselectionEnabled() const
+{
+ return myPreselectionEnabled;
+}
+
+/*!
+ \brief Enables/disables preselection
+ \param theIsToEnable if true - preselection will be enabled
+*/
+void OCCViewer_ViewWindow::enablePreselection( bool theIsToEnable )
+{
+ onSwitchPreselection( theIsToEnable );
+}
+
+/*!
+ \brief Indicates whether selection is enabled
+ \return true if selection is enabled
+*/
+bool OCCViewer_ViewWindow::isSelectionEnabled() const
+{
+ return mySelectionEnabled;
+}
+
+/*!
+ \brief Enables/disables selection
+ \param theIsToEnable if true - selection will be enabled
+*/
+void OCCViewer_ViewWindow::enableSelection( bool theIsToEnable )
+{
+ onSwitchSelection( theIsToEnable );
+}
FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId,
ResetId, CloneId, ClippingId, MemId, RestoreId,
TrihedronShowId, AxialScaleId, GraduatedAxesId, AmbientId,
- SwitchInteractionStyleId, SwitchZoomingStyleId, MaximizedId, SynchronizeId, UserId };
+ SwitchInteractionStyleId, SwitchZoomingStyleId,
+ SwitchPreselectionId, SwitchSelectionId,
+ MaximizedId, SynchronizeId,
+ UserId };
enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE,
PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
virtual int zoomingStyle() const;
virtual void setZoomingStyle( const int );
+
+ virtual bool isPreselectionEnabled() const;
+ virtual void enablePreselection( bool );
+ virtual bool isSelectionEnabled() const;
+ virtual void enableSelection( bool );
void setTransformEnabled( const OperationType, const bool );
bool transformEnabled( const OperationType ) const;
virtual void setRestoreFlag();
virtual void onSwitchInteractionStyle( bool on );
virtual void onSwitchZoomingStyle( bool on );
+ virtual void onSwitchPreselection( bool on );
+ virtual void onSwitchSelection( bool on );
virtual void activateSetRotationGravity();
virtual void activateSetRotationSelected( double theX, double theY, double theZ );
QtxRectRubberBand* myRectBand; //!< selection rectangle rubber band
+ bool mySelectionEnabled;
+ bool myPreselectionEnabled;
int myInteractionStyle;
typedef QMap<OperationType, bool> MapOfTransformStatus;
<source>ICON_OCCVIEWER_MINIMIZE</source>
<translation>occ_view_minimized.png</translation>
</message>
+ <message>
+ <source>ICON_OCCVIEWER_PRESELECTION</source>
+ <translation>occ_view_preselection.png</translation>
+ </message>
+ <message>
+ <source>ICON_OCCVIEWER_SELECTION</source>
+ <translation>occ_view_selection.png</translation>
+ </message>
</context>
</TS>
<source>MNU_ZOOMING_STYLE_SWITCH</source>
<translation>Zooming style switch</translation>
</message>
+ <message>
+ <source>DSC_ENABLE_PRESELECTION</source>
+ <translation>Enable/disable preselection</translation>
+ </message>
+ <message>
+ <source>MNU_ENABLE_PRESELECTION</source>
+ <translation>Enable/disable preselection</translation>
+ </message>
+ <message>
+ <source>DSC_ENABLE_SELECTION</source>
+ <translation>Enable/disable selection</translation>
+ </message>
+ <message>
+ <source>MNU_ENABLE_SELECTION</source>
+ <translation>Enable/disable selection</translation>
+ </message>
<message>
<source>OCC_IMAGE_FILES</source>
<translation>Images Files (*.bmp *.png *.jpg *.jpeg *.eps *.ps)</translation>
<source>MNU_ZOOMING_STYLE_SWITCH</source>
<translation>Changer le style de zoom</translation>
</message>
+ <message>
+ <source>DSC_ENABLE_PRESELECTION</source>
+ <translation type="unfinished">Enable/disable preselection</translation>
+ </message>
+ <message>
+ <source>MNU_ENABLE_PRESELECTION</source>
+ <translation type="unfinished">Enable/disable preselection</translation>
+ </message>
+ <message>
+ <source>DSC_ENABLE_SELECTION</source>
+ <translation type="unfinished">Enable/disable selection</translation>
+ </message>
+ <message>
+ <source>MNU_ENABLE_SELECTION</source>
+ <translation type="unfinished">Enable/disable selection</translation>
+ </message>
<message>
<source>OCC_IMAGE_FILES</source>
<translation>Fichiers images (*.bmp *.png *.jpg *.jpeg *.eps *.ps)</translation>