]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
*** empty log message ***
authorvsv <vsv@opencascade.com>
Fri, 11 Jul 2008 14:35:44 +0000 (14:35 +0000)
committervsv <vsv@opencascade.com>
Fri, 11 Jul 2008 14:35:44 +0000 (14:35 +0000)
15 files changed:
src/VISUGUI/Makefile.am
src/VISUGUI/VISU_msg_en.ts
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI.h
src/VISUGUI/VisuGUI_ActionsDef.h
src/VISUGUI/VisuGUI_ClippingPanel.cxx [new file with mode: 0644]
src/VISUGUI/VisuGUI_ClippingPanel.h [new file with mode: 0644]
src/VISUGUI/VisuGUI_ClippingPlaneDlg.cxx [new file with mode: 0644]
src/VISUGUI/VisuGUI_ClippingPlaneDlg.h [new file with mode: 0644]
src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx
src/VISUGUI/VisuGUI_DeformedShapeDlg.h
src/VISUGUI/VisuGUI_Prs3dTools.h
src/VISUGUI/VisuGUI_SegmentationMgr.h
src/VISUGUI/VisuGUI_Tools.cxx
src/VISUGUI/VisuGUI_Tools.h

index 50a9a6bb253e43b8a0eadb477b9d40730b69451b..3d629cb5e441937c72279625a7975e1e0fa2e9bf 100644 (file)
@@ -81,7 +81,9 @@ dist_libVISU_la_SOURCES= \
        VisuGUI_FieldFilter.cxx \
        VisuGUI_ViewExtender.cxx \
        VisuGUI_ClippingPlaneMgr.cxx \
-       VisuGUI_SegmentationMgr.cxx
+       VisuGUI_SegmentationMgr.cxx \
+       VisuGUI_ClippingPanel.cxx \
+       VisuGUI_ClippingPlaneDlg.cxx
 
 MOC_FILES= \
        VisuGUI_moc.cxx \
@@ -121,7 +123,10 @@ MOC_FILES= \
        VisuGUI_InputPane_moc.cxx \
        VisuGUI_ViewExtender_moc.cxx \
        VisuGUI_ClippingPlaneMgr_moc.cxx \
-       VisuGUI_SegmentationMgr_moc.cxx
+       VisuGUI_SegmentationMgr_moc.cxx \
+       VisuGUI_ClippingPanel_moc.cxx \
+       VisuGUI_ClippingPlaneDlg_moc.cxx
+
 
 nodist_libVISU_la_SOURCES=$(MOC_FILES)
 
index 3f3c64a2b221e91b51af3c9f175cc9d56f0155ef..c09967b760592c1e1a00ed24e812da97688d09e2 100644 (file)
@@ -3560,4 +3560,98 @@ Please, refer to the documentation.</translation>
             <translation>Activate/Deactivate clipping planes</translation>
         </message>
     </context>
+    <context>
+        <name>VisuGUI_ClippingPanel</name>
+        <message>
+            <source>TITLE</source>
+            <translation>Clipping Planes</translation>
+        </message>
+        <message>
+            <source>PRESENTATIONS_LBL</source>
+            <translation>Presentations:</translation>
+        </message>
+        <message>
+            <source>PLANES_LBL</source>
+            <translation>Associated planes:</translation>
+        </message>
+        <message>
+            <source>NEW_BTN</source>
+            <translation>New...</translation>
+        </message>
+        <message>
+            <source>EDIT_BTN</source>
+            <translation>Edit...</translation>
+        </message>
+        <message>
+            <source>DELETE_BTN</source>
+            <translation>Delete</translation>
+        </message>
+        <message>
+            <source>TIT_DELETE_PLANE</source>
+            <translation>Delete clipping plane</translation>
+        </message>
+        <message>
+            <source>MSG_DELETE_PLANE</source>
+            <translation>Clipping plane %1 will be deleted. Continue?</translation>
+        </message>
+        <message>
+            <source>CHK_SHOW_PLANES</source>
+            <translation>Show planes preview</translation>
+        </message>
+        <message>
+            <source>CHK_ACTIVATE_PLANES</source>
+            <translation>Deactivate planes</translation>
+        </message>
+        <message>
+            <source>CHK_AUTO_APPLY</source>
+            <translation>Auto apply</translation>
+        </message>
+    </context>
+    <context>
+        <name>VisuGUI_ClippingPlaneDlg</name>
+        <message>
+            <source>TITLE</source>
+            <translation>Clipping plane edit</translation>
+        </message>
+       <message>
+            <source>LBL_NAME</source>
+            <translation>Name of the plane</translation>
+        </message>
+        <message>
+            <source>BYVECTOR_TITLE</source>
+            <translation>Normal vector</translation>
+        </message>
+        <message>
+            <source>BYPLANE_TITLE</source>
+            <translation>Main plane</translation>
+        </message>
+        <message>
+            <source>CHK_AUTOAPPLY</source>
+            <translation>Auto apply</translation>
+        </message>
+        <message>
+            <source>CHK_SHOW_PREVIEW</source>
+            <translation>Show preview</translation>
+        </message>
+        <message>
+            <source>ORIGIN_TITLE</source>
+            <translation>Origin</translation>
+        </message>
+        <message>
+            <source>DIRECTION_TITLE</source>
+            <translation>Direction</translation>
+        </message>
+        <message>
+            <source>LBL_ORIENTATION</source>
+            <translation>Orientation</translation>
+        </message>
+        <message>
+            <source>LBL_DISTANCE</source>
+            <translation>Distance</translation>
+        </message>
+        <message>
+            <source>LBL_ROTATION</source>
+            <translation>Rotation around %1</translation>
+        </message>
+    </context>
 </TS>
index 6757875bb0cde96398be939b9d80e61bb2b6c483..03adac48046d2854305333b5d8459f40c7620b1e 100644 (file)
 #include "VisuGUI_Displayer.h"
 #include "VisuGUI_BuildProgressDlg.h"
 #include "VisuGUI_TransparencyDlg.h"
+#include "VisuGUI_ClippingPanel.h"
 
 #include "VISU_ScalarMap_i.hh"
 #include "VisuGUI_ScalarBarDlg.h"
@@ -629,7 +630,8 @@ VisuGUI
   SVTK_ViewWindow* aViewWindow = GetViewWindow<SVTK_Viewer>(this);
 
   // create mesh presentation and display it in aViewWindow
-  CreateMesh(this, anIO, aViewWindow);
+  VISU::Mesh_i* aPrs = CreateMesh(this, anIO, aViewWindow);
+  emit presentationCreated(aPrs);
 }
 
 void
@@ -654,7 +656,8 @@ VisuGUI
       return;
 
     // create mesh presentation and display it in aViewWindow
-    CreateMesh(this, anIO, aViewWindow);
+    VISU::Mesh_i* aPrs = CreateMesh(this, anIO, aViewWindow);
+    emit presentationCreated(aPrs);
   }
 }
 
@@ -662,7 +665,8 @@ void
 VisuGUI
 ::OnCreateScalarMap()
 {
-  CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
+  Prs3d_i* aPrs = CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
+  emit presentationCreated(aPrs);
 }
 
 
