#include "OCCViewer_Utilities.h"
+#include "OCCViewer_ViewWidget.h"
#include <OCCViewer_ViewFrame.h>
#include <OCCViewer_ViewModel.h>
break;
}
}
+
+void OCCViewer_Utilities::setViewWidget2DMode( OCCViewer_ViewWidget* theViewWidget,
+ const OCCViewer_ViewWidget::Mode2dType& theMode )
+{
+ if ( !theViewWidget )
+ return;
+
+ // set a view mode
+ theViewWidget->set2dMode( theMode );
+ bool is2dMode = theMode != OCCViewer_ViewWindow::No2dMode;
+
+ // enable/disable view actions
+ QList<OCCViewer_ViewWidget::ButtonsType> aNo2dActions;
+ aNo2dActions << OCCViewer_ViewWidget::RotationId
+ << OCCViewer_ViewWidget::FrontId
+ << OCCViewer_ViewWidget::BackId
+ << OCCViewer_ViewWidget::TopId
+ << OCCViewer_ViewWidget::BottomId
+ << OCCViewer_ViewWidget::LeftId
+ << OCCViewer_ViewWidget::RightId;
+
+ QAction* anAction;
+ for ( int i = 0, aNb = aNo2dActions.size(); i < aNb; i++ ) {
+ anAction = theViewWidget->action( aNo2dActions[i] );
+ if ( anAction )
+ anAction->setVisible( !is2dMode );
+ }
+
+ // change view position
+ switch ( theMode ) {
+ case OCCViewer_ViewWindow::XYPlane:
+ theViewWidget->onTopView();
+ break;
+ case OCCViewer_ViewWindow::XZPlane:
+ theViewWidget->onLeftView();
+ break;
+ case OCCViewer_ViewWindow::YZPlane:
+ theViewWidget->onFrontView();
+ break;
+ }
+}
#include "CurveCreator_Macro.hxx"
#include <OCCViewer_ViewWindow.h>
+#include "OCCViewer_ViewWidget.h"
class OCCViewer_Viewer;
static void setViewer2DMode( OCCViewer_Viewer* theViewer,
const OCCViewer_ViewWindow::Mode2dType& theMode );
+
+ /*!
+ * Set 2D mode for the view widget. Hide or show 3D actions.
+ * \param theViewWidget an OCC view widget
+ * \param theMode OCC view window mode
+ */
+ static void setViewWidget2DMode( OCCViewer_ViewWidget* theViewWidget,
+ const OCCViewer_ViewWidget::Mode2dType& theMode );
};
#endif
"................................"};
// ---------------- OCC view widget --------
-OCCViewer_ViewWidget::OCCViewer_ViewWidget(QWidget* parent)
- : QFrame(parent), myShowTrihedron(true)
+OCCViewer_ViewWidget::OCCViewer_ViewWidget(QWidget* parent, const bool isUseMultiAction)
+ : QFrame(parent), myShowTrihedron(true), myUseMultiAction(isUseMultiAction)
{
setObjectName("OCC_view_widget");
mySelectedPoint = gp_Pnt(0.,0.,0.);
myToolBar = new QToolBar(aBtnBox);
aBtnLay->addWidget(myToolBar);
- myZoomBtns = new QtxMultiAction(aBtnBox);
- myZoomBtns->setObjectName("zoomBtn");
- myToolBar->addAction(myZoomBtns);
- myPanBtns = new QtxMultiAction(aBtnBox);
- myPanBtns->setObjectName("panBtn");
- myToolBar->addAction(myPanBtns);
- myProjBtns = new QtxMultiAction(aBtnBox);
- myProjBtns->setObjectName("projectionBtn");
- myToolBar->addAction(myProjBtns);
-
+ if (myUseMultiAction) {
+ myZoomBtns = new QtxMultiAction(aBtnBox);
+ myZoomBtns->setObjectName("zoomBtn");
+ myToolBar->addAction(myZoomBtns);
+ myPanBtns = new QtxMultiAction(aBtnBox);
+ myPanBtns->setObjectName("panBtn");
+ myToolBar->addAction(myPanBtns);
+ myProjBtns = new QtxMultiAction(aBtnBox);
+ myProjBtns->setObjectName("projectionBtn");
+ myToolBar->addAction(myProjBtns);
+ }
// Rotation
aBtnLay->addStretch(1);
anAnalLay->addWidget(aBtnBox, 0, 0, 1, 2);
createActions();
myButsMap[TrihId]->setChecked(false);
onTrihChanged();
+
+ my2dMode = No2dMode;
}
OCCViewer_ViewWidget::~OCCViewer_ViewWidget()
myToolBar->addAction(aAction);
myButsMap[ TrihId ] = aAction;
- myZoomBtns->insertAction(myButsMap[ FitAllId ]);
- myZoomBtns->insertAction(myButsMap[ FitRectId ]);
- myZoomBtns->insertAction(myButsMap[ ZoomId ]);
+ if (myUseMultiAction) {
+ myZoomBtns->insertAction(myButsMap[ FitAllId ]);
+ myZoomBtns->insertAction(myButsMap[ FitRectId ]);
+ myZoomBtns->insertAction(myButsMap[ ZoomId ]);
- myPanBtns->insertAction(myButsMap[ PanId ]);
- myPanBtns->insertAction(myButsMap[ GlobalPanId ]);
+ myPanBtns->insertAction(myButsMap[ PanId ]);
+ myPanBtns->insertAction(myButsMap[ GlobalPanId ]);
- myProjBtns->insertAction(myButsMap[ FrontId ]);
- myProjBtns->insertAction(myButsMap[ BackId ]);
- myProjBtns->insertAction(myButsMap[ TopId ]);
- myProjBtns->insertAction(myButsMap[ BottomId ]);
- myProjBtns->insertAction(myButsMap[ LeftId ]);
- myProjBtns->insertAction(myButsMap[ RightId ]);
+ myProjBtns->insertAction(myButsMap[ FrontId ]);
+ myProjBtns->insertAction(myButsMap[ BackId ]);
+ myProjBtns->insertAction(myButsMap[ TopId ]);
+ myProjBtns->insertAction(myButsMap[ BottomId ]);
+ myProjBtns->insertAction(myButsMap[ LeftId ]);
+ myProjBtns->insertAction(myButsMap[ RightId ]);
+ }
+ else {
+ myToolBar->addAction(myButsMap[ FitAllId ]);
+ myToolBar->addAction(myButsMap[ FitRectId ]);
+ myToolBar->addAction(myButsMap[ ZoomId ]);
+
+ myToolBar->addAction(myButsMap[ PanId ]);
+ myToolBar->addAction(myButsMap[ GlobalPanId ]);
+
+ myToolBar->addAction(myButsMap[ FrontId ]);
+ myToolBar->addAction(myButsMap[ BackId ]);
+ myToolBar->addAction(myButsMap[ TopId ]);
+ myToolBar->addAction(myButsMap[ BottomId ]);
+ myToolBar->addAction(myButsMap[ LeftId ]);
+ myToolBar->addAction(myButsMap[ RightId ]);
+ }
}
/*!
return aRes;
}
+void OCCViewer_ViewWidget::set2dMode(OCCViewer_ViewWidget::Mode2dType theType)
+{
+ my2dMode = theType;
+}
+
+QAction* OCCViewer_ViewWidget::action( const ButtonsType& theId )
+{
+ return myButsMap.contains( theId ) ? myButsMap[theId] : 0;
+}
+
void OCCViewer_ViewWidget::onActivated()
{
if(!sender() || !sender()->inherits("QtxAction"))
(theEvent->button() == SUIT_ViewModel::myButtonMap[SUIT_ViewModel::STANDARD][SUIT_ViewModel::PAN]))
aOp = PANVIEW;
else if((theEvent->modifiers() == SUIT_ViewModel::myStateMap[SUIT_ViewModel::STANDARD][SUIT_ViewModel::ROTATE]) &&
- (theEvent->button() == SUIT_ViewModel::myButtonMap[SUIT_ViewModel::STANDARD][SUIT_ViewModel::ROTATE]))
+ (theEvent->button() == SUIT_ViewModel::myButtonMap[SUIT_ViewModel::STANDARD][SUIT_ViewModel::ROTATE]) &&
+ (my2dMode == No2dMode))
aOp = ROTATE;
return aOp;
Q_OBJECT
public:
- OCCViewer_ViewWidget(QWidget* parent);
+ typedef enum { FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId, TrihId,
+ FrontId, BackId, TopId, BottomId, LeftId, RightId, None } ButtonsType;
+
+ OCCViewer_ViewWidget(QWidget* parent, const bool isUseMultiAction = true);
~OCCViewer_ViewWidget();
OCCViewer_ViewPort3d* getViewPort();
void Display(const TopoDS_Shape shape, const bool theShaded,
const QColor& shapeColor);
-private slots:
+ enum Mode2dType { No2dMode, XYPlane, XZPlane, YZPlane};
+
+ void set2dMode( Mode2dType );
+ Mode2dType get2dMode() const { return my2dMode; }
+
+ QAction* action( const ButtonsType& theId );
+
+public slots:
void onActivated();
void onTrihChanged();
void onFrontView();
bool setTransformRequested (OperationType op);
void clearViewer(const bool theUpdate = true);
- typedef enum { FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId, TrihId,
- FrontId, BackId, TopId, BottomId, LeftId, RightId, None } ButtonsType;
typedef QMap<ButtonsType, QtxAction*> ActionsMap;
private:
OCCViewer_ViewWindow::RotationPointType myCurrPointType;
gp_Pnt mySelectedPoint;
bool myShowTrihedron;
+
+ Mode2dType my2dMode;
+ bool myUseMultiAction;
};
#endif
#include <OCCViewer_ViewWidget.h>
#include <OCCViewer_ViewPort3d.h>
+#include <OCCViewer_Utilities.h>
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
myEditorWidget = new CurveCreator_Widget( this, NULL );
addWidget( myEditorWidget, 3 );
- myViewWidget = new OCCViewer_ViewWidget( this );
+ myViewWidget = new OCCViewer_ViewWidget( this, false );
OCCViewer_ViewPort3d* aViewPort = myViewWidget->getViewPort();
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
if ( aResMgr )
aViewPort->setBackground( aResMgr->backgroundValue( "OCCViewer", "background",
Qtx::BackgroundData( Qt::black ) ) );
+ OCCViewer_Utilities::setViewWidget2DMode( myViewWidget, OCCViewer_ViewWidget::XZPlane );
addWidget( myViewWidget, 4 );
//myAddElementBox = new QGroupBox( tr( "ADD_ELEMENT" ), this );