From: vsv Date: Thu, 8 May 2008 15:21:51 +0000 (+0000) Subject: Introduced ViewExtender X-Git-Tag: TG_VISU_2008_2008-06-26~52 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9e8fafd04fce26db0da2221260758bffb45631d6;p=modules%2Fvisu.git Introduced ViewExtender --- diff --git a/src/VISUGUI/Makefile.am b/src/VISUGUI/Makefile.am index f5ad51ad..68d70bb7 100644 --- a/src/VISUGUI/Makefile.am +++ b/src/VISUGUI/Makefile.am @@ -71,7 +71,9 @@ dist_libVISU_la_SOURCES= \ VisuGUI_Slider.cxx \ VisuGUI_InputPane.cxx \ VisuGUI_CacheDlg.cxx \ - VisuGUI_FieldFilter.cxx + VisuGUI_FieldFilter.cxx \ + VisuGUI_ViewExtender.cxx \ + VisuGUI_ClippingPlaneMgr.cxx MOC_FILES= \ VisuGUI_moc.cxx \ @@ -101,7 +103,9 @@ MOC_FILES= \ VisuGUI_TransparencyDlg_moc.cxx \ VisuGUI_Slider_moc.cxx \ VisuGUI_InputPane_moc.cxx \ - VisuGUI_CacheDlg_moc.cxx + VisuGUI_CacheDlg_moc.cxx \ + VisuGUI_ViewExtender_moc.cxx \ + VisuGUI_ClippingPlaneMgr_moc.cxx nodist_libVISU_la_SOURCES=$(MOC_FILES) diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index dcb15c65..a44661ff 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -3208,4 +3208,78 @@ Please, refer to the documentation. auto + + VisuGUI_ClippingPlaneMgr + + TITLE + Clipping planes configuration + + + TITLE_PLANES + Planes definition + + + LBL_NAME + Name of the plane + + + BYVECTOR_TITLE + Normal vector + + + BYPLANE_TITLE + Main plane + + + CHK_AUTOAPPLY + Auto apply + + + CHK_SHOW_PREVIEW + Show preview + + + ORIGIN_TITLE + Origin + + + DIRECTION_TITLE + Direction + + + LBL_ORIENTATION + Orientation + + + LBL_DISTANCE + Distance + + + LBL_ROTATION + Rotation around %1 + + + BTN_NEW + New + + + BTN_DELETE + Delete + + + + VisuGUI_ViewExtender + + MNU_CLIPPING_PLANE_MGR + Clipping planes + + + DSK_CLIPPING_PLANE_MGR + Manage clipping planes in the viewer + + + VISU_VIEW_TOOLBAR + VISU tools + + diff --git a/src/VISUGUI/VisuGUI_ClippingPlaneMgr.cxx b/src/VISUGUI/VisuGUI_ClippingPlaneMgr.cxx new file mode 100644 index 00000000..f5578879 --- /dev/null +++ b/src/VISUGUI/VisuGUI_ClippingPlaneMgr.cxx @@ -0,0 +1,221 @@ +// Copyright (C) 2005 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 "VisuGUI_ClippingPlaneMgr.h" + +#include "VisuGUI.h" +#include "VisuGUI_Tools.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +using namespace std; + +VisuGUI_ClippingPlaneMgr::VisuGUI_ClippingPlaneMgr(VisuGUI* theModule) + : QDialog(VISU::GetDesktop(theModule), Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), + myModule(theModule) +{ + setWindowTitle(tr("TITLE")); + setSizeGripEnabled(true); + setAttribute( Qt::WA_DeleteOnClose, true ); + setModal(false); + + QVBoxLayout* aMainLayout = new QVBoxLayout(this); + aMainLayout->setSpacing(6); + aMainLayout->setMargin(11); + + QHBoxLayout* aPlanesBox = new QHBoxLayout(this); + aPlanesBox->setMargin(6); + aMainLayout->addLayout(aPlanesBox); + + myPlanesList = new QListView(this); + aPlanesBox->addWidget(myPlanesList); + + // Planes parameters box + QFrame* aPlanesFrame = new QFrame(this); + aPlanesFrame->setWindowTitle(tr("TITLE_PLANES")); + aPlanesBox->addWidget(aPlanesFrame); + + QVBoxLayout* aFrameLayout = new QVBoxLayout(aPlanesFrame); + aFrameLayout->setSpacing(5); + aFrameLayout->setMargin(6); + + QHBoxLayout* aNameBox = new QHBoxLayout(aPlanesFrame); + aFrameLayout->addLayout(aNameBox); + aNameBox->setSpacing(5); + + aNameBox->addWidget(new QLabel(tr("LBL_NAME"), aPlanesFrame)); + myNameEdt = new QLineEdit(aPlanesFrame); + aNameBox->addWidget(myNameEdt); + + myMethodTab = new QTabWidget(aPlanesFrame); + aFrameLayout->addWidget(myMethodTab); + + myMethodTab->addTab(createVectorTab(), tr("BYVECTOR_TITLE")); + myMethodTab->addTab(createPlanesTab(), tr("BYPLANE_TITLE")); + + myAutoApply = new QCheckBox(tr("CHK_AUTOAPPLY"), aPlanesFrame); + aFrameLayout->addWidget(myAutoApply); + + // Buttons for management of planes + QHBoxLayout* aManageBox = new QHBoxLayout(this); + aMainLayout->addLayout(aManageBox); + aManageBox->setMargin(6); + + QPushButton* aNewBtn = new QPushButton(tr("BTN_NEW"), this); + aManageBox->addWidget(aNewBtn); + + QPushButton* aDeleteBtn = new QPushButton(tr("BTN_DELETE"), this); + aManageBox->addWidget(aDeleteBtn); + + aManageBox->addStretch(); + + myShowPreview = new QCheckBox(tr("CHK_SHOW_PREVIEW"), this); + aManageBox->addWidget(myShowPreview); + + // Dialog buttons + QGroupBox* aGroupButtons = new QGroupBox (this); + aMainLayout->addWidget(aGroupButtons); + + QSizePolicy aSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed ); + QHBoxLayout* aButtonsLayout = new QHBoxLayout(aGroupButtons); + aButtonsLayout->setSpacing(6); + aButtonsLayout->setMargin(11); + + QPushButton* aBtnOk = new QPushButton(tr("BUT_OK"), aGroupButtons); + aButtonsLayout->addWidget(aBtnOk); + + QPushButton* aBtnApply = new QPushButton(tr("BUT_APPLY"), aGroupButtons); + aButtonsLayout->addWidget(aBtnApply); + + aButtonsLayout->addStretch(); + + QPushButton* aBtnClose = new QPushButton(tr("BUT_CLOSE"), aGroupButtons); + aButtonsLayout->addWidget(aBtnClose); + + QPushButton* aBtnHelp = new QPushButton(tr("BUT_HELP"), aGroupButtons); + aButtonsLayout->addWidget(aBtnHelp); +} + + +//**************************************************************** +QWidget* VisuGUI_ClippingPlaneMgr::createVectorTab() +{ + QWidget* aVectorTab = new QWidget(myMethodTab); + QVBoxLayout* aVectorTabLayout = new QVBoxLayout(aVectorTab); + + QGroupBox* aOriginGroup = new QGroupBox( tr( "ORIGIN_TITLE" ), aVectorTab ); + aVectorTabLayout->addWidget(aOriginGroup); + QHBoxLayout* aOriginLayout = new QHBoxLayout(aOriginGroup); + + aOriginLayout->addWidget( new QLabel("X", aOriginGroup) ); + myXOrigin = new QtxDoubleSpinBox( -1000.0, 1000.0, 0.1, aOriginGroup ); + myXOrigin->setValue( 0.0 ); + aOriginLayout->addWidget( myXOrigin ); + + aOriginLayout->addWidget( new QLabel("Y", aOriginGroup) ); + myYOrigin = new QtxDoubleSpinBox( -1000.0, 1000, 0.1, aOriginGroup ); + myYOrigin->setValue( 0.0 ); + aOriginLayout->addWidget( myYOrigin ); + + aOriginLayout->addWidget( new QLabel("Z", aOriginGroup) ); + myZOrigin = new QtxDoubleSpinBox( -1000.0, 1000.0, 0.1, aOriginGroup ); + myZOrigin->setValue( 0.0 ); + aOriginLayout->addWidget( myZOrigin ); + + QGroupBox* aDirGroup = new QGroupBox( tr( "DIRECTION_TITLE" ), aVectorTab ); + aVectorTabLayout->addWidget(aDirGroup); + QHBoxLayout* aDirLayout = new QHBoxLayout(aDirGroup); + + aDirLayout->addWidget( new QLabel("dX", aDirGroup) ); + myXDir = new QtxDoubleSpinBox( -1000.0, 1000.0, 0.1, aDirGroup ); + myXDir->setValue( 0.0 ); + aDirLayout->addWidget( myXDir ); + + aDirLayout->addWidget( new QLabel("dY", aDirGroup) ); + myYDir = new QtxDoubleSpinBox( -1000.0, 1000.0, 0.1, aDirGroup ); + myYDir->setValue( 0.0 ); + aDirLayout->addWidget( myYDir ); + + aDirLayout->addWidget( new QLabel("dZ", aDirGroup) ); + myZDir = new QtxDoubleSpinBox( -1000.0, 1000.0, 0.1, aDirGroup ); + myZDir->setValue( 0.0 ); + aDirLayout->addWidget( myZDir ); + + + return aVectorTab; +} + + +//**************************************************************** +QWidget* VisuGUI_ClippingPlaneMgr::createPlanesTab() +{ + QWidget* aPlanesTab = new QWidget(myMethodTab); + QGridLayout* aVectorTabLayout = new QGridLayout(aPlanesTab); + + aVectorTabLayout->addWidget(new QLabel(tr("LBL_ORIENTATION"), aPlanesTab), 0, 0); + aVectorTabLayout->addWidget(new QLabel(tr("LBL_DISTANCE"), aPlanesTab), 1, 0); + + myPlaneCombo = new QComboBox(aPlanesTab); + myPlaneCombo->addItem("|| X-Y"); + myPlaneCombo->addItem("|| Y-Z"); + myPlaneCombo->addItem("|| X-Z"); + aVectorTabLayout->addWidget(myPlaneCombo, 0, 1); + + myDistance = new QtxDoubleSpinBox( -1000, 1000, 1, aPlanesTab ); + myDistance->setValue( 0.0 ); + aVectorTabLayout->addWidget( myDistance, 1, 1 ); + + myRotationXLbl = new QLabel(tr("LBL_ROTATION").arg("X"), aPlanesTab); + aVectorTabLayout->addWidget(myRotationXLbl, 0, 2); + + myRotX = new QtxDoubleSpinBox( -180.0, 180.0, 1, aPlanesTab ); + myRotX->setValue( 0.0 ); + aVectorTabLayout->addWidget( myRotX, 0, 3 ); + + myRotationYLbl = new QLabel(tr("LBL_ROTATION").arg("Y"), aPlanesTab); + aVectorTabLayout->addWidget(myRotationYLbl, 1, 2); + + myRotY = new QtxDoubleSpinBox( -180.0, 180.0, 1, aPlanesTab ); + myRotY->setValue( 0.0 ); + aVectorTabLayout->addWidget( myRotY, 1, 3 ); + + + return aPlanesTab; +} + + +//**************************************************************** +VisuGUI_ClippingPlaneMgr::~VisuGUI_ClippingPlaneMgr() +{ +} diff --git a/src/VISUGUI/VisuGUI_ClippingPlaneMgr.h b/src/VISUGUI/VisuGUI_ClippingPlaneMgr.h new file mode 100644 index 00000000..dd898a33 --- /dev/null +++ b/src/VISUGUI/VisuGUI_ClippingPlaneMgr.h @@ -0,0 +1,71 @@ +// Copyright (C) 2005 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 DIALOGBOX_CLIPPINGPLANEMGR_H +#define DIALOGBOX_CLIPPINGPLANEMGR_H + +#include + +class VisuGUI; +class QListView; +class QLineEdit; +class QtxDoubleSpinBox; +class QTabWidget; +class QLabel; +class QComboBox; +class QCheckBox; + +class VisuGUI_ClippingPlaneMgr : public QDialog +{ + Q_OBJECT +public: + + VisuGUI_ClippingPlaneMgr(VisuGUI* theModule); + ~VisuGUI_ClippingPlaneMgr(); + + private: + QWidget* createVectorTab(); + QWidget* createPlanesTab(); + + QListView* myPlanesList; + QLineEdit* myNameEdt; + VisuGUI* myModule; + QTabWidget* myMethodTab; + + QtxDoubleSpinBox* myXOrigin; + QtxDoubleSpinBox* myYOrigin; + QtxDoubleSpinBox* myZOrigin; + + QtxDoubleSpinBox* myXDir; + QtxDoubleSpinBox* myYDir; + QtxDoubleSpinBox* myZDir; + + QLabel* myRotationXLbl; + QLabel* myRotationYLbl; + + QComboBox* myPlaneCombo; + QtxDoubleSpinBox* myDistance; + QtxDoubleSpinBox* myRotX; + QtxDoubleSpinBox* myRotY; + + QCheckBox* myAutoApply; + QCheckBox* myShowPreview; +}; + +#endif diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index 21ffa19d..5a7a269e 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -27,6 +27,7 @@ // $Header$ #include "VisuGUI_Module.h" +#include "VisuGUI_ViewExtender.h" #include "QtxPopupMgr.h" @@ -183,6 +184,7 @@ VisuGUI_Module:: VisuGUI_Module() : VisuGUI() { + myExtender = new VisuGUI_ViewExtender(this); } diff --git a/src/VISUGUI/VisuGUI_Module.h b/src/VISUGUI/VisuGUI_Module.h index 02abf76e..c3c3722a 100644 --- a/src/VISUGUI/VisuGUI_Module.h +++ b/src/VISUGUI/VisuGUI_Module.h @@ -31,6 +31,8 @@ #include "VisuGUI.h" #include "STD_Application.h" #include "SALOMEDSClient_SObject.hxx" +#include +#include "VisuGUI_ViewExtender.h" class SUIT_ViewManager; class SVTK_ViewManager; @@ -81,6 +83,9 @@ public: void restoreVisualParameters(int savePoint); + //! Returns Module dedicated extension for Viewer. Returns 0 if module has no extension + virtual CAM_ViewExtender* getViewExtender() { return myExtender; } + public slots: //! Reimplemented method of the module deactivation. virtual @@ -160,6 +165,9 @@ protected: void setProperty( SVTK_ViewWindow*, const QString& ); // set a property (speed_increment, etc ) for SVTK ViewWindow void setProperty( SVTK_ViewManager*, const QString& ); // set a property for SVTK ViewWindow // set only 1 property for all ViewWindows of given view manager + + + VisuGUI_ViewExtender* myExtender; }; #endif diff --git a/src/VISUGUI/VisuGUI_ViewExtender.cxx b/src/VISUGUI/VisuGUI_ViewExtender.cxx new file mode 100644 index 00000000..c3273b6e --- /dev/null +++ b/src/VISUGUI/VisuGUI_ViewExtender.cxx @@ -0,0 +1,100 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 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 +// +// +// +// File : VisuGUI_ViewExtender.cxx +// Author : Vitaly Smetannikov +// Module : VISU + + + +#include "VisuGUI_ViewExtender.h" + +// #include +#include "VisuGUI_ClippingPlaneMgr.h" +#include "VisuGUI.h" + +#include +#include + +#include +#include +#include + +//using namespace std; + +VisuGUI_ViewExtender::VisuGUI_ViewExtender(VisuGUI* theModule): + myModule(theModule), + myNonModalDlg(0) +{ + QtxAction* aAction; + SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); + aAction = new QtxAction(tr("MNU_CLIPPING_PLANE_MGR"), + aResourceMgr->loadPixmap("VISU",tr("ICON_VVTK_PLANE_SEGMENTATION_SWITCH")), + tr( "DSK_CLIPPING_PLANE_MGR" ), + 0, + this, + false); + connect(aAction, SIGNAL( activated() ), this, SLOT( onPlanesMgr() )); + myActionsMap[ClippingPlaneMgrId] = aAction; +} + +VisuGUI_ViewExtender::~VisuGUI_ViewExtender() +{ +} + +int VisuGUI_ViewExtender::createToolbar(QtxActionToolMgr* theMgr) +{ + int aToolBar = theMgr->createToolBar( QObject::tr("VISU_VIEW_TOOLBAR")); + theMgr->append( myActionsMap[ClippingPlaneMgrId], aToolBar ); + return aToolBar; +} + +void VisuGUI_ViewExtender::contextMenuPopup(QMenu* theMenu) +{ + printf("#### contextMenuPopup\n"); +} + +void VisuGUI_ViewExtender::onPlanesMgr() +{ + myNonModalDlg = new VisuGUI_ClippingPlaneMgr(myModule); + connect(myNonModalDlg, SIGNAL( destroyed(QObject*) ), this, SLOT( onDialogDestroy() )); + myNonModalDlg->show(); +} + +void VisuGUI_ViewExtender::activate() +{ +} + +void VisuGUI_ViewExtender::deactivate() +{ + if (myNonModalDlg) { + myNonModalDlg->close(); + myNonModalDlg = 0; + } +} + +void VisuGUI_ViewExtender::onDialogDestroy() +{ + disconnect(myNonModalDlg, SIGNAL( destroyed(QObject*) ), this, SLOT( onDialogDestroy() )); + myNonModalDlg = 0; +} diff --git a/src/VISUGUI/VisuGUI_ViewExtender.h b/src/VISUGUI/VisuGUI_ViewExtender.h new file mode 100644 index 00000000..fc608a3d --- /dev/null +++ b/src/VISUGUI/VisuGUI_ViewExtender.h @@ -0,0 +1,69 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 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 +// +// +// +// File : VisuGUI_ViewExtender.h +// Author : Vitaly Smetannikov +// Module : VISU + + +#ifndef VisuGUI_ViewExtender_HeaderFile +#define VisuGUI_ViewExtender_HeaderFile + +#include +#include +#include + +class VisuGUI; +class QtxAction; +class QDialog; + +class VisuGUI_ViewExtender: public QObject, public CAM_ViewExtender +{ + Q_OBJECT + + public: + VisuGUI_ViewExtender(VisuGUI* theModule); + + virtual ~VisuGUI_ViewExtender(); + + virtual int createToolbar(QtxActionToolMgr* theMgr); + virtual void contextMenuPopup(QMenu* theMenu); + + virtual void activate(); + virtual void deactivate(); + +private slots: + void onPlanesMgr(); + void onDialogDestroy(); + + private: + enum { ClippingPlaneMgrId }; + + QMap myActionsMap; + VisuGUI* myModule; + + QDialog* myNonModalDlg; +}; + + +#endif