--- /dev/null
+
+#include "OCCViewer_ViewFrame.h"
+#include "OCCViewer_ViewWindow.h"
+#include "OCCViewer_ViewModel.h"
+
+#include <SUIT_ViewManager.h>
+
+#include <QFrame>
+#include <QLayout>
+
+
+OCCViewer_ViewFrame::OCCViewer_ViewFrame(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel)
+ : OCCViewer_ViewWindow( theDesktop, theModel )
+{
+ QFrame* centralFrame = new QFrame( this );
+ setCentralWidget( centralFrame );
+
+ OCCViewer_ViewWindow* view0 = theModel->createSubWindow();
+ view0->setParent( centralFrame );
+ myViews.append( view0 ); // MAIN_VIEW
+
+ myLayout = new QGridLayout( centralFrame );
+ myLayout->setMargin( 0 );
+ myLayout->setSpacing( 1 );
+
+ myLayout->addWidget( view0, 1, 1 );
+ connectViewSignals(view0);
+}
+
+OCCViewer_ViewFrame::~OCCViewer_ViewFrame()
+{
+}
+
+//**************************************************************************************
+OCCViewer_ViewWindow* OCCViewer_ViewFrame::getView( const int i ) const
+{
+ return ( i < myViews.count() ) ? myViews.at( i ) : 0 ;
+}
+
+//**************************************************************************************
+void OCCViewer_ViewFrame::setViewManager( SUIT_ViewManager* theMgr )
+{
+ OCCViewer_ViewWindow::setViewManager(theMgr);
+ foreach (OCCViewer_ViewWindow* aView, myViews) {
+ aView->setViewManager(theMgr);
+ }
+}
+
+
+//**************************************************************************************
+void OCCViewer_ViewFrame::onMaximizedView( OCCViewer_ViewWindow* theView, bool isMaximized)
+{
+ if (isMaximized) {
+ if (myViews.count() <= 1)
+ return;
+
+ myLayout->setColumnStretch(0 , 0);
+ myLayout->setColumnStretch(1, 0);
+ int i = 0;
+ OCCViewer_ViewWindow* aView = 0;
+ for ( i = BOTTOM_RIGHT; i <= TOP_RIGHT; i++) {
+ aView = myViews.at(i);
+ if (aView != theView)
+ aView->hide();
+ }
+ } else {
+
+ OCCViewer_Viewer* aModel = dynamic_cast<OCCViewer_Viewer*>(myManager->getViewModel());
+ if (!aModel) return;
+
+ myLayout->setColumnStretch(0 , 10);
+ myLayout->setColumnStretch(1, 10);
+
+ int i = 0;
+ if (myViews.count() == 1) {
+ QColor aColor = myViews.at( MAIN_VIEW )->backgroundColor();
+ OCCViewer_ViewWindow* view = 0;
+ for ( i = BOTTOM_LEFT; i <= TOP_RIGHT; i++) {
+ view = aModel->createSubWindow();
+ view->set2dMode( (Mode2dType) i );
+ view->setParent( centralWidget() );
+ view->setViewManager(myManager);
+ myViews.append( view );
+ aModel->initView(view);
+ view->setMaximized(false, false);
+ connectViewSignals(view);
+ view->setBackgroundColor(aColor);
+ }
+ myLayout->addWidget( myViews.at(BOTTOM_LEFT), 1, 0 );
+ myLayout->addWidget( myViews.at(TOP_LEFT), 0, 0 );
+ myLayout->addWidget( myViews.at(TOP_RIGHT), 0, 1 );
+ }
+ for ( i = BOTTOM_RIGHT; i <= TOP_RIGHT; i++)
+ myViews.at(i)->show();
+ }
+ myLayout->invalidate();
+}
+
+OCCViewer_ViewPort3d* OCCViewer_ViewFrame::getViewPort(int theView)
+{
+ return getView(theView)? getView(theView)->getViewPort() : 0;
+}
+
+void OCCViewer_ViewFrame::updateEnabledDrawMode()
+{
+ foreach (OCCViewer_ViewWindow* aView, myViews) {
+ aView->updateEnabledDrawMode();
+ }
+}
+
+void OCCViewer_ViewFrame::setCuttingPlane( bool on, const double x , const double y , const double z,
+ const double dx, const double dy, const double dz)
+{
+ foreach (OCCViewer_ViewWindow* aView, myViews) {
+ aView->setCuttingPlane(on, x, y, z, dx, dy, dz);
+ }
+}
+
+//**************************************************************************************
+void OCCViewer_ViewFrame::setCuttingPlane( bool on, const gp_Pln thePln )
+{
+ foreach (OCCViewer_ViewWindow* aView, myViews) {
+ aView->setCuttingPlane(on, thePln);
+ }
+}
+
+//**************************************************************************************
+void OCCViewer_ViewFrame::setInteractionStyle( const int i )
+{
+ foreach (OCCViewer_ViewWindow* aView, myViews) {
+ aView->setInteractionStyle(i);
+ }
+}
+
+
+//**************************************************************************************
+void OCCViewer_ViewFrame::connectViewSignals(OCCViewer_ViewWindow* theView)
+{
+ connect( theView, SIGNAL( maximized( OCCViewer_ViewWindow*, bool ) ),
+ this, SLOT( onMaximizedView( OCCViewer_ViewWindow*, bool ) ) );
+
+ connect( theView, SIGNAL( wheeling(SUIT_ViewWindow*, QWheelEvent*) ),
+ this, SIGNAL( wheeling(SUIT_ViewWindow*, QWheelEvent*) ) );
+
+ connect( theView, SIGNAL( keyReleased(SUIT_ViewWindow*, QKeyEvent*) ),
+ this, SIGNAL( keyReleased(SUIT_ViewWindow*, QKeyEvent*) ) );
+ connect( theView, SIGNAL( keyPressed(SUIT_ViewWindow*, QKeyEvent*) ),
+ this, SIGNAL( keyPressed(SUIT_ViewWindow*, QKeyEvent*) ) );
+
+ connect( theView, SIGNAL( mouseDoubleClicked(SUIT_ViewWindow*, QMouseEvent*) ),
+ this, SIGNAL( mouseDoubleClicked(SUIT_ViewWindow*, QMouseEvent*) ) );
+ connect( theView, SIGNAL( mousePressed(SUIT_ViewWindow*, QMouseEvent*) ),
+ this, SIGNAL( mousePressed(SUIT_ViewWindow*, QMouseEvent*) ) );
+ connect( theView, SIGNAL( mouseReleased(SUIT_ViewWindow*, QMouseEvent*) ),
+ this, SIGNAL( mouseReleased(SUIT_ViewWindow*, QMouseEvent*) ) );
+ connect( theView, SIGNAL( mouseMoving(SUIT_ViewWindow*, QMouseEvent*) ),
+ this, SIGNAL( mouseMoving(SUIT_ViewWindow*, QMouseEvent*) ) );
+
+ connect( theView, SIGNAL( contextMenuRequested(QContextMenuEvent*) ),
+ this, SIGNAL( contextMenuRequested(QContextMenuEvent*) ) );
+}
+
+void OCCViewer_ViewFrame::setBackgroundColor( const QColor& theColor)
+{
+ foreach (OCCViewer_ViewWindow* aView, myViews) {
+ aView->setBackgroundColor(theColor);
+ }
+}
+
+
+void OCCViewer_ViewFrame::onViewFitAll()
+{
+ foreach (OCCViewer_ViewWindow* aView, myViews) {
+ aView->onViewFitAll();
+ }
+}
+
+void OCCViewer_ViewFrame::onFitAll()
+{
+ foreach (OCCViewer_ViewWindow* aView, myViews) {
+ aView->onFitAll();
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef OCCVIEWER_VIEWFRAME_H
+#define OCCVIEWER_VIEWFRAME_H
+
+#include "OCCViewer.h"
+#include "OCCViewer_ViewWindow.h"
+
+#include <gp_Pln.hxx>
+
+class SUIT_Desktop;
+class OCCViewer_Viewer;
+class QGridLayout;
+
+class OCCVIEWER_EXPORT OCCViewer_ViewFrame : public OCCViewer_ViewWindow
+{
+ Q_OBJECT
+public:
+ enum { MAIN_VIEW, BOTTOM_RIGHT=MAIN_VIEW, BOTTOM_LEFT, TOP_LEFT, TOP_RIGHT };
+
+ OCCViewer_ViewFrame(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel);
+ virtual ~OCCViewer_ViewFrame();
+
+ OCCViewer_ViewWindow* getView( const int ) const;
+
+ virtual OCCViewer_ViewPort3d* getViewPort() { return 0; }
+ OCCViewer_ViewPort3d* getViewPort(int theView);
+
+ virtual void performRestoring( const viewAspect& theAspect) { getView(MAIN_VIEW)->performRestoring(theAspect); }
+ virtual void initLayout() {}
+
+ virtual void updateEnabledDrawMode();
+ virtual void setCuttingPlane( bool on, const double x = 0 , const double y = 0 , const double z = 0,
+ const double dx = 0, const double dy = 0, const double dz = 1);
+
+ virtual void setCuttingPlane( bool on, const gp_Pln thePln );
+
+ virtual bool isCuttingPlane() { return getView(MAIN_VIEW)->isCuttingPlane(); }
+
+ virtual QString getVisualParameters() { return getView(MAIN_VIEW)->getVisualParameters(); }
+ virtual void setVisualParameters( const QString& parameters ) { getView(MAIN_VIEW)->setVisualParameters(parameters); }
+
+ virtual void initSketchers() { getView(MAIN_VIEW)->initSketchers(); }
+ virtual OCCViewer_ViewSketcher* getSketcher( const int i) { return getView(MAIN_VIEW)->getSketcher(i); }
+ virtual void activateSketching( int i ) { getView(MAIN_VIEW)->activateSketching(i); }
+
+ virtual int interactionStyle() const { return getView(MAIN_VIEW)->interactionStyle(); }
+ virtual void setInteractionStyle( const int i );
+
+ virtual void setViewManager( SUIT_ViewManager* );
+
+ virtual bool eventFilter(QObject* watched, QEvent* e) { return SUIT_ViewWindow::eventFilter(watched, e); }
+
+ virtual QColor backgroundColor() const { return getView(MAIN_VIEW)->backgroundColor(); }
+ virtual void setBackgroundColor( const QColor& );
+
+public slots:
+ virtual void onFrontView() { getView(MAIN_VIEW)->onFrontView(); }
+ virtual void onViewFitAll();
+ virtual void onBackView() { getView(MAIN_VIEW)->onBackView(); }
+ virtual void onTopView() { getView(MAIN_VIEW)->onTopView(); }
+ virtual void onBottomView() { getView(MAIN_VIEW)->onBottomView(); }
+ virtual void onLeftView() { getView(MAIN_VIEW)->onLeftView(); }
+ virtual void onRightView() { getView(MAIN_VIEW)->onRightView(); }
+ virtual void onResetView() { getView(MAIN_VIEW)->onResetView(); }
+ virtual void onFitAll();
+ virtual void activateZoom() {}
+ virtual void activateWindowFit() {}
+ virtual void activateRotation() {}
+ virtual void activatePanning() {}
+ virtual void activateGlobalPanning() {}
+ virtual void onSetRotationPoint( bool on ) {}
+ virtual void onAxialScale() {}
+ virtual void onAmbientToogle() {}
+ virtual void onMemorizeView() {}
+ virtual void onRestoreView() {}
+ virtual void onSwitchInteractionStyle( bool on ) {}
+
+ virtual void activateSetRotationGravity() {}
+ virtual void activateSetRotationSelected( double theX, double theY, double theZ ) {}
+ virtual void activateStartPointSelection() {}
+ virtual void updateGravityCoords() {}
+
+ void onMaximizedView( OCCViewer_ViewWindow*, bool );
+
+ virtual void onDumpView() { getView(MAIN_VIEW)->onDumpView(); }
+
+private:
+ void connectViewSignals(OCCViewer_ViewWindow* theView);
+
+
+ QList<OCCViewer_ViewWindow*> myViews;
+ QGridLayout* myLayout;
+};
+
+#endif