@@ -671,56 +675,64 @@ VisuGUI
 ::OnCreateDeformedShape()
 {
   //  CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
-  VisuGUI_DeformedShapeDlg::CreatePrs3d(this);
+  Prs3d_i* aPrs = VisuGUI_DeformedShapeDlg::CreatePrs3d(this);
+  emit presentationCreated(aPrs);
 }
 
 void
 VisuGUI
 ::OnCreateScalarMapOnDeformedShape()
 {
-  CreatePrs3d<VISU::ScalarMapOnDeformedShape_i,VisuGUI_ScalarMapOnDeformedShapeDlg,1>(this);
+  Prs3d_i* aPrs = CreatePrs3d<VISU::ScalarMapOnDeformedShape_i,VisuGUI_ScalarMapOnDeformedShapeDlg,1>(this);
+  emit presentationCreated(aPrs);
 }
 
 void
 VisuGUI
 ::OnCreateVectors()
 {
-  CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
+  Prs3d_i* aPrs = CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
+  emit presentationCreated(aPrs);
 }
 
 void
 VisuGUI
 ::OnCreateIsoSurfaces()
 {
-  CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
+  Prs3d_i* aPrs = CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
+  emit presentationCreated(aPrs);
 }
 
 void
 VisuGUI
 ::OnCreateCutPlanes()
 {
-  CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,0>(this);
+  Prs3d_i* aPrs = CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,0>(this);
+  emit presentationCreated(aPrs);
 }
 
 void
 VisuGUI
 ::OnCreateCutLines()
 {
-  CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,0>(this);
+  Prs3d_i* aPrs = CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,0>(this);
+  emit presentationCreated(aPrs);
 }
 
 void
 VisuGUI
 ::OnCreateStreamLines()
 {
-  CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
+  Prs3d_i* aPrs = CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
+  emit presentationCreated(aPrs);
 }
 
 void
 VisuGUI
 ::OnCreatePlot3D()
 {
-  CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,0>(this);
+  Prs3d_i* aPrs = CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,0>(this);
+  emit presentationCreated(aPrs);
 }
 
 void
@@ -1606,6 +1618,8 @@ VisuGUI
          break;
        }
        default: {
+         if(VISU::Prs3d_i* aPrs = dynamic_cast<VISU::Prs3d_i*>(aBase))
+           aPrs->SetName((const char*)Name.toLatin1(), true);
        }}
       }
     }
@@ -2759,6 +2773,7 @@ void VisuGUI::createPanels()
 {
   myPanels.insert( SelectionPanelId,    new VisuGUI_SelectionPanel( this ) );
   myPanels.insert( FeatureEdgesPanelId, new VisuGUI_FeatureEdgesPanel( this ) );
+  myPanels.insert( ClippingPlanesPanelId, new VisuGUI_ClippingPanel( this ) );
 
   QMap< PanelId, VisuGUI_Panel* >::iterator it = myPanels.begin(), itEnd = myPanels.end();
   for( ; it != itEnd; ++it )
@@ -3665,6 +3680,7 @@ void VisuGUI::OnPlot3dFromCutPlane()
 
          AddScalarBarPosition(this, aSVtkWindow, aPrs3d, aPos);
        }
+       emit presentationCreated(aPrs3d);
      }
    }
    application()->putInfo(QObject::tr("INF_DONE"));
index 1ce6b8d1281f30b392d9b952ce831db875f041d0..b7ba9a78fb1b1a87c008f1877c658aede4f75c31 100644 (file)
@@ -57,7 +57,8 @@ class VisuGUI: public SalomeApp_Module
 
 public:
   enum PanelId { SelectionPanelId = 0,
-                FeatureEdgesPanelId };
+                FeatureEdgesPanelId,
+                 ClippingPlanesPanelId };
 
 public:
   VisuGUI();
@@ -88,6 +89,7 @@ public:
 signals:
   void moduleDeactivated();
   void moduleActivated();
+  void presentationCreated(VISU::Prs3d_i* thePrs);
 
 public slots:
   virtual bool deactivateModule( SUIT_Study* );
index 72c49e657d27a4bdf6c6f8d041ad269b201350f2..8c310db81f2d864ff3a32485dd596a091139671f 100644 (file)
 
 #define VISU_SLIDER_PANEL           4200
 #define VISU_SWEEP_PANEL            4300
+#define VISU_GLOBALCLIPPING         4301
 
 #endif
