From: vsr Date: Tue, 23 Nov 2010 11:23:41 +0000 (+0000) Subject: Merge from V6_1_BR (TRIPOLI development) X-Git-Tag: V6_2_0a1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=baeee6f27bc5742a086f5e8d968794225a5cbd93;p=modules%2Fgui.git Merge from V6_1_BR (TRIPOLI development) --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index b1b027d92..63252a822 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -110,6 +110,7 @@ #ifndef DISABLE_OCCVIEWER #include + #include #ifndef DISABLE_SALOMEOBJECT #include #else @@ -1343,7 +1344,16 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType #else vm = new OCCViewer_Viewer( true, resMgr->booleanValue( "OCCViewer", "static_trihedron", true ) ); #endif - vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) ); + vm->setBackgroundColor( OCCViewer_ViewFrame::TOP_LEFT, + resMgr->colorValue( "OCCViewer", "xz_background", vm->backgroundColor() ) ); + vm->setBackgroundColor( OCCViewer_ViewFrame::TOP_RIGHT, + resMgr->colorValue( "OCCViewer", "yz_background", vm->backgroundColor() ) ); + + vm->setBackgroundColor( OCCViewer_ViewFrame::BOTTOM_LEFT, + resMgr->colorValue( "OCCViewer", "xy_background", vm->backgroundColor() ) ); + vm->setBackgroundColor( OCCViewer_ViewFrame::BOTTOM_RIGHT, + resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) ); + vm->setTrihedronSize( resMgr->doubleValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) ); int u( 1 ), v( 1 ); vm->isos( u, v ); @@ -1902,22 +1912,32 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->setItemProperty( "min", 1.0E-06, occTS ); pref->setItemProperty( "max", 1000, occTS ); + int occStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), occGroup, + LightApp_Preferences::Selector, "OCCViewer", "navigation_mode" ); + int isoU = pref->addPreference( tr( "PREF_ISOS_U" ), occGroup, LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_u" ); pref->setItemProperty( "min", 0, isoU ); pref->setItemProperty( "max", 100000, isoU ); - pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup, - LightApp_Preferences::Color, "OCCViewer", "background" ); - int isoV = pref->addPreference( tr( "PREF_ISOS_V" ), occGroup, LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_v" ); pref->setItemProperty( "min", 0, isoV ); pref->setItemProperty( "max", 100000, isoV ); - int occStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), occGroup, - LightApp_Preferences::Selector, "OCCViewer", "navigation_mode" ); + //pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup, + // LightApp_Preferences::Color, "OCCViewer", "background" ); + pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), occGroup, + LightApp_Preferences::Color, "OCCViewer", "xz_background" ); + pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), occGroup, + LightApp_Preferences::Color, "OCCViewer", "yz_background" ); + + pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), occGroup, + LightApp_Preferences::Color, "OCCViewer", "xy_background" ); + pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), occGroup, + LightApp_Preferences::Color, "OCCViewer", "background" ); + QStringList aStyleModeList; aStyleModeList.append( tr("PREF_STANDARD_STYLE") ); aStyleModeList.append( tr("PREF_KEYFREE_STYLE") ); diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index eceb49113..2da459c32 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -114,7 +114,10 @@
- + + + + diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index 2c9178de5..9e799934b 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -434,6 +434,22 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASPREF_VIEWER_BACKGROUND Background color + + PREF_XYVIEWER_BACKGROUND + XY View background color + + + PREF_XZVIEWER_BACKGROUND + XZ View background color + + + PREF_YZVIEWER_BACKGROUND + YZ View background color + + + PREF_3DVIEWER_BACKGROUND + 3D View background color + PREF_FONT Font diff --git a/src/OCCViewer/Makefile.am b/src/OCCViewer/Makefile.am index 65d59fc7e..1a5e49497 100755 --- a/src/OCCViewer/Makefile.am +++ b/src/OCCViewer/Makefile.am @@ -44,7 +44,8 @@ salomeinclude_HEADERS = \ OCCViewer_AxialScaleDlg.h \ OCCViewer_SetRotationPointDlg.h \ OCCViewer_Trihedron.h \ - OCCViewer_ToolTip.h + OCCViewer_ToolTip.h \ + OCCViewer_ViewFrame.h dist_libOCCViewer_la_SOURCES = \ OCCViewer_AISSelector.cxx \ @@ -60,7 +61,8 @@ dist_libOCCViewer_la_SOURCES = \ OCCViewer_ClippingDlg.cxx \ OCCViewer_AxialScaleDlg.cxx \ OCCViewer_Trihedron.cxx \ - OCCViewer_ToolTip.cxx + OCCViewer_ToolTip.cxx \ + OCCViewer_ViewFrame.cxx MOC_FILES = \ OCCViewer_AISSelector_moc.cxx \ @@ -74,8 +76,9 @@ MOC_FILES = \ OCCViewer_SetRotationPointDlg_moc.cxx \ OCCViewer_ClippingDlg_moc.cxx \ OCCViewer_AxialScaleDlg_moc.cxx \ - OCCViewer_ToolTip_moc.cxx - + OCCViewer_ToolTip_moc.cxx \ + OCCViewer_ViewFrame_moc.cxx + nodist_libOCCViewer_la_SOURCES = $(MOC_FILES) dist_salomeres_DATA = \ @@ -101,7 +104,9 @@ dist_salomeres_DATA = \ resources/occ_view_top.png \ resources/occ_view_triedre.png \ resources/occ_view_zoom.png \ - resources/occ_view_rotation_point.png + resources/occ_view_rotation_point.png \ + resources/occ_view_maximized.png \ + resources/occ_view_minimized.png nodist_salomeres_DATA = \ OCCViewer_images.qm \ diff --git a/src/OCCViewer/OCCViewer_AxialScaleDlg.cxx b/src/OCCViewer/OCCViewer_AxialScaleDlg.cxx index df14c9562..55eed1278 100644 --- a/src/OCCViewer/OCCViewer_AxialScaleDlg.cxx +++ b/src/OCCViewer/OCCViewer_AxialScaleDlg.cxx @@ -39,8 +39,8 @@ \param view - view window \param parent - parent widget */ -OCCViewer_AxialScaleDlg::OCCViewer_AxialScaleDlg( OCCViewer_ViewWindow* view, QWidget* parent ) - : QDialog( parent ), +OCCViewer_AxialScaleDlg::OCCViewer_AxialScaleDlg( OCCViewer_ViewWindow* view ) + : QDialog( view ), myView( view ) { setWindowTitle( tr( "DLG_SCALING" ) ); diff --git a/src/OCCViewer/OCCViewer_AxialScaleDlg.h b/src/OCCViewer/OCCViewer_AxialScaleDlg.h index 17f55f400..3c6cde4c7 100644 --- a/src/OCCViewer/OCCViewer_AxialScaleDlg.h +++ b/src/OCCViewer/OCCViewer_AxialScaleDlg.h @@ -33,7 +33,7 @@ class OCCVIEWER_EXPORT OCCViewer_AxialScaleDlg : public QDialog Q_OBJECT public: - OCCViewer_AxialScaleDlg( OCCViewer_ViewWindow*, QWidget* = 0 ); + OCCViewer_AxialScaleDlg( OCCViewer_ViewWindow* ); ~OCCViewer_AxialScaleDlg(); void Update(); diff --git a/src/OCCViewer/OCCViewer_ClippingDlg.cxx b/src/OCCViewer/OCCViewer_ClippingDlg.cxx index 4fb3b48b0..dab14bd5f 100644 --- a/src/OCCViewer/OCCViewer_ClippingDlg.cxx +++ b/src/OCCViewer/OCCViewer_ClippingDlg.cxx @@ -62,8 +62,8 @@ \param modal - is this dialog modal \param fl - flags */ -OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl ) -: QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), +OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, const char* name, bool modal, Qt::WindowFlags fl ) +: QDialog( view, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), myView( view ) { setObjectName( "OCCViewer_ClippingDlg" ); @@ -266,9 +266,9 @@ void OCCViewer_ClippingDlg::closeEvent( QCloseEvent* e ) erasePreview(); // Set the clipping plane back - Handle(V3d_View) aView3d = myView->getViewPort()->getView(); + /*Handle(V3d_View) aView3d = myView->getViewPort()->getView(); if ( !aView3d.IsNull() && !myClippingPlane.IsNull() ) - aView3d->SetPlaneOn( myClippingPlane ); + aView3d->SetPlaneOn( myClippingPlane );*/ myAction->setChecked( false ); @@ -281,7 +281,7 @@ void OCCViewer_ClippingDlg::closeEvent( QCloseEvent* e ) */ void OCCViewer_ClippingDlg::showEvent( QShowEvent* e ) { - ReserveClippingPlane(); + //ReserveClippingPlane(); QDialog::showEvent( e ); onPreview( PreviewChB->isChecked() ); @@ -306,10 +306,10 @@ void OCCViewer_ClippingDlg::ClickOnClose() erasePreview(); // Set the clipping plane back - Handle(V3d_View) aView3d = myView->getViewPort()->getView(); + /*Handle(V3d_View) aView3d = myView->getViewPort()->getView(); if ( !aView3d.IsNull() && !myClippingPlane.IsNull() ) aView3d->SetPlaneOn( myClippingPlane ); - + */ myAction->setChecked( false ); reject(); @@ -332,7 +332,7 @@ void OCCViewer_ClippingDlg::ClickOnApply() erasePreview(); - ReserveClippingPlane(); + //ReserveClippingPlane(); } /*! @@ -504,7 +504,8 @@ void OCCViewer_ClippingDlg::displayPreview() myPreviewPlane->SetSize( aSize, aSize ); // Deactivate clipping planes - myView->getViewPort()->getView()->SetPlaneOff(); + //myView->getViewPort()->getView()->SetPlaneOff(); + //myView->setPlaneOff(); ic->Display( myPreviewPlane, 1, -1, false ); ic->SetWidth( myPreviewPlane, 10, false ); @@ -575,13 +576,13 @@ bool OCCViewer_ClippingDlg::isValid() */ void OCCViewer_ClippingDlg::ReserveClippingPlane() { - Handle(V3d_View) aView3d = myView->getViewPort()->getView(); + /*Handle(V3d_View) aView3d = myView->getViewPort()->getView(); if ( !aView3d.IsNull() ) { aView3d->InitActivePlanes(); if ( aView3d->MoreActivePlanes() ) myClippingPlane = aView3d->ActivePlane(); - } + }*/ } void OCCViewer_ClippingDlg::onViewShow() diff --git a/src/OCCViewer/OCCViewer_ClippingDlg.h b/src/OCCViewer/OCCViewer_ClippingDlg.h index 8639661b7..2baa05360 100644 --- a/src/OCCViewer/OCCViewer_ClippingDlg.h +++ b/src/OCCViewer/OCCViewer_ClippingDlg.h @@ -50,7 +50,7 @@ class OCCViewer_ClippingDlg : public QDialog Q_OBJECT public: - OCCViewer_ClippingDlg(OCCViewer_ViewWindow* , QWidget* parent = 0, const char* name = 0, bool modal = FALSE, Qt::WindowFlags fl = 0); + OCCViewer_ClippingDlg(OCCViewer_ViewWindow* , const char* name = 0, bool modal = FALSE, Qt::WindowFlags fl = 0); ~OCCViewer_ClippingDlg(); void SetAction( QtxAction* theAction ) { myAction = theAction; } @@ -94,7 +94,7 @@ private : OCCViewer_ViewWindow* myView; Handle(AIS_Plane) myPreviewPlane; - Handle(V3d_Plane) myClippingPlane; + //Handle(V3d_Plane) myClippingPlane; bool myBusy; diff --git a/src/OCCViewer/OCCViewer_SetRotationPointDlg.cxx b/src/OCCViewer/OCCViewer_SetRotationPointDlg.cxx index d5d131014..fefc08a51 100644 --- a/src/OCCViewer/OCCViewer_SetRotationPointDlg.cxx +++ b/src/OCCViewer/OCCViewer_SetRotationPointDlg.cxx @@ -43,8 +43,8 @@ \param modal - is this dialog modal \param fl - flags */ -OCCViewer_SetRotationPointDlg::OCCViewer_SetRotationPointDlg( OCCViewer_ViewWindow* view, QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl ) -: QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), +OCCViewer_SetRotationPointDlg::OCCViewer_SetRotationPointDlg( OCCViewer_ViewWindow* view, const char* name, bool modal, Qt::WindowFlags fl ) +: QDialog( view, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), myView( view ) { setObjectName( "OCCViewer_SetRotationPointDlg" ); diff --git a/src/OCCViewer/OCCViewer_SetRotationPointDlg.h b/src/OCCViewer/OCCViewer_SetRotationPointDlg.h index 83cccad42..31a2a5461 100644 --- a/src/OCCViewer/OCCViewer_SetRotationPointDlg.h +++ b/src/OCCViewer/OCCViewer_SetRotationPointDlg.h @@ -41,7 +41,7 @@ class OCCVIEWER_EXPORT OCCViewer_SetRotationPointDlg : public QDialog Q_OBJECT public: - OCCViewer_SetRotationPointDlg(OCCViewer_ViewWindow* , QWidget* parent = 0, + OCCViewer_SetRotationPointDlg(OCCViewer_ViewWindow* , const char* name = 0, bool modal = FALSE, Qt::WindowFlags fl = 0); ~OCCViewer_SetRotationPointDlg(); diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx new file mode 100644 index 000000000..e0eedf65f --- /dev/null +++ b/src/OCCViewer/OCCViewer_ViewFrame.cxx @@ -0,0 +1,248 @@ +// 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 +// + +#include "OCCViewer_ViewFrame.h" +#include "OCCViewer_ViewWindow.h" +#include "OCCViewer_ViewModel.h" + +#include + +#include +#include +#include + +OCCViewer_ViewFrame::OCCViewer_ViewFrame(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel) + : OCCViewer_ViewWindow( theDesktop, theModel ), myPopupRequestedView(0) +{ + 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(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(aModel->backgroundColor(i)); + } + myLayout->addWidget( myViews.at(BOTTOM_LEFT), 1, 0 ); + myLayout->addWidget( myViews.at(TOP_LEFT), 0, 0 ); + myLayout->addWidget( myViews.at(TOP_RIGHT), 0, 1 ); + } + OCCViewer_ViewWindow* view = 0; + for ( i = BOTTOM_RIGHT; i <= TOP_RIGHT; i++) { + view = myViews.at(i); + view->show(); + QApplication::processEvents(); + if (view != theView) + view->onViewFitAll(); + } + } + 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); + aView->update(); + } +} + +//************************************************************************************** +void OCCViewer_ViewFrame::setCuttingPlane( bool on, const gp_Pln thePln ) +{ + foreach (OCCViewer_ViewWindow* aView, myViews) { + aView->setCuttingPlane(on, thePln); + aView->update(); + } +} + +//************************************************************************************** +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*) ) ); + + // The signal is used to process get/set bacgrounf\d color from popup + connect( theView, SIGNAL( contextMenuRequested(QContextMenuEvent*) ), + this, SLOT( onContextMenuRequested(QContextMenuEvent*) ) ); + + connect( theView, SIGNAL( contextMenuRequested(QContextMenuEvent*) ), + this, SIGNAL( contextMenuRequested(QContextMenuEvent*) ) ); +} + +void OCCViewer_ViewFrame::setBackgroundColor( const QColor& theColor) +{ + if (myPopupRequestedView) + myPopupRequestedView->setBackgroundColor(theColor); + else { + foreach (OCCViewer_ViewWindow* aView, myViews) { + if (aView->isVisible()) + 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(); + } +} + +QColor OCCViewer_ViewFrame::backgroundColor() const +{ + if (myPopupRequestedView) + return myPopupRequestedView->backgroundColor(); + + foreach (OCCViewer_ViewWindow* aView, myViews) { + if (aView->isVisible()) + return aView->backgroundColor(); + } + return getView(MAIN_VIEW)->backgroundColor(); +} + +void OCCViewer_ViewFrame::onContextMenuRequested(QContextMenuEvent*) +{ + myPopupRequestedView = dynamic_cast(sender()); +} + +void OCCViewer_ViewFrame::onDumpView() +{ + if (myPopupRequestedView) { + myPopupRequestedView->onDumpView(); + } + else { + getView(MAIN_VIEW)->onDumpView(); + } +} diff --git a/src/OCCViewer/OCCViewer_ViewFrame.h b/src/OCCViewer/OCCViewer_ViewFrame.h new file mode 100644 index 000000000..19212da77 --- /dev/null +++ b/src/OCCViewer/OCCViewer_ViewFrame.h @@ -0,0 +1,122 @@ +// 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 + +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 getView(MAIN_VIEW)->getViewPort(); } + 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; + 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(); + +private slots: + void onContextMenuRequested(QContextMenuEvent*); + +private: + void connectViewSignals(OCCViewer_ViewWindow* theView); + + + QList myViews; + QGridLayout* myLayout; + + OCCViewer_ViewWindow* myPopupRequestedView; +}; + +#endif diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index caea77326..ebc094f48 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -22,6 +22,7 @@ #include "OCCViewer_ViewModel.h" #include "OCCViewer_ViewWindow.h" +#include "OCCViewer_ViewFrame.h" #include "OCCViewer_VService.h" #include "OCCViewer_ViewPort3d.h" @@ -61,8 +62,8 @@ */ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron, bool DisplayStaticTrihedron ) : SUIT_ViewModel(), - myBgColor( Qt::black ), - myShowStaticTrihedron( DisplayStaticTrihedron ) + myShowStaticTrihedron( DisplayStaticTrihedron ), + myColors(4, Qt::black) { // init CasCade viewers myV3dViewer = OCCViewer_VService::Viewer3d( "", (short*) "Viewer3d", "", 1000., @@ -114,7 +115,7 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron, bool DisplayStaticTri myAISContext->Display(myTrihedron); myAISContext->Deactivate(myTrihedron); - } + } // set interaction style to standard myInteractionStyle = 0; @@ -136,7 +137,7 @@ OCCViewer_Viewer::~OCCViewer_Viewer() */ QColor OCCViewer_Viewer::backgroundColor() const { - return myBgColor; + return myColors[0]; } /*! @@ -145,8 +146,7 @@ QColor OCCViewer_Viewer::backgroundColor() const */ void OCCViewer_Viewer::setBackgroundColor( const QColor& c ) { - if ( c.isValid() ) - myBgColor = c; + setBackgroundColor( 0, c ); } /*! @@ -162,7 +162,7 @@ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view ) OCCViewer_ViewPort3d* vp3d = view->getViewPort(); if ( vp3d ) - vp3d->setBackgroundColor( myBgColor ); + vp3d->setBackgroundColor( myColors[0] ); } } @@ -172,8 +172,9 @@ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view ) */ SUIT_ViewWindow* OCCViewer_Viewer::createView( SUIT_Desktop* theDesktop ) { - OCCViewer_ViewWindow* view = new OCCViewer_ViewWindow(theDesktop, this); - initView( view ); + //OCCViewer_ViewWindow* view = new OCCViewer_ViewWindow(theDesktop, this); + OCCViewer_ViewFrame* view = new OCCViewer_ViewFrame(theDesktop, this); + initView( view->getView(OCCViewer_ViewFrame::MAIN_VIEW) ); return view; } @@ -218,12 +219,16 @@ void OCCViewer_Viewer::onMouseMove(SUIT_ViewWindow* theWindow, QMouseEvent* theE OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow; if ( isSelectionEnabled() ) { - if (aView->getViewPort()->isBusy()) return; // Check that the ViewPort initialization completed + if (aView->getViewPort()->isBusy()) { + QCoreApplication::processEvents(); + return; // Check that the ViewPort initialization completed // To Prevent call move event if the View port is not initialized // IPAL 20883 + } Handle(V3d_View) aView3d = aView->getViewPort()->getView(); - if ( !aView3d.IsNull() ) + if ( !aView3d.IsNull() ) { myAISContext->MoveTo(theEvent->x(), theEvent->y(), aView3d); + } } } @@ -402,17 +407,12 @@ void OCCViewer_Viewer::onDumpView() */ void OCCViewer_Viewer::onChangeBgColor() { - OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView()); - if( !aView ) - return; - OCCViewer_ViewPort3d* aViewPort3d = aView->getViewPort(); - if( !aViewPort3d ) + OCCViewer_ViewWindow* aView = dynamic_cast(myViewManager->getActiveView()); + if ( !aView ) return; - QColor aColorActive = aViewPort3d->backgroundColor(); - - QColor selColor = QColorDialog::getColor( aColorActive, aView); + QColor selColor = QColorDialog::getColor( aView->backgroundColor(), aView ); if ( selColor.isValid() ) - aViewPort3d->setBackgroundColor(selColor); + aView->setBackgroundColor(selColor); } /*! @@ -708,3 +708,22 @@ void OCCViewer_Viewer::isos( int& u, int& v ) const v = ic->IsoNumber( AIS_TOI_IsoV ); } } + +/* + * Returns a new OCCViewer_ViewWindow instance which will be placed as a sub window in ViewFrame + */ +OCCViewer_ViewWindow* OCCViewer_Viewer::createSubWindow() +{ + return new OCCViewer_ViewWindow( 0, this); +} + +QColor OCCViewer_Viewer::backgroundColor(int theViewId) const +{ + return ( theViewId >= 0 && theViewId < myColors.count() ) ? myColors[theViewId] : Qt::black; +} + +void OCCViewer_Viewer::setBackgroundColor( int theViewId, const QColor& theColor) +{ + if ( theColor.isValid() && theViewId >= 0 && theViewId < myColors.count() ) + myColors[theViewId] = theColor; +} diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index 925b2dc05..94f28153c 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -25,6 +25,7 @@ #include #include +#include #include "OCCViewer.h" @@ -107,6 +108,9 @@ public: QColor backgroundColor() const; void setBackgroundColor( const QColor& ); + QColor backgroundColor(int theViewId) const; + void setBackgroundColor( int theViewId, const QColor& ); + //! returns true if 3d Trihedron in viewer was created bool trihedronActivated() const { return !myTrihedron.IsNull(); } @@ -117,6 +121,8 @@ public: double trihedronSize() const; virtual void setTrihedronSize( const double ); + virtual OCCViewer_ViewWindow* createSubWindow(); + public slots: void onClearViewAspects(); @@ -150,12 +156,13 @@ public: void setIsos( const int u, const int v ); // number of isolines void isos( int& u, int& v ) const; + void initView( OCCViewer_ViewWindow* view ); + signals: void selectionChanged(); void deselection(); protected: - void initView( OCCViewer_ViewWindow* view ); protected slots: void onMousePress(SUIT_ViewWindow*, QMouseEvent*); @@ -180,10 +187,12 @@ private: bool mySelectionEnabled; bool myMultiSelectionEnabled; - QColor myBgColor; + //QColor myBgColor; QPoint myStartPnt, myEndPnt; bool myShowStaticTrihedron; + + QVector myColors; }; #ifdef WIN32 diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index 4b2ebd62c..f0cbe3d13 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -119,7 +119,7 @@ bool OCCViewer_ViewPort3d::mapView( const Handle(V3d_View)& view ) } /* create static trihedron (16551: EDF PAL 501) */ - OCCViewer_ViewWindow* aVW = dynamic_cast( parentWidget() ); + OCCViewer_ViewWindow* aVW = dynamic_cast( parentWidget()->parentWidget()->parentWidget() ); if ( aVW ) { OCCViewer_Viewer* aViewModel = dynamic_cast( aVW->getViewManager()->getViewModel() ); if ( aViewModel && aViewModel->isStaticTrihedronDisplayed() ){ diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index ee2ba5cb8..a82f2b983 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -216,6 +216,7 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop* theDesktop, mypSketcher = 0; myCurSketch = -1; + my2dMode = No2dMode; myInteractionStyle = SUIT_ViewModel::STANDARD; } @@ -250,6 +251,17 @@ void OCCViewer_ViewWindow::initLayout() createActions(); createToolBar(); + switch (my2dMode) { + case XYPlane: + onTopView(); + break; + case XZPlane: + onLeftView(); + break; + case YZPlane: + onFrontView(); + break; + } } /*! @@ -270,7 +282,8 @@ OCCViewer_ViewWindow::getButtonState( QMouseEvent* theEvent, int theInteractionS (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::PAN]) ) aOp = PANVIEW; else if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::ROTATE]) && - (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::ROTATE]) ) + (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::ROTATE]) && + (my2dMode == No2dMode)) aOp = ROTATE; return aOp; @@ -1137,6 +1150,13 @@ void OCCViewer_ViewWindow::createActions() aAction->setCheckable(true); connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool))); toolMgr()->registerAction( aAction, SwitchInteractionStyleId ); + + // Maximized view + aAction = new QtxAction(tr("MNU_MINIMIZE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MINIMIZE" ) ), + tr( "MNU_MINIMIZE_VIEW" ), 0, this ); + aAction->setStatusTip(tr("DSC_MINIMIZE_VIEW")); + connect(aAction, SIGNAL(triggered()), this, SLOT(onMaximizedView())); + toolMgr()->registerAction( aAction, MaximizedId ); } /*! @@ -1144,11 +1164,26 @@ void OCCViewer_ViewWindow::createActions() */ void OCCViewer_ViewWindow::createToolBar() { - int tid = toolMgr()->createToolBar( tr( "LBL_TOOLBAR_LABEL" ), false ); + QString aToolbarName; + switch (my2dMode) { + case XYPlane: + aToolbarName = tr( "LBL_XYTOOLBAR_LABEL" ); + break; + case XZPlane: + aToolbarName = tr( "LBL_XZTOOLBAR_LABEL" ); + break; + case YZPlane: + aToolbarName = tr( "LBL_YZTOOLBAR_LABEL" ); + break; + default: + aToolbarName = tr( "LBL_3DTOOLBAR_LABEL" ); + } + + int tid = toolMgr()->createToolBar( aToolbarName, false ); toolMgr()->append( DumpId, tid ); toolMgr()->append( SwitchInteractionStyleId, tid ); - if( myModel->trihedronActivated() ) + if( myModel->trihedronActivated() && (my2dMode == No2dMode) ) toolMgr()->append( TrihedronShowId, tid ); QtxMultiAction* aScaleAction = new QtxMultiAction( this ); @@ -1162,32 +1197,37 @@ void OCCViewer_ViewWindow::createToolBar() aPanningAction->insertAction( toolMgr()->action( GlobalPanId ) ); toolMgr()->append( aPanningAction, tid ); - toolMgr()->append( ChangeRotationPointId, tid ); - toolMgr()->append( RotationId, tid ); - - QtxMultiAction* aViewsAction = new QtxMultiAction( this ); - aViewsAction->insertAction( toolMgr()->action( FrontId ) ); - aViewsAction->insertAction( toolMgr()->action( BackId ) ); - aViewsAction->insertAction( toolMgr()->action( TopId ) ); - aViewsAction->insertAction( toolMgr()->action( BottomId ) ); - aViewsAction->insertAction( toolMgr()->action( LeftId ) ); - aViewsAction->insertAction( toolMgr()->action( RightId ) ); - toolMgr()->append( aViewsAction, tid ); - - toolMgr()->append( ResetId, tid ); + if (my2dMode == No2dMode) { + toolMgr()->append( ChangeRotationPointId, tid ); + toolMgr()->append( RotationId, tid ); + + QtxMultiAction* aViewsAction = new QtxMultiAction( this ); + aViewsAction->insertAction( toolMgr()->action( FrontId ) ); + aViewsAction->insertAction( toolMgr()->action( BackId ) ); + aViewsAction->insertAction( toolMgr()->action( TopId ) ); + aViewsAction->insertAction( toolMgr()->action( BottomId ) ); + aViewsAction->insertAction( toolMgr()->action( LeftId ) ); + aViewsAction->insertAction( toolMgr()->action( RightId ) ); + toolMgr()->append( aViewsAction, tid ); + + toolMgr()->append( ResetId, tid ); - QtxMultiAction* aMemAction = new QtxMultiAction( this ); - aMemAction->insertAction( toolMgr()->action( MemId ) ); - aMemAction->insertAction( toolMgr()->action( RestoreId ) ); - toolMgr()->append( aMemAction, tid ); + QtxMultiAction* aMemAction = new QtxMultiAction( this ); + aMemAction->insertAction( toolMgr()->action( MemId ) ); + aMemAction->insertAction( toolMgr()->action( RestoreId ) ); + toolMgr()->append( aMemAction, tid ); - toolMgr()->append( toolMgr()->separator(), tid ); - toolMgr()->append( CloneId, tid ); + toolMgr()->append( toolMgr()->separator(), tid ); + toolMgr()->append( CloneId, tid ); - toolMgr()->append( toolMgr()->separator(), tid ); - toolMgr()->append( ClippingId, tid ); - toolMgr()->append( AxialScaleId, tid ); - toolMgr()->append( AmbientId, tid ); + toolMgr()->append( toolMgr()->separator(), tid ); + toolMgr()->append( ClippingId, tid ); + toolMgr()->append( AxialScaleId, tid ); + toolMgr()->append( AmbientId, tid ); + } else { + toolMgr()->append( AxialScaleId, tid ); + } + toolMgr()->append( MaximizedId, tid); } /*! @@ -1306,7 +1346,7 @@ void OCCViewer_ViewWindow::onSetRotationPoint( bool on ) { if (!mySetRotationPointDlg) { - mySetRotationPointDlg = new OCCViewer_SetRotationPointDlg (this, myDesktop); + mySetRotationPointDlg = new OCCViewer_SetRotationPointDlg (this); mySetRotationPointDlg->SetAction(mySetRotationPointAction); } @@ -1355,23 +1395,26 @@ void OCCViewer_ViewWindow::onClipping( bool on ) else myActionsMap[ ClippingId ]->setIcon(aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING" ))); */ + OCCViewer_ViewWindow* aParent = dynamic_cast(parent()->parent()); + if (!aParent) + aParent = this; if ( on ) - { - if ( !myClippingDlg ) { - myClippingDlg = new OCCViewer_ClippingDlg( this, myDesktop ); - myClippingDlg->SetAction( myClippingAction ); - } + if ( !myClippingDlg ) + { + myClippingDlg = new OCCViewer_ClippingDlg( aParent ); + myClippingDlg->SetAction( myClippingAction ); + } - if ( !myClippingDlg->isVisible() ) - myClippingDlg->show(); - } + if ( !myClippingDlg->isVisible() ) + myClippingDlg->show(); + } else - { - if ( myClippingDlg->isVisible() ) - myClippingDlg->hide(); - setCuttingPlane(false); - } + { + if ( myClippingDlg->isVisible() ) + myClippingDlg->hide(); + aParent->setCuttingPlane(false); + } } /*! @@ -1380,7 +1423,7 @@ void OCCViewer_ViewWindow::onClipping( bool on ) void OCCViewer_ViewWindow::onAxialScale() { if ( !myScalingDlg ) - myScalingDlg = new OCCViewer_AxialScaleDlg( this, myDesktop ); + myScalingDlg = new OCCViewer_AxialScaleDlg( this ); if ( !myScalingDlg->isVisible() ) myScalingDlg->show(); @@ -1504,14 +1547,18 @@ QImage OCCViewer_ViewWindow::dumpView() Handle(V3d_View) view = myViewPort->getView(); if ( view.IsNull() ) return QImage(); + int aWidth = myViewPort->width(); int aHeight = myViewPort->height(); QApplication::syncX(); - view->Update(); + view->Redraw(); // In order to reactivate GL context + //view->Update(); OpenGLUtils_FrameBuffer aFrameBuffer; if( aFrameBuffer.init( aWidth, aHeight ) ) { + QImage anImage( aWidth, aHeight, QImage::Format_RGB32 ); + glPushAttrib( GL_VIEWPORT_BIT ); glViewport( 0, 0, aWidth, aHeight ); aFrameBuffer.bind(); @@ -1522,8 +1569,6 @@ QImage OCCViewer_ViewWindow::dumpView() aFrameBuffer.unbind(); glPopAttrib(); - QImage anImage( aWidth, aHeight, QImage::Format_RGB32 ); - aFrameBuffer.bind(); glReadPixels( 0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits() ); aFrameBuffer.unbind(); @@ -1532,9 +1577,8 @@ QImage OCCViewer_ViewWindow::dumpView() anImage = anImage.mirrored(); return anImage; } - // if frame buffers are unsupported, use old functionality - view->Redraw(); + //view->Redraw(); unsigned char* data = new unsigned char[ aWidth*aHeight*4 ]; @@ -1616,6 +1660,14 @@ void OCCViewer_ViewWindow::setCuttingPlane( bool on, const double x, const doub view->Redraw(); } +void OCCViewer_ViewWindow::setCuttingPlane( bool on, const gp_Pln pln ) +{ + gp_Dir aDir = pln.Axis().Direction(); + gp_Pnt aPnt = pln.Location(); + setCuttingPlane(on, aPnt.X(), aPnt.Y(), aPnt.Z(), aDir.X(), aDir.Y(), aDir.Z()); +} + + /*! \brief Check if any cutting plane is enabled \return \c true if at least one cutting plane is enabled @@ -1927,3 +1979,56 @@ bool OCCViewer_ViewWindow::transformEnabled( const OperationType id ) const { return myStatus.contains( id ) ? myStatus[ id ] : true; } + +void OCCViewer_ViewWindow::onMaximizedView() +{ + setMaximized(!isMaximized()); +} + + +void OCCViewer_ViewWindow::setMaximized(bool toMaximize, bool toSendSignal) +{ + QAction* anAction = toolMgr()->action( MaximizedId ); + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + if ( toMaximize ) { + anAction->setText( tr( "MNU_MINIMIZE_VIEW" ) ); + anAction->setToolTip( tr( "MNU_MINIMIZE_VIEW" ) ); + anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MINIMIZE" ) ) ); + anAction->setStatusTip( tr( "DSC_MINIMIZE_VIEW" ) ); + if (toSendSignal) { + emit maximized( this, true ); + } + } + else { + anAction->setText( tr( "MNU_MAXIMIZE_VIEW" ) ); + anAction->setToolTip( tr( "MNU_MAXIMIZE_VIEW" ) ); + anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MAXIMIZE" ) ) ); + anAction->setStatusTip( tr( "DSC_MAXIMIZE_VIEW" ) ); + if (toSendSignal) { + emit maximized( this, false ); + } + } +} + + +bool OCCViewer_ViewWindow::isMaximized() const +{ + return !(toolMgr()->action( MaximizedId )->text() == tr( "MNU_MAXIMIZE_VIEW" )); +} + + +void OCCViewer_ViewWindow::set2dMode(Mode2dType theType) +{ + my2dMode = theType; +} + +QColor OCCViewer_ViewWindow::backgroundColor() const +{ + return myViewPort ? myViewPort->backgroundColor() : Qt::black; +} + +void OCCViewer_ViewWindow::setBackgroundColor( const QColor& theColor) +{ + if ( myViewPort ) myViewPort->setBackgroundColor( theColor ); +} + diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index 56558b5b7..498748a7c 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -26,6 +26,7 @@ #include "OCCViewer.h" #include "SUIT_ViewWindow.h" #include +#include class QtxRectRubberBand; class SUIT_Desktop; @@ -35,7 +36,7 @@ class OCCViewer_ClippingDlg; class OCCViewer_AxialScaleDlg; class OCCViewer_SetRotationPointDlg; class OCCViewer_Viewer; -class viewAspect; +struct viewAspect; class QtxAction; #ifdef WIN32 @@ -50,7 +51,7 @@ public: enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, ChangeRotationPointId, RotationId, FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, ClippingId, MemId, RestoreId, - TrihedronShowId, AxialScaleId, AmbientId, SwitchInteractionStyleId }; + TrihedronShowId, AxialScaleId, AmbientId, SwitchInteractionStyleId, MaximizedId, UserId }; enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW, @@ -60,72 +61,90 @@ public: enum SketchingType { NoSketching, Rect, Polygon }; + enum Mode2dType { No2dMode, XYPlane, XZPlane, YZPlane}; + + OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel); virtual ~OCCViewer_ViewWindow(); - OCCViewer_ViewPort3d* getViewPort(); + virtual OCCViewer_ViewPort3d* getViewPort(); - bool eventFilter(QObject* watched, QEvent* e); + virtual bool eventFilter(QObject* watched, QEvent* e); - void performRestoring( const viewAspect& ); + virtual void performRestoring( const viewAspect& ); virtual void initLayout(); - void updateEnabledDrawMode(); + 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); - 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 ); - bool isCuttingPlane(); + virtual bool isCuttingPlane(); virtual QString getVisualParameters(); virtual void setVisualParameters( const QString& parameters ); - virtual void initSketchers(); - OCCViewer_ViewSketcher* getSketcher( const int ); + virtual void initSketchers(); + virtual OCCViewer_ViewSketcher* getSketcher( const int ); - void activateSketching( int ); + virtual void activateSketching( int ); - int interactionStyle() const; - void setInteractionStyle( const int ); + virtual int interactionStyle() const; + virtual void setInteractionStyle( const int ); void setTransformEnabled( const OperationType, const bool ); bool transformEnabled( const OperationType ) const; + + void set2dMode( Mode2dType ); + Mode2dType get2dMode() const { return my2dMode; } + + void setMaximized( bool, bool = true ); + bool isMaximized() const; + + virtual QColor backgroundColor() const; + virtual void setBackgroundColor( const QColor& ); + + public slots: - void onFrontView(); - void onViewFitAll(); - void onBackView(); - void onTopView(); - void onBottomView(); - void onLeftView(); - void onRightView(); - void onResetView(); - void onFitAll(); - void activateZoom(); - void activateWindowFit(); - void activateRotation(); - void activatePanning(); - void activateGlobalPanning(); - void onSetRotationPoint( bool on ); - void onCloneView(); - void onClipping( bool on ); - void onAxialScale(); - void onAmbientToogle(); - void onMemorizeView(); - void onRestoreView(); - void onTrihedronShow(); - void setRestoreFlag(); - void onSwitchInteractionStyle( bool on ); - - void activateSetRotationGravity(); - void activateSetRotationSelected( double theX, double theY, double theZ ); - void activateStartPointSelection(); - void updateGravityCoords(); + virtual void onFrontView(); + virtual void onViewFitAll(); + virtual void onBackView(); + virtual void onTopView(); + virtual void onBottomView(); + virtual void onLeftView(); + virtual void onRightView(); + virtual void 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 onCloneView(); + virtual void onClipping( bool on ); + virtual void onAxialScale(); + virtual void onAmbientToogle(); + virtual void onMemorizeView(); + virtual void onRestoreView(); + virtual void onTrihedronShow(); + virtual void setRestoreFlag(); + virtual void onSwitchInteractionStyle( bool on ); + + virtual void activateSetRotationGravity(); + virtual void activateSetRotationSelected( double theX, double theY, double theZ ); + virtual void activateStartPointSelection(); + virtual void updateGravityCoords(); virtual void showEvent( QShowEvent * ); virtual void hideEvent( QHideEvent * ); + void onMaximizedView(); + signals: void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type); @@ -134,6 +153,7 @@ signals: void Show( QShowEvent * ); void Hide( QHideEvent * ); + void maximized( OCCViewer_ViewWindow*, bool ); protected: virtual QImage dumpView(); @@ -216,6 +236,10 @@ private: typedef QMap MapOfTransformStatus; MapOfTransformStatus myStatus; + + Mode2dType my2dMode; + + Handle(V3d_Plane) myReserveClippingPlane; }; #ifdef WIN32 diff --git a/src/OCCViewer/resources/OCCViewer_images.ts b/src/OCCViewer/resources/OCCViewer_images.ts index bdd523e49..e6a032c7a 100644 --- a/src/OCCViewer/resources/OCCViewer_images.ts +++ b/src/OCCViewer/resources/OCCViewer_images.ts @@ -120,5 +120,13 @@ ICON_OCCVIEWER_STYLE_SWITCH occ_view_style_switch.png + + ICON_OCCVIEWER_MAXIMIZE + occ_view_maximized.png + + + ICON_OCCVIEWER_MINIMIZE + occ_view_minimized.png + diff --git a/src/OCCViewer/resources/OCCViewer_msg_en.ts b/src/OCCViewer/resources/OCCViewer_msg_en.ts index 5fcc11b74..764efc208 100644 --- a/src/OCCViewer/resources/OCCViewer_msg_en.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_en.ts @@ -213,8 +213,20 @@ Restore view - LBL_TOOLBAR_LABEL - View Operations + LBL_XYTOOLBAR_LABEL + XY View Operations + + + LBL_XZTOOLBAR_LABEL + XZ View Operations + + + LBL_YZTOOLBAR_LABEL + YZ View Operations + + + LBL_3DTOOLBAR_LABEL + 3D View Operations DSC_BACK_VIEW @@ -248,6 +260,22 @@ OCC_IMAGE_FILES Images Files (*.bmp *.png *.jpg *.jpeg) + + DSC_MAXIMIZE_VIEW + Maximize view + + + DSC_MINIMIZE_VIEW + Set axonometric projections + + + MNU_MAXIMIZE_VIEW + Maximize + + + MNU_MINIMIZE_VIEW + Axonometric views + OCCViewer_CreateRestoreViewDlg diff --git a/src/OCCViewer/resources/occ_view_maximized.png b/src/OCCViewer/resources/occ_view_maximized.png new file mode 100644 index 000000000..8e19d6a23 Binary files /dev/null and b/src/OCCViewer/resources/occ_view_maximized.png differ diff --git a/src/OCCViewer/resources/occ_view_minimized.png b/src/OCCViewer/resources/occ_view_minimized.png new file mode 100644 index 000000000..b38bbeb90 Binary files /dev/null and b/src/OCCViewer/resources/occ_view_minimized.png differ diff --git a/src/SOCC/SOCC_ViewModel.cxx b/src/SOCC/SOCC_ViewModel.cxx index 260bed36e..4d8fa63cf 100755 --- a/src/SOCC/SOCC_ViewModel.cxx +++ b/src/SOCC/SOCC_ViewModel.cxx @@ -706,9 +706,18 @@ void SOCC_Viewer::Repaint() /*! create SOCC_ViewWindow */ -SUIT_ViewWindow* SOCC_Viewer::createView( SUIT_Desktop* theDesktop ) +/*SUIT_ViewWindow* SOCC_Viewer::createView( SUIT_Desktop* theDesktop ) { SOCC_ViewWindow* view = new SOCC_ViewWindow(theDesktop, this); - initView( view ); + //initView( view ); + initView( view->getView(OCCViewer_ViewFrame::MAIN_VIEW) ); return view; + }*/ + +/* + * Returns a new OCCViewer_ViewWindow instance which will be placed as a sub window in ViewFrame + */ +OCCViewer_ViewWindow* SOCC_Viewer::createSubWindow() +{ + return new SOCC_ViewWindow( 0, this); } diff --git a/src/SOCC/SOCC_ViewModel.h b/src/SOCC/SOCC_ViewModel.h index 7a5b10ef4..92c919032 100755 --- a/src/SOCC/SOCC_ViewModel.h +++ b/src/SOCC/SOCC_ViewModel.h @@ -51,7 +51,8 @@ public: void rename( const Handle(SALOME_InteractiveObject)&, const QString& ); - virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop); + //virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop); + virtual OCCViewer_ViewWindow* createSubWindow(); /* Reimplemented from SALOME_View */ virtual void Display( const SALOME_OCCPrs* ); diff --git a/src/SOCC/SOCC_ViewWindow.h b/src/SOCC/SOCC_ViewWindow.h index 90338fbef..ac18551a1 100644 --- a/src/SOCC/SOCC_ViewWindow.h +++ b/src/SOCC/SOCC_ViewWindow.h @@ -28,7 +28,7 @@ #endif #include "SOCC.h" -#include "OCCViewer_ViewWindow.h" +#include "OCCViewer_ViewFrame.h" class SOCC_EXPORT SOCC_ViewWindow : public OCCViewer_ViewWindow { diff --git a/src/SUIT/SUIT_LicenseDlg.cxx b/src/SUIT/SUIT_LicenseDlg.cxx index 21c6517b2..77b01f9a6 100755 --- a/src/SUIT/SUIT_LicenseDlg.cxx +++ b/src/SUIT/SUIT_LicenseDlg.cxx @@ -48,10 +48,10 @@ SUIT_LicenseDlg::SUIT_LicenseDlg( bool firstShow, QWidget* parent, const char* n setObjectName( name ); setModal( modal ); QString env; - if ( ::getenv( "TRIPOLI_ROOT_DIR" ) ) - env = ::getenv( "TRIPOLI_ROOT_DIR" ); + if ( ::getenv( "SALOME_LICENSE_FILE" ) ) + env = ::getenv( "SALOME_LICENSE_FILE" ); - QFile file( env + "/share/salome/resources/License.txt" ); // Read the text from a file + QFile file( env ); // Read the text from a file if ( !file.exists() || !file.open( QIODevice::ReadOnly ) ) return; diff --git a/src/SUIT/SUIT_SelectionMgr.cxx b/src/SUIT/SUIT_SelectionMgr.cxx index 042631603..28e204a55 100755 --- a/src/SUIT/SUIT_SelectionMgr.cxx +++ b/src/SUIT/SUIT_SelectionMgr.cxx @@ -96,6 +96,8 @@ void SUIT_SelectionMgr::selected( SUIT_DataOwnerPtrList& lst, const QString& typ for ( SelectorList::const_iterator it = mySelectors.begin(); it != mySelectors.end(); ++it ) { + if ( !(*it)->isEnabled() ) + continue; if ( !type.isEmpty() && (*it)->type() != type ) continue; diff --git a/src/SUIT/SUIT_ViewWindow.cxx b/src/SUIT/SUIT_ViewWindow.cxx index ebf0055c9..9d41d22d3 100755 --- a/src/SUIT/SUIT_ViewWindow.cxx +++ b/src/SUIT/SUIT_ViewWindow.cxx @@ -157,7 +157,8 @@ void SUIT_ViewWindow::contextMenuEvent( QContextMenuEvent* e ) */ void SUIT_ViewWindow::onDumpView() { - QApplication::postEvent( this, new QPaintEvent( QRect( 0, 0, width(), height() ) ) ); + // VSV (TRIPOLI dev): next line commented: causes error messages + //QApplication::postEvent( this, new QPaintEvent( QRect( 0, 0, width(), height() ) ) ); QApplication::postEvent( this, new QEvent( (QEvent::Type)DUMP_EVENT ) ); } @@ -178,18 +179,17 @@ bool SUIT_ViewWindow::event( QEvent* e ) bool bOk = false; if ( myManager && myManager->study() && myManager->study()->application() ) { - QImage im = dumpView(); - // get file name SUIT_Application* app = myManager->study()->application(); QString fileName = app->getFileName( false, QString(), filter(), tr( "TLT_DUMP_VIEW" ), 0 ); if ( !fileName.isEmpty() ) { - QString fmt = SUIT_Tools::extension( fileName ).toUpper(); - bOk = dumpViewToFormat( im, fileName, fmt ); + QImage im = dumpView(); + QString fmt = SUIT_Tools::extension( fileName ).toUpper(); + bOk = dumpViewToFormat( im, fileName, fmt ); } else - bOk = true; // cancelled + bOk = true; // cancelled } if ( !bOk ) SUIT_MessageBox::critical( this, tr( "ERROR" ), tr( "ERR_CANT_DUMP_VIEW" ) ); diff --git a/src/SUIT/SUIT_ViewWindow.h b/src/SUIT/SUIT_ViewWindow.h index 5b09273da..7043c8497 100755 --- a/src/SUIT/SUIT_ViewWindow.h +++ b/src/SUIT/SUIT_ViewWindow.h @@ -43,7 +43,7 @@ public: SUIT_ViewWindow( SUIT_Desktop* ); virtual ~SUIT_ViewWindow(); - void setViewManager( SUIT_ViewManager* ); + virtual void setViewManager( SUIT_ViewManager* ); SUIT_ViewManager* getViewManager() const; bool event(QEvent*); diff --git a/src/SalomeApp/resources/SalomeApp.xml b/src/SalomeApp/resources/SalomeApp.xml index 1500aedaf..970ca1d78 100644 --- a/src/SalomeApp/resources/SalomeApp.xml +++ b/src/SalomeApp/resources/SalomeApp.xml @@ -121,7 +121,10 @@
- + + + +