diff --git a/src/VISUGUI/VisuGUI_ClippingPanel.cxx b/src/VISUGUI/VisuGUI_ClippingPanel.cxx
new file mode 100644 (file)
index 0000000..b08f456
--- /dev/null
@@ -0,0 +1,477 @@
+// 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_ClippingPanel.h"
+#include "VisuGUI.h"
+#include "VisuGUI_Tools.h"
+#include "VisuGUI_ClippingPlaneDlg.h"
+#include "VisuGUI_ViewTools.h"
+
+#include <LightApp_Application.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_Session.h>
+#include <SUIT_ViewManager.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_ViewWindow.h>
+#include <SVTK_ViewWindow.h>
+#include <VTKViewer_Utilities.h>
+
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QPushButton>
+#include <QToolButton>
+#include <QGroupBox>
+#include <QListWidget>
+#include <QStringList>
+#include <QMessageBox>
+#include <QCheckBox>
+
+#include <SALOMEDSClient_AttributeSequenceOfReal.hxx>
+#include <SALOMEDSClient_AttributeInteger.hxx>
+
+VisuGUI_ClippingPanel::VisuGUI_ClippingPanel(VisuGUI* theModule)
+  : VisuGUI_Panel(tr("TITLE"), theModule, VISU::GetDesktop(theModule), ApplyBtn | HelpBtn ),
+    myModule(theModule),
+    myPlaneDlg(0),
+    myViewWindow(0)
+{
+  QVBoxLayout* aMainLayout = new QVBoxLayout(mainFrame());
+
+  // List of presentations
+  aMainLayout->addWidget(new QLabel(tr("PRESENTATIONS_LBL"), mainFrame()));
+  myPrsList = new QListWidget(mainFrame());
+  myPrsList->setSelectionMode(QAbstractItemView::SingleSelection);
+  aMainLayout->addWidget(myPrsList);
+
+  // List of planes
+  aMainLayout->addWidget(new QLabel(tr("PLANES_LBL"), mainFrame()));
+  myPlanesList = new QListWidget(mainFrame());
+  myPlanesList->setSelectionMode(QAbstractItemView::SingleSelection);
+  aMainLayout->addWidget(myPlanesList);
+  
+  // Management buttons
+  QWidget* aButtonsWgt = new QWidget(mainFrame());
+  QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtonsWgt);
+  aMainLayout->addWidget(aButtonsWgt);
+
+  QToolButton* aNewBtn = new QToolButton(aButtonsWgt);
+  aNewBtn->setToolButtonStyle(Qt::ToolButtonTextOnly);
+  aNewBtn->setText(tr("NEW_BTN"));
+  connect(aNewBtn, SIGNAL(clicked(bool)), this, SLOT(onNew()));
+  aBtnLayout->addWidget(aNewBtn);
+
+  QToolButton* aEditBtn = new QToolButton(aButtonsWgt);
+  aEditBtn->setToolButtonStyle(Qt::ToolButtonTextOnly);
+  aEditBtn->setText(tr("EDIT_BTN"));
+  connect(aEditBtn, SIGNAL(clicked(bool)), this, SLOT(onEdit()));
+  aBtnLayout->addWidget(aEditBtn);
+
+  QToolButton* aDeleteBtn = new QToolButton(aButtonsWgt);
+  aDeleteBtn->setToolButtonStyle(Qt::ToolButtonTextOnly);
+  aDeleteBtn->setText(tr("DELETE_BTN"));
+  connect(aDeleteBtn, SIGNAL(clicked(bool)), this, SLOT(onPlaneDelete()));
+  aBtnLayout->addWidget(aDeleteBtn);
+
+  myShowPlanes = new QCheckBox(tr("CHK_SHOW_PLANES"), mainFrame());
+  connect(myShowPlanes, SIGNAL( toggled(bool) ), this, SLOT( setPlanesVisible(bool) ));
+  aMainLayout->addWidget(myShowPlanes);
+
+  myNonActivePlanes = new QCheckBox(tr("CHK_ACTIVATE_PLANES"), mainFrame());
+  connect(myNonActivePlanes, SIGNAL(toggled(bool)), this, SLOT(setPlanesNonActive(bool)));
+  aMainLayout->addWidget(myNonActivePlanes);
+
+  myAutoApply = new QCheckBox(tr("CHK_AUTO_APPLY"), mainFrame());
+  aMainLayout->addWidget(myAutoApply);
+
+
+  fillPrsList();
+  fillPlanesList();
+
+  connect(myModule, SIGNAL(presentationCreated(VISU::Prs3d_i*)), 
+         this, SLOT(onPresentationCreate(VISU::Prs3d_i*)));
+
+  SUIT_Desktop* aDesktop = VISU::GetDesktop(myModule);
+  connect(aDesktop, SIGNAL(windowActivated(SUIT_ViewWindow*)), this, SLOT(onWindowActivated(SUIT_ViewWindow*)));
+}
+  
+
+//*************************************************************************
+VisuGUI_ClippingPanel::~VisuGUI_ClippingPanel()
+{
+}
+
+
+//*************************************************************************
+void VisuGUI_ClippingPanel::fillPrsList()
+{
+  myPrsList->clear();
+  _PTR(Study) aStudy = VISU::GetCStudy(VISU::GetAppStudy(myModule));
+  _PTR(SComponent) aVisuSO = aStudy->FindComponent("VISU");
+  if (!aVisuSO) {
+    return;
+  }
+  myPresentations = getPrsList(aStudy, aVisuSO);
+  QStringList aNames;
+  for (int i = 0; i < myPresentations.size(); i++) {
+    aNames.append(myPresentations.at(i)->GetName().c_str());
+  }
+  myPrsList->addItems(aNames);
+}
+
+//*************************************************************************
+QList<VISU::Prs3d_i*> VisuGUI_ClippingPanel::getPrsList(_PTR(Study) theStudy, 
+                                                              _PTR(SObject) theObject)
+{
+  QList<VISU::Prs3d_i*> aList;
+  _PTR(ChildIterator) aIter = theStudy->NewChildIterator(theObject);
+  for (aIter->InitEx(true); aIter->More(); aIter->Next()) {
+    _PTR(SObject) aSObject = aIter->Value();
+    std::vector<VISU::Prs3d_i*> aSTLList = VISU::GetPrs3dList(myModule, aSObject);
+    for (int i = 0; i < aSTLList.size(); i++) {
+      VISU::Prs3d_i* aPrs = aSTLList[i];
+      if (!aList.contains(aPrs))
+       aList.append(aPrs);
+    }
+    if (aList.size() == 0) {
+      QList<VISU::Prs3d_i*> aSubList = getPrsList(theStudy, aSObject);
+       for (int i = 0; i < aSubList.size(); i++) {
+       VISU::Prs3d_i* aPrs = aSubList[i];
+       if (!aList.contains(aPrs))
+         aList.append(aSubList[i]);
+      }
+    }
+  }
+  return aList;
+}
+
+//*************************************************************************
+void VisuGUI_ClippingPanel::fillPlanesList()
+{
+  myPlanesList->clear();
+  myPlanes.clear();
+  _PTR(Study) aStudy = VISU::GetCStudy(VISU::GetAppStudy(myModule));
+  _PTR(SObject) aFolder;
+  if (VISU::getClippingPlanesFolder(aStudy, aFolder)) {
+    _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aFolder);
+    int i;
+    for (aIter->InitEx(true), i = 0; aIter->More(); aIter->Next(), i++) {
+      _PTR(SObject) aSObject = aIter->Value();
+      PlaneDef aNewPlane = createEmptyPlane();
+      updatePlane(aSObject, aNewPlane);
+
+      QListWidgetItem* aItem = new QListWidgetItem(aNewPlane.name, myPlanesList);
+
+      if (aNewPlane.isAuto) {
+       aItem->setFlags(0);
+       aItem->setCheckState(Qt::Checked);
+      } else {
+       aItem->setCheckState(Qt::Unchecked);
+      }
+      myPlanesList->addItem(aItem);
+      myPlanes.append(aNewPlane);
+    }
+  }
+}
+
+//*************************************************************************
+void VisuGUI_ClippingPanel::showEvent(QShowEvent* event)
+{
+  fillPrsList();
+  VisuGUI_Panel::showEvent(event);
+}
+
+//*************************************************************************
+// void VisuGUI_ClippingPanel::hideEvent(QHideEvent* event)
+// {
+//   disconnect(myModule, SIGNAL(presentationCreated()), this, SLOT(onPresentationCreate()));
+//   VisuGUI_Panel::hideEvent(event);
+// }
+
+//*************************************************************************
+void VisuGUI_ClippingPanel::onPresentationCreate(VISU::Prs3d_i* thePrs)
+{
+  myPrsList->addItem(thePrs->GetName().c_str());
+  myPresentations.append(thePrs);
+  for (int i = 0; i < myPlanes.size(); i++) {
+    const PlaneDef& aPlane = myPlanes.at(i);
+    if (aPlane.isAuto)
+      thePrs->AddClippingPlane(aPlane.plane);
+  }
+}
+
+//*************************************************************************
+PlaneDef VisuGUI_ClippingPanel::createEmptyPlane()
+{
+  PlaneDef aPlane;
+  aPlane.name = QString("Plane");
+  aPlane.plane = CutPlaneFunction::New();
+  aPlane.plane->Delete();
+  aPlane.plane->SetOrigin(0.,0.,0.);
+  aPlane.plane->SetNormal(0.,0.,1.);
+  aPlane.isAuto = true;
+  return aPlane;
+}
+
+//*************************************************************************
+void VisuGUI_ClippingPanel::updatePlane(_PTR(SObject) theObject, PlaneDef& thePlane)
+{
+  thePlane.name = QString(theObject->GetName().c_str());
+  thePlane.plane->setPlaneObject(theObject);
+
+  _PTR(GenericAttribute) anAttr;
+  if (theObject->FindAttribute(anAttr, "AttributeSequenceOfReal")) {
+    _PTR(AttributeSequenceOfReal) aArray(anAttr);
+    thePlane.plane->SetOrigin(aArray->Value(1), aArray->Value(2), aArray->Value(3));
+    thePlane.plane->SetNormal(aArray->Value(4), aArray->Value(5), aArray->Value(6));
+  }
+  if (theObject->FindAttribute(anAttr, "AttributeInteger")) {
+    _PTR(AttributeInteger) aFlag(anAttr);
+    thePlane.isAuto = (aFlag->Value() == 1);
+  }
+}
+  
+//*************************************************************************
+void VisuGUI_ClippingPanel::onNewPlane()
+{
+  disconnect(myPlaneDlg, SIGNAL(accepted()), this, SLOT(onNewPlane()));
+  disconnect(myPlaneDlg, SIGNAL(rejected()), this, SLOT(onCancelDialog()));
+  _PTR(SObject) aPlaneSObj = myPlaneDlg->getPlaneObj();
+
+  PlaneDef aNewPlane = createEmptyPlane();
+  updatePlane(aPlaneSObj, aNewPlane);
+
+  QListWidgetItem* aItem = new QListWidgetItem(aNewPlane.name, myPlanesList);
+  if (aNewPlane.isAuto) {
+    aItem->setFlags(0);
+    aItem->setCheckState(Qt::Checked);
+    for (int i = 0; i < myPresentations.size(); i++) {
+      myPresentations.at(i)->AddClippingPlane(aNewPlane.plane);
+    }
+  } else {
+    aItem->setCheckState(Qt::Unchecked);
+  }
+  myPlanesList->addItem(aItem);
+  myPlanes.append(aNewPlane);
+
+  delete myPlaneDlg;
+  myPlaneDlg = 0;
+
+  setPlanesVisible(myShowPlanes->checkState() == Qt::Checked);
+  
+  if (myViewWindow)
+    myViewWindow->Repaint();
+}
+
+//*************************************************************************
+void VisuGUI_ClippingPanel::onPlaneEdited() 
+{
+  disconnect(myPlaneDlg, SIGNAL(accepted()), this, SLOT(onNewPlane()));
+  disconnect(myPlaneDlg, SIGNAL(rejected()), this, SLOT(onCancelDialog()));
+  _PTR(SObject) aPlaneSObj = myPlaneDlg->getPlaneObj();
+
+  PlaneDef aPlane = myPlanes.at(myEditingPlanePos);
+  updatePlane(aPlaneSObj, aPlane);
+
+  delete myPlaneDlg;
+  myPlaneDlg = 0;
+
+  setPlanesVisible(myShowPlanes->checkState() == Qt::Checked);
+
+  if (myViewWindow)
+    myViewWindow->Repaint();
+}
+
+//*************************************************************************
+void VisuGUI_ClippingPanel::onEdit()
+{
+  if (!isVISUDataReady()) return;
+  if (myPlaneDlg) return;
+
+  int aRow = myPlanesList->currentRow();
+  if (aRow < 0) return;
+
+  const PlaneDef& aPlane = myPlanes.at(aRow);
+
+  myPlaneDlg = new VisuGUI_ClippingPlaneDlg(myModule);
+  myPlaneDlg->setPlaneObj(aPlane.plane->getPlaneObject());
+  connect(myPlaneDlg, SIGNAL(accepted()), this, SLOT(onPlaneEdited()));
+  connect(myPlaneDlg, SIGNAL(rejected()), this, SLOT(onCancelDialog()));
+  myEditingPlanePos = aRow;
+  myPlaneDlg->show();
+}
+
+//*************************************************************************
+void VisuGUI_ClippingPanel::onNew()
+{
+  if (!isVISUDataReady()) return;
+
+  if (myPlaneDlg) return;
+
+  myPlaneDlg = new VisuGUI_ClippingPlaneDlg(myModule);
+  connect(myPlaneDlg, SIGNAL(accepted()), this, SLOT(onNewPlane()));
+  connect(myPlaneDlg, SIGNAL(rejected()), this, SLOT(onCancelDialog()));
+  myPlaneDlg->show();
+}
+
+//*************************************************************************
+void VisuGUI_ClippingPanel::onPlaneDelete()
+{
+  if (!isVISUDataReady()) return;
+  if (myPlaneDlg) return;
+
+  _PTR(Study) aStudy = VISU::GetCStudy( VISU::GetAppStudy( myModule ) );
+  
+  
+  int aRow = myPlanesList->currentRow();
+  if (aRow < 0) return;
+
+  const PlaneDef& aPlane = myPlanes.at(aRow);
+  QMessageBox::StandardButton aRes = QMessageBox::warning(VISU::GetDesktop(myModule), 
+                                                         tr("TIT_DELETE_PLANE"), 
+                                                         tr("MSG_DELETE_PLANE").arg(aPlane.name), 
+                                                         QMessageBox::Yes | QMessageBox::No, 
+                                                         QMessageBox::No);
+  if (aRes == QMessageBox::Yes) {
+    short aTag1 = aPlane.plane->getPlaneObject()->Tag();
+    for (int i = 0; i < myPresentations.size(); i++) {
+      VISU::Prs3d_i* aPrs = myPresentations.at(i);
+      for (int j = aPrs->GetNumberOfClippingPlanes()-1; j > -1; j--) {
+       CutPlaneFunction* aPln = dynamic_cast<CutPlaneFunction*>(aPrs->GetClippingPlane(j));
+       if (aPln) {
+         short aTag2 = aPln->getPlaneObject()->Tag();
+         if (aTag1 == aTag2) {
+           aPrs->RemoveClippingPlane(j);
+         }
+       }
+      }
+    }
+
+    _PTR(SObject) aSObj = aPlane.plane->getPlaneObject();
+    _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+    aBuilder->RemoveObject(aSObj);
+    
+    myPlanesList->takeItem(aRow);
+    myPlanes.removeAt(aRow);
+    
+    VISU::UpdateObjBrowser(myModule);
+    
+    if (myViewWindow)
+      myViewWindow->Repaint();
+  }
+}
+
+//*************************************************************************
+bool VisuGUI_ClippingPanel::isVISUDataReady() 
+{
+  _PTR(Study) aStudy = VISU::GetCStudy( VISU::GetAppStudy( myModule ) );
+
+  _PTR(SComponent) aVisuSO = aStudy->FindComponent("VISU");
+  if (!aVisuSO) return false;
+
+  if(aStudy->GetProperties()->IsLocked()) return false;
+  return true;
+}
+
+//*************************************************************************
+void VisuGUI_ClippingPanel::onApply()
+{
+
+}
+
+//*************************************************************************
+void VisuGUI_ClippingPanel::setPlanesNonActive(bool theState)
+{
+  PlaneDef aPlane;
+  for (int i = 0; i < myPlanes.size(); i++) {
+    aPlane = myPlanes.at(i);
+    aPlane.plane->setActive(!theState);
+  }
+  if (myViewWindow)
+    myViewWindow->Repaint();
+}
+
+//*************************************************************************
+void VisuGUI_ClippingPanel::setPlanesVisible(bool theVisible)
+{
+  if (!myViewWindow) return;
+
+  if (theVisible) {
+    // Hide previous
+    setPlanesVisible(false);
+
+    double aBounds[6];
+    ComputeVisiblePropBounds(myViewWindow->getRenderer(), aBounds);
+    for (int i = 0; i < myPlanes.size(); i++) {
+      PreviewPlane* aPreview = new PreviewPlane(myViewWindow, myPlanes.at(i), aBounds);
+      aPreview->setVisible(true);
+      myPreview.append(aPreview);
+    }
+  } else {
+    PreviewPlane* aPreview;
+    while (myPreview.size() > 0) {
+      aPreview = myPreview.last();
+      myPreview.removeLast();
+      delete aPreview;
+    }
+  }
+  myViewWindow->Repaint();
+}
+
+//*************************************************************************
+void VisuGUI_ClippingPanel::onCancelDialog()
+{
+  disconnect(myPlaneDlg, SIGNAL(accepted()), this, SLOT(onNewPlane()));
+  disconnect(myPlaneDlg, SIGNAL(rejected()), this, SLOT(onCancelDialog()));
+
+  delete myPlaneDlg;
+  myPlaneDlg = 0;
+}
+
+
+//*************************************************************************
+void VisuGUI_ClippingPanel::onWindowActivated(SUIT_ViewWindow* theWindow)
+{
+  myViewWindow = dynamic_cast<SVTK_ViewWindow*>(theWindow);
+  printf("#### New window activated\n");
+}
+
+
+//*************************************************************************
+void VisuGUI_ClippingPanel::onHelp()
+{
+  QString aHelpFileName = "clipping_planes_page.html";
+  LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+  if (app)
+    app->onHelpContextModule(myModule ? app->moduleName(myModule->moduleName()) : QString(""), aHelpFileName);
+  else {
+    QString platform;
+#ifdef WIN32
+    platform = "winapplication";
+#else
+    platform = "application";
+#endif
+    SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
+                             QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+                             arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName),
+                             QObject::tr("BUT_OK"));
+  }
+}
diff --git a/src/VISUGUI/VisuGUI_ClippingPanel.h b/src/VISUGUI/VisuGUI_ClippingPanel.h
new file mode 100644 (file)
index 0000000..7999342
--- /dev/null
@@ -0,0 +1,98 @@
+// 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_CLIPPINGPANEL_H
+#define DIALOGBOX_CLIPPINGPANEL_H
+
+
+class VisuGUI;
+class QListWidget;
+class VisuGUI_ClippingPlaneDlg;
+class QCheckBox;
+class SVTK_ViewWindow;
+class SUIT_ViewWindow;
+
+#include "VISU_Prs3d_i.hh"
+#include "VisuGUI_Panel.h"
+#include <VisuGUI_SegmentationMgr.h>
+
+#include <QList>
+
+#include <SALOMEDSClient_SObject.hxx>
+
+class VisuGUI_ClippingPanel: public VisuGUI_Panel
+{
+  Q_OBJECT
+public:
+  VisuGUI_ClippingPanel(VisuGUI* theModule);
+  ~VisuGUI_ClippingPanel();
+
+protected:
+  virtual void showEvent(QShowEvent* event);
+  //virtual void hideEvent(QHideEvent* event);
+
+public slots:
+  void onPresentationCreate(VISU::Prs3d_i* thePrs);
+
+protected slots:
+  virtual void onApply();
+  virtual void onHelp();
+
+private slots:
+  void onNew();
+  void onNewPlane();
+  void onEdit();
+  void onPlaneEdited();
+  void onPlaneDelete();
+  void onCancelDialog();
+  void setPlanesNonActive(bool theState);
+  void setPlanesVisible(bool theVisible);
+  void onWindowActivated(SUIT_ViewWindow* theWindow);
+
+ private:
+  void fillPrsList();
+  void fillPlanesList();
+
+  void updatePlane(_PTR(SObject) theObject, PlaneDef& thePlane);
+  PlaneDef createEmptyPlane();
+
+  bool isVISUDataReady();
+
+  QList<VISU::Prs3d_i*> getPrsList(_PTR(Study) theStudy, _PTR(SObject) theObject);
+
+  VisuGUI*   myModule;
+
+  QListWidget* myPrsList;
+  QListWidget* myPlanesList;
+
+  QCheckBox* myShowPlanes;
+  QCheckBox* myNonActivePlanes;
+  QCheckBox* myAutoApply;
+  
+  QListOfPlanes myPlanes;
+  QList<VISU::Prs3d_i*> myPresentations;
+  ListOfPreview myPreview;
+
+  VisuGUI_ClippingPlaneDlg* myPlaneDlg;
+  int myEditingPlanePos;
+  SVTK_ViewWindow* myViewWindow;
+};
+
+#endif
diff --git a/src/VISUGUI/VisuGUI_ClippingPlaneDlg.cxx b/src/VISUGUI/VisuGUI_ClippingPlaneDlg.cxx
new file mode 100644 (file)
index 0000000..219b9ad
--- /dev/null
@@ -0,0 +1,362 @@
+// 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_ClippingPlaneDlg.h"
+#include "VisuGUI.h"
+#include "VisuGUI_Tools.h"
+#include "VisuGUI_ViewTools.h"
+
+#include <LightApp_Application.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_Session.h>
+#include <SUIT_ViewManager.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_ResourceMgr.h>
+#include <QtxDoubleSpinBox.h>
+#include <SVTK_ViewWindow.h>
+#include <VTKViewer_Utilities.h>
+
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QLineEdit>
+#include <QWidget>
+#include <QGroupBox>
+#include <QGridLayout>
+#include <QCheckBox>
+#include <QPushButton>
+
+#include <vtkCallbackCommand.h>
+#include <vtkImplicitPlaneWidget.h>
+
+
+#define SIZEFACTOR 1.5
+
+
+
+
+//****************************************************************
+//****************************************************************
+//****************************************************************
+VisuGUI_ClippingPlaneDlg::VisuGUI_ClippingPlaneDlg(VisuGUI* theModule)
+  : QDialog(VISU::GetDesktop(theModule), Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
+    myModule(theModule),
+    myCallback( vtkCallbackCommand::New() ),
+    myPreviewWidget(0),
+    myViewWindow(0)
+{
+  myViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(myModule);
+  ComputeVisiblePropBounds(myViewWindow->getRenderer(), myBounds);
+
+  setWindowTitle(tr("TITLE"));
+  setSizeGripEnabled(true);
+  setModal(false);
+
+  myCallback->SetClientData(this); 
+  myCallback->SetCallback(VisuGUI_ClippingPlaneDlg::ProcessEvents);
+
+  QVBoxLayout* aMainLayout = new QVBoxLayout(this);
+
+  QWidget* aPlanesWgt = new QWidget(this);
+  aMainLayout->addWidget(aPlanesWgt);
+  QVBoxLayout* aFrameLayout = new QVBoxLayout(aPlanesWgt);
+
+  QWidget* aNameBox = new QWidget(aPlanesWgt);
+  aFrameLayout->addWidget(aNameBox);
+  QHBoxLayout* aNameLayout = new QHBoxLayout(aNameBox);
+
+  aNameLayout->addWidget(new QLabel(tr("LBL_NAME"), aPlanesWgt));
+  myNameEdt = new QLineEdit();
+  
+  _PTR(Study) aStudy = VISU::GetCStudy(VISU::GetAppStudy(myModule));
+  _PTR(SObject) aFolderSO;
+  if (VISU::getClippingPlanesFolder(aStudy, aFolderSO)) {
+    _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aFolderSO);
+    int i = 1;
+    for (; aIter->More(); aIter->Next()) i++;
+
+    myNameEdt->setText(QString("Plane %1").arg(i));
+  }
+  aNameLayout->addWidget(myNameEdt);
+
+  QGroupBox* aOriginGroup = new QGroupBox( tr( "ORIGIN_TITLE" ), aPlanesWgt );
+  aFrameLayout->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 );
+  connect(myXOrigin, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged()));
+  aOriginLayout->addWidget( myXOrigin );
+
+  aOriginLayout->addWidget( new QLabel("Y", aOriginGroup) );
+  myYOrigin = new QtxDoubleSpinBox( -1000.0, 1000, 0.1, aOriginGroup );
+  myYOrigin->setValue( 0.0 );
+  connect(myYOrigin, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged()));
+  aOriginLayout->addWidget( myYOrigin );
+
+  aOriginLayout->addWidget( new QLabel("Z", aOriginGroup) );
+  myZOrigin = new QtxDoubleSpinBox( -1000.0, 1000.0, 0.1, aOriginGroup );
+  myZOrigin->setValue( 0.0 );
+  connect(myZOrigin, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged()));
+  aOriginLayout->addWidget( myZOrigin );
+  
+  QGroupBox* aDirGroup = new QGroupBox( tr( "DIRECTION_TITLE" ), aPlanesWgt );
+  aFrameLayout->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 );
+  connect(myXDir, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged()));
+  aDirLayout->addWidget( myXDir );
+
+  aDirLayout->addWidget( new QLabel("dY", aDirGroup) );
+  myYDir = new QtxDoubleSpinBox( -1000.0, 1000.0, 0.1, aDirGroup );
+  myYDir->setValue( 0.0 );
+  connect(myYDir, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged()));
+  aDirLayout->addWidget( myYDir );
+
+  aDirLayout->addWidget( new QLabel("dZ", aDirGroup) );
+  myZDir = new QtxDoubleSpinBox( -1000.0, 1000.0, 0.1, aDirGroup );
+  myZDir->setValue( 1.0 );
+  connect(myZDir, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged()));
+  aDirLayout->addWidget( myZDir );
+
+  myAutoApply = new QCheckBox(tr("CHK_AUTOAPPLY"), aPlanesWgt);
+  myAutoApply->setCheckState(Qt::Checked);
+  aFrameLayout->addWidget(myAutoApply);
+
+  // Dialog buttons
+  QGroupBox* aGroupButtons = new QGroupBox (this);
+  aMainLayout->addWidget(aGroupButtons);
+
+  QSizePolicy aSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed );
+  QHBoxLayout* aButtonsLayout = new QHBoxLayout(aGroupButtons);
+
+  QPushButton* aBtnOk = new QPushButton(tr("BUT_OK"), aGroupButtons);
+  aButtonsLayout->addWidget(aBtnOk);
+
+  aButtonsLayout->addStretch();
+
+  QPushButton* aBtnClose = new QPushButton(tr("BUT_CANCEL"), aGroupButtons);
+  aButtonsLayout->addWidget(aBtnClose);
+
+  QPushButton* aBtnHelp = new QPushButton(tr("BUT_HELP"), aGroupButtons);
+  aButtonsLayout->addWidget(aBtnHelp);
+
+  connect(aBtnOk   , SIGNAL(clicked()), this, SLOT(accept()));
+  connect(aBtnClose, SIGNAL(clicked()), this, SLOT(reject()));
+  connect(aBtnHelp , SIGNAL(clicked()), this, SLOT(onHelp()));
+
+
+  myPreviewWidget = createPreviewWidget();
+  myViewWindow->Repaint();
+}
+
+VisuGUI_ClippingPlaneDlg::~VisuGUI_ClippingPlaneDlg()
+{
+  if (myPreviewWidget) {
+    myPreviewWidget->Off();
+    myPreviewWidget->Delete();
+  }
+  myPreviewWidget = 0;
+  myCallback->Delete();
+}
+
+//****************************************************************
+void VisuGUI_ClippingPlaneDlg::ProcessEvents(vtkObject* theObject, 
+                                            unsigned long theEvent,
+                                            void* theClientData, 
+                                            void* vtkNotUsed(theCallData))
+{
+  vtkImplicitPlaneWidget* aWidget = vtkImplicitPlaneWidget::SafeDownCast(theObject);
+  if (aWidget == NULL) return;
+  if (theClientData == NULL) return;
+
+  VisuGUI_ClippingPlaneDlg* aDlg = (VisuGUI_ClippingPlaneDlg*) theClientData;
+
+  double aOrigin[3];
+  double aDir[3];
+
+  switch(theEvent){
+  case vtkCommand::InteractionEvent:
+    aWidget->GetOrigin(aOrigin);
+    aWidget->GetNormal(aDir);
+
+    aDlg->setOrigin(aOrigin);
+    aDlg->setDirection(aDir);
+
+    break;
+  }
+}
+
+//****************************************************************
+void VisuGUI_ClippingPlaneDlg::setOrigin(double theVal[3])
+{
+  myXOrigin->setValue(theVal[0]);
+  myYOrigin->setValue(theVal[1]);
+  myZOrigin->setValue(theVal[2]);
+}
+
+//****************************************************************
+void VisuGUI_ClippingPlaneDlg::setDirection(double theVal[3])
+{
+  myXDir->setValue(theVal[0]);
+  myYDir->setValue(theVal[1]);
+  myZDir->setValue(theVal[2]);
+}
+
+//****************************************************************
+void VisuGUI_ClippingPlaneDlg::onValueChanged()
+{
+  if (!myPreviewWidget) return;
+  double aOrigin[3];
+  double aDir[3];
+  aOrigin[0] = myXOrigin->value();
+  aOrigin[1] = myYOrigin->value();
+  aOrigin[2] = myZOrigin->value();
+
+  aDir[0] = myXDir->value();
+  aDir[1] = myYDir->value();
+  aDir[2] = myZDir->value();
+
+  myPreviewWidget->SetOrigin(aOrigin);
+  myPreviewWidget->SetNormal(aDir);
+}
+
+//****************************************************************
+vtkImplicitPlaneWidget* VisuGUI_ClippingPlaneDlg::createPreviewWidget()
+{
+  vtkImplicitPlaneWidget* aPlaneWgt = vtkImplicitPlaneWidget::New();
+  aPlaneWgt->SetInteractor(myViewWindow->getInteractor());
+  aPlaneWgt->SetPlaceFactor(SIZEFACTOR);
+  aPlaneWgt->ScaleEnabledOff();
+  aPlaneWgt->PlaceWidget(myBounds[0],myBounds[1],myBounds[2],myBounds[3],myBounds[4],myBounds[5]);
+  aPlaneWgt->SetOrigin(0,0,0);
+  aPlaneWgt->SetNormal(0,0,1);
+  aPlaneWgt->On();
+
+  //aPlaneWgt->OutlineTranslationOff();
+  //aPlaneWgt->ScaleEnabledOn();
+  aPlaneWgt->AddObserver(vtkCommand::InteractionEvent, 
+                        myCallback.GetPointer(), 
+                        0.);
+  return aPlaneWgt;
+}
+
+
+//****************************************************************
+void VisuGUI_ClippingPlaneDlg::setPlaneObj(_PTR(SObject) thePlaneObj)
+{
+  myPlaneObj = thePlaneObj;
+
+  myNameEdt->setText(QString(myPlaneObj->GetName().c_str()));
+
+  _PTR(GenericAttribute) anAttr;
+  if (myPlaneObj->FindAttribute(anAttr, "AttributeSequenceOfReal")) {
+    _PTR(AttributeSequenceOfReal) aArray(anAttr);
+    myXOrigin->setValue(aArray->Value(1));
+    myYOrigin->setValue(aArray->Value(2));
+    myZOrigin->setValue(aArray->Value(3));
+
+    myPreviewWidget->SetOrigin(aArray->Value(1), aArray->Value(2), aArray->Value(3));
+
+    myXDir->setValue(aArray->Value(4));
+    myYDir->setValue(aArray->Value(5));
+    myZDir->setValue(aArray->Value(6));
+
+    myPreviewWidget->SetNormal(aArray->Value(4), aArray->Value(5), aArray->Value(6));
+  }
+  if (myPlaneObj->FindAttribute(anAttr, "AttributeInteger")) {
+    _PTR(AttributeInteger) aFlag(anAttr);
+    myAutoApply->setCheckState((aFlag->Value() == 1)? Qt::Checked : Qt::Unchecked);
+  }
+
+  myViewWindow->Repaint();
+}
+
+//****************************************************************
+void VisuGUI_ClippingPlaneDlg::accept()
+{
+  _PTR(Study) aStudy = VISU::GetCStudy( VISU::GetAppStudy( myModule ) );
+  if(!aStudy->GetProperties()->IsLocked()) {
+    _PTR(SObject) aFolder;
+    if (VISU::getClippingPlanesFolder(aStudy, aFolder)) {
+      _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+      if (myPlaneObj == 0) { // Create a New plane
+       myPlaneObj = aBuilder->NewObject(aFolder);
+      } 
+      // Save Name
+      _PTR(GenericAttribute) anAttr;
+      anAttr = aBuilder->FindOrCreateAttribute(myPlaneObj,"AttributeName");
+      _PTR(AttributeName) aName(anAttr);
+      aName->SetValue(myNameEdt->text().toStdString());
+
+      //Save Parameters
+      double aParams[6];
+      aParams[0] = myXOrigin->value();
+      aParams[1] = myYOrigin->value();
+      aParams[2] = myZOrigin->value();
+      aParams[3] = myXDir->value();
+      aParams[4] = myYDir->value();
+      aParams[5] = myZDir->value();
+
+      anAttr = aBuilder->FindOrCreateAttribute(myPlaneObj,"AttributeSequenceOfReal");
+      _PTR(AttributeSequenceOfReal) aArray(anAttr);
+      if (aArray->Length() == 6) {
+       for (int i = 0; i < 6; i++)
+         aArray->ChangeValue(i+1, aParams[i]);
+      } else {
+       for (int i = 0; i < 6; i++)
+         aArray->Add(aParams[i]);
+      }
+      // Save Bool Flag
+      anAttr = aBuilder->FindOrCreateAttribute(myPlaneObj,"AttributeInteger");
+      _PTR(AttributeInteger) aFlag(anAttr);
+      aFlag->SetValue((myAutoApply->checkState() == Qt::Checked)? 1 : 0);
+
+      VISU::UpdateObjBrowser(myModule);
+    }
+  }
+  QDialog::accept();
+}
+
+
+//****************************************************************
+void VisuGUI_ClippingPlaneDlg::onHelp()
+{
+  QString aHelpFileName = "clipping_planes_page.html";
+  LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+  if (app)
+    app->onHelpContextModule(myModule ? app->moduleName(myModule->moduleName()) : QString(""), aHelpFileName);
+  else {
+    QString platform;
+#ifdef WIN32
+    platform = "winapplication";
+#else
+    platform = "application";
+#endif
+    SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
+                             QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+                             arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName),
+                             QObject::tr("BUT_OK"));
+  }
+}
+
diff --git a/src/VISUGUI/VisuGUI_ClippingPlaneDlg.h b/src/VISUGUI/VisuGUI_ClippingPlaneDlg.h
new file mode 100644 (file)
index 0000000..35b917f
--- /dev/null
@@ -0,0 +1,90 @@
+// 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_CLIPPINGPLANEDLG_H
+#define DIALOGBOX_CLIPPINGPLANEDLG_H
+
+class VisuGUI;
+class QLineEdit;
+class QCheckBox;
+
+class QtxDoubleSpinBox;
+class vtkImplicitPlaneWidget;
+class vtkCallbackCommand;
+class vtkObject;
+class SVTK_ViewWindow;
+
+#include <QDialog>
+#include <vtkSmartPointer.h>
+#include <VisuGUI_SegmentationMgr.h>
+#include <SALOMEDSClient_SObject.hxx>
+
+
+class VisuGUI_ClippingPlaneDlg: public QDialog
+{
+  Q_OBJECT
+public:
+  VisuGUI_ClippingPlaneDlg(VisuGUI* theModule);
+  ~VisuGUI_ClippingPlaneDlg();
+
+  void setOrigin(double theVal[3]);
+  void setDirection(double theVal[3]);
+
+  void setPlaneObj(_PTR(SObject) thePlaneObj);
+  _PTR(SObject) getPlaneObj() const { return myPlaneObj; }
+
+protected slots:
+  virtual void accept();
+
+private slots:
+  void onHelp();
+  void onValueChanged();
+
+ private:
+  void setEmptyPlane(PlaneDef& thePlane) const;
+  vtkImplicitPlaneWidget* createPreviewWidget();
+
+
+  static void ProcessEvents(vtkObject* theObject, unsigned long theEvent,
+                           void* theClientData, void* theCallData);
+
+  VisuGUI*   myModule;
+  SVTK_ViewWindow* myViewWindow;
+
+  QLineEdit* myNameEdt;
+
+  QtxDoubleSpinBox* myXOrigin;
+  QtxDoubleSpinBox* myYOrigin;
+  QtxDoubleSpinBox* myZOrigin;
+  QtxDoubleSpinBox* myXDir;
+  QtxDoubleSpinBox* myYDir;
+  QtxDoubleSpinBox* myZDir;
+
+  QCheckBox* myAutoApply;
+
+  vtkImplicitPlaneWidget* myPreviewWidget;
+  vtkSmartPointer<vtkCallbackCommand> myCallback;
+
+  double myBounds[6];
+  _PTR(SObject) myPlaneObj;
+};
+
+#endif
index e9b26850170bf61dd0a6ff18e319a8c0b3f07185..16f549676f3a3f7b931091ccde5ccd21a4b62dd8 100644 (file)
@@ -242,8 +242,9 @@ bool VisuGUI_DeformedShapeDlg::onApply()
 //  Create and Edit
 ////////////////////////////////////////////////////////////////////////////////
 
-void VisuGUI_DeformedShapeDlg::CreatePrs3d(VisuGUI* theModule)
+VISU::Prs3d_i* VisuGUI_DeformedShapeDlg::CreatePrs3d(VisuGUI* theModule)
 {
+  VISU::DeformedShape_i* aPrs3d = NULL;
   _PTR(SObject) aTimeStamp;
   Handle(SALOME_InteractiveObject) anIO;
   VISU::ColoredPrs3d_i::EPublishInStudyMode aPublishInStudyMode;
@@ -260,10 +261,10 @@ void VisuGUI_DeformedShapeDlg::CreatePrs3d(VisuGUI* theModule)
          QString aFieldName = aRestoringMap["myFieldName"];
          QString aTimeStampId = aRestoringMap["myTimeStampId"];
          
-         typedef VISU::DeformedShape_i TPrs3d_i; 
+         //typedef VISU::DeformedShape_i TPrs3d_i; 
          
-         TPrs3d_i* aPrs3d =
-           VISU::CreatePrs3dFromFactory<TPrs3d_i>(theModule,
+         aPrs3d =
+           VISU::CreatePrs3dFromFactory<VISU::DeformedShape_i>(theModule,
                                                   aTimeStamp,
                                                   aMeshName.toLatin1().data(),
                                                   (VISU::Entity)anEntity.toInt(),
@@ -277,9 +278,10 @@ void VisuGUI_DeformedShapeDlg::CreatePrs3d(VisuGUI* theModule)
          VisuGUI_DialogRunner r(aDlg);
          int dlgResult = r.run( false );
 
-         if ( dlgResult == 0 )
+         if ( dlgResult == 0 ) {
            aPrs3d->RemoveFromStudy();
-         else {
+           aPrs3d = NULL;
+         } else {
            aDlg->storeToPrsObject( aPrs3d );
            SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
            PublishInView(theModule, aPrs3d, aViewWindow);
@@ -292,6 +294,7 @@ void VisuGUI_DeformedShapeDlg::CreatePrs3d(VisuGUI* theModule)
          delete aDlg;
        }
     }
+  return aPrs3d;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
index 099fc006f355547e55f48e4f705032b781059499..19528e26f462f3118b7ee275c4f5589e9c30ec4c 100644 (file)
@@ -71,7 +71,7 @@ public:
 
     virtual int  storeToPrsObject(VISU::ColoredPrs3d_i* thePrs);
 
-    static void CreatePrs3d(VisuGUI*  theModule);
+    static VISU::Prs3d_i* CreatePrs3d(VisuGUI*  theModule);
     static void EditPrs3d(VisuGUI* theModule, VISU::Prs3d_i* thePrs3d, Handle(SALOME_InteractiveObject)& theIO);
 
     void updatePrsCopy();
index 5112c0973f19785ba52ac7367f146da63314b49b..43a362e71a215d58277e3337047fb43fbbfeba5d 100644 (file)
@@ -278,64 +278,68 @@ namespace VISU
 
   //---------------------------------------------------------------
   template<class TPrs3d_i, class TViewer, class TDlg, int IsDlgModal>
-  void
+  TPrs3d_i*
   CreatePrs3dInViewer(VisuGUI* theModule,
                      _PTR(SObject) theTimeStampSObj,
                      ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode)
   {
+    TPrs3d_i* aPrs = 0;
     // Create new TViewWindow instance, if it does not exist.
     typedef typename TViewer::TViewWindow TViewWindow;
     if (!GetViewWindow<TViewer>(theModule))
-      return;
+      return aPrs;
 
-    CreateAndEditPrs3d<TPrs3d_i,TViewer,TDlg,IsDlgModal>
-      (theModule,theTimeStampSObj,thePublishInStudyMode);
+    aPrs = CreateAndEditPrs3d<TPrs3d_i,TViewer,TDlg,IsDlgModal>
+              (theModule,theTimeStampSObj,thePublishInStudyMode);
 
     theModule->application()->putInfo(QObject::tr("INF_DONE"));
+    return aPrs;
   }
 
 
   //----------------------------------------------------------------------------
   template<class TPrs3d_i, class TDlg, int IsDlgModal>
-  void
+  TPrs3d_i*
   CreatePrs3d(VisuGUI* theModule,
              const QString& theDesiredViewerType = QString())
   {
+    TPrs3d_i* aPrs = 0;
     if (CheckLock(GetCStudy(GetAppStudy(theModule)),GetDesktop(theModule)))
-      return;
+      return aPrs;
 
     _PTR(SObject) aTimeStampSObj;
     Handle(SALOME_InteractiveObject) anIO;
     ColoredPrs3d_i::EPublishInStudyMode aPublishInStudyMode;
     if (!CheckTimeStamp(theModule,aTimeStampSObj,anIO,aPublishInStudyMode))
-      return;
+      return aPrs;
 
     if(aPublishInStudyMode == VISU::ColoredPrs3d_i::EPublishIndependently){
       //      CreatePrs3dInViewer<TPrs3d_i,VVTK_Viewer,TDlg,0>
       //       (theModule,aTimeStampSObj,aPublishInStudyMode);
-      CreatePrs3dInViewer<TPrs3d_i,SVTK_Viewer,TDlg,0>
-       (theModule,aTimeStampSObj,aPublishInStudyMode);
-      return;
+      aPrs = CreatePrs3dInViewer<TPrs3d_i,SVTK_Viewer,TDlg,0>
+               (theModule,aTimeStampSObj,aPublishInStudyMode);
+      return aPrs;
     }else{
       if(theDesiredViewerType.isNull()){
        if (SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager())
          if (aViewManager->getType() == VVTK_Viewer::Type()){ 
-           CreatePrs3dInViewer<TPrs3d_i,VVTK_Viewer,TDlg,IsDlgModal>
-             (theModule,aTimeStampSObj,aPublishInStudyMode);
-           return;
+           aPrs = CreatePrs3dInViewer<TPrs3d_i,VVTK_Viewer,TDlg,IsDlgModal>
+                     (theModule,aTimeStampSObj,aPublishInStudyMode);
+           return aPrs;
          }
-       CreatePrs3dInViewer<TPrs3d_i,SVTK_Viewer,TDlg,IsDlgModal>
-         (theModule,aTimeStampSObj,aPublishInStudyMode);
+       aPrs = CreatePrs3dInViewer<TPrs3d_i,SVTK_Viewer,TDlg,IsDlgModal>
+                  (theModule,aTimeStampSObj,aPublishInStudyMode);
       }else{
        if(theDesiredViewerType == VVTK_Viewer::Type()) {
-         CreatePrs3dInViewer<TPrs3d_i,VVTK_Viewer,TDlg,IsDlgModal>
-           (theModule,aTimeStampSObj,aPublishInStudyMode);
+         aPrs = CreatePrs3dInViewer<TPrs3d_i,VVTK_Viewer,TDlg,IsDlgModal>
+                    (theModule,aTimeStampSObj,aPublishInStudyMode);
        } else {
-         CreatePrs3dInViewer<TPrs3d_i,SVTK_Viewer,TDlg,IsDlgModal>
-           (theModule,aTimeStampSObj,aPublishInStudyMode);
+         aPrs = CreatePrs3dInViewer<TPrs3d_i,SVTK_Viewer,TDlg,IsDlgModal>
+                    (theModule,aTimeStampSObj,aPublishInStudyMode);
        }
       }
     }
+    return aPrs;
   }
 
 
index 9c072073ac793ecda2fb29d40e3b15ff8ac379b0..d4489e377fd67ad57d5a9291434045f4d3fe4382 100644 (file)
@@ -36,6 +36,7 @@
 #include <QMap>
 #include <QList>
 #include <vtkActor.h>
+#include <SALOMEDSClient_SObject.hxx>
 
 class VISU_Actor;
 class vtkPlane;
@@ -58,7 +59,8 @@ public:
   void setActive(bool theActive);
   bool isActive() const { return myIsActive; }
 
-  //static void removeCutPlaneFunctions(VISU_Actor* theActor);
+  void setPlaneObject(_PTR(SObject) aSOPlane) { mySObject = aSOPlane; }
+  _PTR(SObject) getPlaneObject() const { return mySObject; }
 
 protected:
   CutPlaneFunction();
@@ -66,6 +68,7 @@ protected:
 
 private:
   bool myIsActive;
+  _PTR(SObject) mySObject;
 };
 
 
index ef30aef241f0a4937f69564e1468d09cc01f8d4f..3ebed845780ba94727c5696d19f88c2e3e5dad61 100644 (file)
@@ -37,7 +37,7 @@
 #include "VISU_Prs3d_i.hh"
 #include "VISU_Result_i.hh"
 #include "VISU_Table_i.hh"
-#include "VISU_Mesh_i.hh"
+//#include "VISU_Mesh_i.hh"
 #include "VISU_ViewManager_i.hh"
 
 #include "VISU_Actor.h"
@@ -1097,8 +1097,7 @@ namespace VISU
 
   //************************************************************
   // Others
-
-  void
+  VISU::Mesh_i*
   CreateMesh(VisuGUI* theModule,
             const Handle(SALOME_InteractiveObject)& theIO,
             SVTK_ViewWindow* theViewWindow)
@@ -1113,11 +1112,11 @@ namespace VISU
     VISU::Result_var aResult;
     VISU::Result_i* pResult = CheckResult(theModule, aResultSObj, aResult);
     if (pResult == NULL)
-      return;
+      return NULL;
 
     Storable::TRestoringMap aMap = Storable::GetStorableMap(aResultSObj);
     if (aMap.empty())
-      return;
+      return NULL;
 
     CORBA::Object_var aMesh;
     string aComment = Storable::FindValue(aMap,"myComment").toLatin1().data();
@@ -1155,7 +1154,7 @@ namespace VISU
       SUIT_MessageBox::warning (GetDesktop(theModule),
                                 QObject::tr("WRN_VISU"),
                                 QObject::tr("ERR_CANT_BUILD_PRESENTATION") );
-      return;
+      return NULL;
     }
 
     if (theViewWindow) {
@@ -1187,6 +1186,7 @@ namespace VISU
     theModule->application()->putInfo(QObject::tr("INF_DONE"));
     // Make "Save" button active
     theModule->getApp()->updateActions();
+    return pPresent;
   }
 
   // ========================================================================================
@@ -1228,6 +1228,7 @@ namespace VISU
         case VISU::TSTREAMLINES:
         case VISU::TPLOT3D:
        case VISU::TSCALARMAPONDEFORMEDSHAPE:
+       case VISU::TMESH:
           {
             PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
             if (aServant.in()) {
@@ -1364,4 +1365,21 @@ namespace VISU
     spinBox->setDecimals( decimals );
   }
   //------------------------------------------------------------
+  bool getClippingPlanesFolder(_PTR(Study) theStudy, _PTR(SObject)& theSObject)
+  {
+    _PTR(SComponent) aVisuSO = theStudy->FindComponent("VISU");
+    if (!aVisuSO) return false;
+    _PTR(SObject) aFolder = theStudy->FindObject(CLIP_PLANES_FOLDER);
+    if (!aFolder) {
+      _PTR(StudyBuilder) aBuilder = theStudy->NewBuilder();
+      aFolder = aBuilder->NewObject(aVisuSO);
+      
+      _PTR(GenericAttribute) anAttr;
+      anAttr = aBuilder->FindOrCreateAttribute(aFolder,"AttributeName");
+      _PTR(AttributeName) aName(anAttr);
+      aName->SetValue(CLIP_PLANES_FOLDER);
+    }
+    theSObject = aFolder;
+    return true;
+  }
 }
index 2d68def7c8ad6ede4c85a76dcb569b6c3cc0dadb..f8fd7d6d480dee06761fe301e915ccabe0aabefe 100644 (file)
@@ -58,6 +58,7 @@ class VisuGUI;
 
 #include <vector>
 #include <utility>
+#include "VISU_Mesh_i.hh"
 
 namespace VISU 
 {
@@ -215,9 +216,9 @@ namespace VISU
   /*! Create mesh presentation and display it in \a theViewWindow.
    *  If \a theViewWindow is NULL, no displaying will be done.
    */
-  void CreateMesh(VisuGUI* theModule,
-                 const Handle(SALOME_InteractiveObject)& theIO,
-                 SVTK_ViewWindow* theViewWindow);
+  VISU::Mesh_i* CreateMesh(VisuGUI* theModule,
+                          const Handle(SALOME_InteractiveObject)& theIO,
+                          SVTK_ViewWindow* theViewWindow);
   
   // Others
   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
@@ -232,6 +233,10 @@ namespace VISU
                               VISU::Prs3d_i* thePrs3d);
   void initSpinBox( QSpinBox*, int, int, int = 1 );
   void initSpinBox( QDoubleSpinBox*, double, double, double = 0.1, int = 6 );
+
+#define CLIP_PLANES_FOLDER "Clipping Planes"
+
+  bool getClippingPlanesFolder(_PTR(Study) theStudy, _PTR(SObject)& theSObject);
 }
 
 #endif