VisuGUI_Sweep.cxx \
VisuGUI_InputPane.cxx \
VisuGUI_FieldFilter.cxx \
- VisuGUI_ClippingPlaneMgr.cxx \
- VisuGUI_SegmentationMgr.cxx \
VisuGUI_ClippingPanel.cxx \
VisuGUI_ClippingPlaneDlg.cxx
VisuGUI_Slider_moc.cxx \
VisuGUI_Sweep_moc.cxx \
VisuGUI_InputPane_moc.cxx \
- VisuGUI_ClippingPlaneMgr_moc.cxx \
- VisuGUI_SegmentationMgr_moc.cxx \
VisuGUI_ClippingPanel_moc.cxx \
VisuGUI_ClippingPlaneDlg_moc.cxx
// create mesh presentation and display it in aViewWindow
VISU::Mesh_i* aPrs = CreateMesh(this, anIO, aViewWindow);
- emit presentationCreated(aPrs);
+ if (aPrs)
+ emit presentationCreated(aPrs);
}
void
// create mesh presentation and display it in aViewWindow
VISU::Mesh_i* aPrs = CreateMesh(this, anIO, aViewWindow);
- emit presentationCreated(aPrs);
+ if (aPrs)
+ emit presentationCreated(aPrs);
}
}
::OnCreateScalarMap()
{
Prs3d_i* aPrs = CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
- emit presentationCreated(aPrs);
+ if (aPrs)
+ emit presentationCreated(aPrs);
}
{
// CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
Prs3d_i* aPrs = VisuGUI_DeformedShapeDlg::CreatePrs3d(this);
- emit presentationCreated(aPrs);
+ if (aPrs)
+ emit presentationCreated(aPrs);
}
void
::OnCreateScalarMapOnDeformedShape()
{
Prs3d_i* aPrs = CreatePrs3d<VISU::ScalarMapOnDeformedShape_i,VisuGUI_ScalarMapOnDeformedShapeDlg,1>(this);
- emit presentationCreated(aPrs);
+ if (aPrs)
+ emit presentationCreated(aPrs);
}
void
::OnCreateVectors()
{
Prs3d_i* aPrs = CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
- emit presentationCreated(aPrs);
+ if (aPrs)
+ emit presentationCreated(aPrs);
}
void
::OnCreateIsoSurfaces()
{
Prs3d_i* aPrs = CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
- emit presentationCreated(aPrs);
+ if (aPrs)
+ emit presentationCreated(aPrs);
}
void
::OnCreateCutPlanes()
{
Prs3d_i* aPrs = CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,0>(this);
- emit presentationCreated(aPrs);
+ if (aPrs)
+ emit presentationCreated(aPrs);
}
void
::OnCreateCutLines()
{
Prs3d_i* aPrs = CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,0>(this);
- emit presentationCreated(aPrs);
+ if (aPrs)
+ emit presentationCreated(aPrs);
}
void
::OnCreateStreamLines()
{
Prs3d_i* aPrs = CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
- emit presentationCreated(aPrs);
+ if (aPrs)
+ emit presentationCreated(aPrs);
}
void
::OnCreatePlot3D()
{
Prs3d_i* aPrs = CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,0>(this);
- emit presentationCreated(aPrs);
+ if (aPrs)
+ emit presentationCreated(aPrs);
}
void
AddScalarBarPosition(this, aSVtkWindow, aPrs3d, aPos);
}
- emit presentationCreated(aPrs3d);
+ if (aPrs3d)
+ emit presentationCreated(aPrs3d);
}
}
application()->putInfo(QObject::tr("INF_DONE"));
#include "VisuGUI.h"
#include "VisuGUI_Tools.h"
#include "VisuGUI_ViewTools.h"
-#include "VisuGUI_SegmentationMgr.h"
-#include "VisuGUI_ClippingPlaneMgr.h"
#include "VISU_Prs3d_i.hh"
#include "VISU_Result_i.hh"
}
// Try to apply new clipping
- myPrs3d->RemoveAllClippingPlanes();
+ //myPrs3d->RemoveAllClippingPlanes();
+ removeAllClippingPlanes(myPrs3d);
VISU::TPlanes::iterator anIter = myPlanes.begin();
for (; anIter != myPlanes.end(); anIter++) {
if (isFailed) {
// Restore previous clipping state because of failure.
- myPrs3d->RemoveAllClippingPlanes();
+ //myPrs3d->RemoveAllClippingPlanes();
+ removeAllClippingPlanes(myPrs3d);
TPlns::iterator anOldIter = anOldPlanes.begin();
for (; anOldIter != anOldPlanes.end(); anOldIter++) {
}
+void VisuGUI_ClippingDlg::removeAllClippingPlanes(VISU::Prs3d_i* thePrs)
+{
+ for (int i = thePrs->GetNumberOfClippingPlanes() - 1; i >= 0 ; i--) {
+ OrientedPlane* aPlane = dynamic_cast<OrientedPlane*>(thePrs->GetClippingPlane(i));
+ if (aPlane)
+ thePrs->RemoveClippingPlane(i);
+ }
+}
void applyLocalPlanes();
+ void removeAllClippingPlanes(VISU::Prs3d_i* thePrs);
+
private:
LightApp_SelectionMgr* mySelectionMgr;
#include <QMessageBox>
#include <QCheckBox>
+#include <vtkImageData.h>
+#include <vtkCutter.h>
+#include <vtkPolyDataMapper.h>
+
#include <SALOMEDSClient_AttributeSequenceOfReal.hxx>
#include <SALOMEDSClient_AttributeInteger.hxx>
+#define SIZEFACTOR 1.5
+
+
+#define PRINT3(MARK, VAL) printf("#### %s x=%f, y=%f, z=%f\n", MARK, VAL[0], VAL[1], VAL[2]);
+
+
+void AdjustBounds(const double bounds[6], double newBounds[6], double center[3])
+{
+ center[0] = (bounds[0] + bounds[1])/2.0;
+ center[1] = (bounds[2] + bounds[3])/2.0;
+ center[2] = (bounds[4] + bounds[5])/2.0;
+
+ newBounds[0] = center[0] + SIZEFACTOR*(bounds[0]-center[0]);
+ newBounds[1] = center[0] + SIZEFACTOR*(bounds[1]-center[0]);
+ newBounds[2] = center[1] + SIZEFACTOR*(bounds[2]-center[1]);
+ newBounds[3] = center[1] + SIZEFACTOR*(bounds[3]-center[1]);
+ newBounds[4] = center[2] + SIZEFACTOR*(bounds[4]-center[2]);
+ newBounds[5] = center[2] + SIZEFACTOR*(bounds[5]-center[2]);
+}
+
+
+
+//****************************************************************
+PreviewPlane::PreviewPlane(SVTK_ViewWindow* theWindow, const PlaneDef& thePlane, const double* theBounds):
+ myWindow(theWindow),
+ myBounds(theBounds)
+{
+ double aCenter[3];
+ double aBound[6];
+ AdjustBounds(myBounds, aBound, aCenter);
+
+ myPlane = thePlane.plane;
+
+ myBox = vtkImageData::New();
+ myBox->SetDimensions(2, 2, 2);
+ myBox->SetOrigin(aBound[0],aBound[2],aBound[4]);
+ myBox->SetSpacing((aBound[1]-aBound[0]),
+ (aBound[3]-aBound[2]),
+ (aBound[5]-aBound[4]));
+
+ myCutter = vtkCutter::New();
+ myCutter->SetInput(myBox);
+ myCutter->SetCutFunction(myPlane);
+
+ myMapper = vtkPolyDataMapper::New();
+ myMapper->SetInput(myCutter->GetOutput());
+
+ myActor = vtkActor::New();
+ myActor->VisibilityOff();
+ myActor->PickableOff();
+ myActor->SetMapper(myMapper);
+ vtkProperty* aProp = vtkProperty::New();
+ float anRGB[3];
+
+ SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
+ QColor aFillColor = aResourceMgr->colorValue("SMESH", "fill_color", QColor(0, 170, 255));
+ anRGB[0] = aFillColor.red()/255.;
+ anRGB[1] = aFillColor.green()/255.;
+ anRGB[2] = aFillColor.blue()/255.;
+ aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+ aProp->SetOpacity(0.75);
+ myActor->SetBackfaceProperty(aProp);
+ aProp->Delete();
+
+ vtkProperty* aBackProp = vtkProperty::New();
+ QColor aBackFaceColor = aResourceMgr->colorValue("SMESH", "backface_color", QColor(0, 0, 255));
+ anRGB[0] = aBackFaceColor.red()/255.;
+ anRGB[1] = aBackFaceColor.green()/255.;
+ anRGB[2] = aBackFaceColor.blue()/255.;
+ aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+ aBackProp->SetOpacity(0.75);
+ myActor->SetProperty(aBackProp);
+ aBackProp->Delete();
+
+ myWindow->getRenderer()->AddActor(myActor);
+}
+
+//****************************************************************
+PreviewPlane::~PreviewPlane()
+{
+ myWindow->getRenderer()->RemoveActor(myActor);
+ myActor->Delete();
+
+ myMapper->RemoveAllInputs();
+ myMapper->Delete();
+ myCutter->Delete();
+ myBox->Delete();
+}
+
+
+
+
+
+//****************************************************************
+//****************************************************************
+//****************************************************************
+CutPlaneFunction* CutPlaneFunction::New()
+{
+ return new CutPlaneFunction();
+}
+
+void CutPlaneFunction::setActive(bool theActive)
+{
+ myIsActive = theActive;
+ Modified();
+}
+
+double CutPlaneFunction::EvaluateFunction(double x[3])
+{
+ if (myIsActive)
+ return vtkPlane::EvaluateFunction(x);
+ else
+ return -1;
+}
+
+double CutPlaneFunction::EvaluateFunction(double x, double y, double z)
+{
+ if (myIsActive)
+ return vtkPlane::EvaluateFunction(x,y,z);
+ else
+ return -1;
+}
+
+CutPlaneFunction::CutPlaneFunction():
+ myIsActive(true)
+{
+
+}
+
+CutPlaneFunction::~CutPlaneFunction()
+{
+}
+
+
+
+//****************************************************************
+//****************************************************************
+//****************************************************************
VisuGUI_ClippingPanel::VisuGUI_ClippingPanel(VisuGUI* theModule)
: VisuGUI_Panel(tr("TITLE"), theModule, VISU::GetDesktop(theModule), ApplyBtn | HelpBtn ),
myModule(theModule),
myPlaneDlg(0),
- myViewWindow(0)
+ myViewWindow(0),
+ myIsApplied(true)
{
QVBoxLayout* aMainLayout = new QVBoxLayout(mainFrame());
//*************************************************************************
void VisuGUI_ClippingPanel::onApply()
{
+ if (myIsApplied) return;
+ int aPrsNum = myPrsList->currentRow();
+ if (aPrsNum < 0) return;
+
+ foreach(int aPlnNum, myCheckedPlanes) {
+ applyPlaneToPrs(aPlnNum, aPrsNum, (myPlanesList->item(aPlnNum, 0)->checkState() == Qt::Checked));
+ }
+ myCheckedPlanes.clear();
+ myIsApplied = true;
+ VISU::UpdateObjBrowser(myModule);
+ if (myViewWindow)
+ myViewWindow->Repaint();
}
//*************************************************************************
} else { // Plane checked
if (aPlane.isAuto) return;
-
+
+ if (!isAutoApply()) {
+ myCheckedPlanes.append(row);
+ myIsApplied = false;
+ return;
+ }
int aPrsNum = myPrsList->currentRow();
if (aPrsNum < 0) return;
- _PTR(Study) aStudy = VISU::GetCStudy( VISU::GetAppStudy( myModule ) );
- _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
- VISU::Prs3d_i* aPrs = myPresentations.at(aPrsNum);
- _PTR(SObject) aSObject = aPlane.plane->getPlaneObject();
- _PTR(SObject) aPrsSObj = aStudy->FindObjectID(aPrs->GetEntry());
- if (isChecked) {
- if (!containsPlane(aPrs, aPlane))
- aPrs->AddClippingPlane(aPlane.plane);
-
- if(!aStudy->GetProperties()->IsLocked()) {
- _PTR(SObject) aNewObj = aBuilder->NewObject(aSObject);
+ applyPlaneToPrs(row, aPrsNum, isChecked);
+ VISU::UpdateObjBrowser(myModule);
+ }
+ if (myViewWindow)
+ myViewWindow->Repaint();
+}
+
+//*************************************************************************
+void VisuGUI_ClippingPanel::applyPlaneToPrs(int thePlaneNum, int thePrsNum, bool isChecked)
+{
+ PlaneDef aPlane = myPlanes.at(thePlaneNum);
+ _PTR(Study) aStudy = VISU::GetCStudy( VISU::GetAppStudy( myModule ) );
+ _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+ VISU::Prs3d_i* aPrs = myPresentations.at(thePrsNum);
+ _PTR(SObject) aSObject = aPlane.plane->getPlaneObject();
+ _PTR(SObject) aPrsSObj = aStudy->FindObjectID(aPrs->GetEntry());
+ if (isChecked) {
+ if (!containsPlane(aPrs, aPlane))
+ aPrs->AddClippingPlane(aPlane.plane);
+
+ if(!aStudy->GetProperties()->IsLocked()) {
+ _PTR(SObject) aNewObj = aBuilder->NewObject(aSObject);
aBuilder->Addreference(aNewObj, aPrsSObj);
+ }
+ } else {
+ for (int i = 0; i < aPrs->GetNumberOfClippingPlanes(); i++) {
+ if (aPrs->GetClippingPlane(i) == aPlane.plane.GetPointer()) {
+ aPrs->RemoveClippingPlane(i);
+ break;
}
- } else {
- for (int i = 0; i < aPrs->GetNumberOfClippingPlanes(); i++) {
- if (aPrs->GetClippingPlane(i) == aPlane.plane.GetPointer()) {
- aPrs->RemoveClippingPlane(i);
- break;
- }
- }
- if(!aStudy->GetProperties()->IsLocked()) {
- _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
- for (; aIter->More(); aIter->Next()) {
- _PTR(SObject) aRefObj = aIter->Value();
- if(aRefObj) {
- _PTR(SObject) aRefPrsObject;
- if (aRefObj->ReferencedObject(aRefPrsObject)) {
- if (QString(aRefPrsObject->GetID().c_str()) == QString(aPrs->GetEntry().c_str())) {
- VISU::DeleteSObject(myModule, aStudy, aRefObj);
- break;
- }
+ }
+ if(!aStudy->GetProperties()->IsLocked()) {
+ _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
+ for (; aIter->More(); aIter->Next()) {
+ _PTR(SObject) aRefObj = aIter->Value();
+ if(aRefObj) {
+ _PTR(SObject) aRefPrsObject;
+ if (aRefObj->ReferencedObject(aRefPrsObject)) {
+ if (QString(aRefPrsObject->GetID().c_str()) == QString(aPrs->GetEntry().c_str())) {
+ VISU::DeleteSObject(myModule, aStudy, aRefObj);
+ break;
}
}
}
}
}
- VISU::UpdateObjBrowser(myModule);
}
- if (myViewWindow)
- myViewWindow->Repaint();
}
-
//*************************************************************************
bool VisuGUI_ClippingPanel::containsPlane(VISU::Prs3d_i* thePrs, const PlaneDef& thePlane)
{
connect(myPlanesList, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int)));
}
+//*************************************************************************
+bool VisuGUI_ClippingPanel::isAutoApply() const
+{
+ return myAutoApply->checkState() == Qt::Checked;
+}
+
+
//*************************************************************************
void VisuGUI_ClippingPanel::onHelp()
{
class QCheckBox;
class SVTK_ViewWindow;
class SUIT_ViewWindow;
+class vtkPolyDataMapper;
+class vtkImageData;
+class vtkCutter;
#include "VISU_Prs3d_i.hh"
#include "VisuGUI_Panel.h"
-#include <VisuGUI_SegmentationMgr.h>
+//#include <VisuGUI_SegmentationMgr.h>
#include <QList>
+#include <vtkActor.h>
+#include <vtkPlane.h>
#include <SALOMEDSClient_SObject.hxx>
+class CutPlaneFunction: public vtkPlane
+{
+public:
+ static CutPlaneFunction* New();
+
+ vtkTypeMacro(CutPlaneFunction, vtkPlane);
+
+ virtual double EvaluateFunction(double x[3]);
+ virtual double EvaluateFunction(double x, double y, double z);
+
+ void setActive(bool theActive);
+ bool isActive() const { return myIsActive; }
+
+ void setPlaneObject(_PTR(SObject) aSOPlane) { mySObject = aSOPlane; }
+ _PTR(SObject) getPlaneObject() const { return mySObject; }
+
+protected:
+ CutPlaneFunction();
+ ~CutPlaneFunction();
+
+private:
+ bool myIsActive;
+ _PTR(SObject) mySObject;
+};
+
+
+
+struct PlaneDef
+{
+ vtkSmartPointer<CutPlaneFunction> plane;
+ bool isAuto;
+ QString name;
+};
+
+
+class PreviewPlane
+{
+public:
+ PreviewPlane(SVTK_ViewWindow* theWindow, const PlaneDef& thePlane, const double* theBounds);
+ ~PreviewPlane();
+
+ void setVisible(bool theVisible)
+ { myActor->SetVisibility(theVisible); }
+
+private:
+ SVTK_ViewWindow* myWindow;
+
+ vtkActor* myActor;
+ vtkPolyDataMapper* myMapper;
+ const double* myBounds;
+ vtkPlane* myPlane;
+ vtkImageData* myBox;
+ vtkCutter* myCutter;
+};
+
+
+typedef QList<PlaneDef> QListOfPlanes;
+typedef QList<vtkPlane*> ListOfvtkPlanes;
+typedef QList<PreviewPlane*> ListOfPreview;
+
+
+
+
+
class VisuGUI_ClippingPanel: public VisuGUI_Panel
{
Q_OBJECT
void fillPrsList();
void fillPlanesList();
+ bool isAutoApply() const;
+
+
void updatePlane(_PTR(SObject) theObject, PlaneDef& thePlane);
PlaneDef createEmptyPlane();
static bool containsPlane(VISU::Prs3d_i* thePrs, const PlaneDef& thePlane);
bool isVISUDataReady();
+ void applyPlaneToPrs(int thePlaneNum, int thePrsNum, bool isChecked);
+
QList<VISU::Prs3d_i*> getPrsList(_PTR(Study) theStudy, _PTR(SObject) theObject);
VisuGUI* myModule;
VisuGUI_ClippingPlaneDlg* myPlaneDlg;
int myEditingPlanePos;
SVTK_ViewWindow* myViewWindow;
+ bool myIsApplied;
+ QList<int> myCheckedPlanes;
};
#endif
#include <QDialog>
#include <vtkSmartPointer.h>
-#include <VisuGUI_SegmentationMgr.h>
+#include "VisuGUI_ClippingPanel.h"
#include <SALOMEDSClient_SObject.hxx>
+++ /dev/null
-// 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 "VISU_Actor.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 <SALOME_Actor.h>
-
-#include <VTKViewer_Utilities.h>
-#include <SalomeApp_Application.h>
-#include <SVTK_ViewModel.h>
-
-#include <QVBoxLayout>
-#include <QHBoxLayout>
-#include <QListWidget>
-#include <QLineEdit>
-#include <QTabWidget>
-#include <QWidget>
-#include <QGroupBox>
-#include <QGridLayout>
-#include <QComboBox>
-#include <QCheckBox>
-#include <QPushButton>
-#include <QInputDialog>
-
-#include <vtkMath.h>
-#include <vtkPlaneSource.h>
-#include <vtkDataSetMapper.h>
-#include <vtkProperty.h>
-#include <vtkRenderer.h>
-#include <vtkImplicitPlaneWidget.h>
-#include <vtkGlyph3D.h>
-#include <vtkCallbackCommand.h>
-#include <vtkActorCollection.h>
-#include <vtkPlane.h>
-#include <vtkImplicitFunction.h>
-#include <vtkImplicitFunctionCollection.h>
-
-using namespace std;
-
-#define SIZEFACTOR 1.5
-
-
-
-//****************************************************************
-//****************************************************************
-//****************************************************************
-VisuGUI_ClippingPlaneMgr::VisuGUI_ClippingPlaneMgr(VisuGUI* theModule,
- SVTK_ViewWindow* theViewWindow,
- VisuGUI_SegmentationMgr* theMgr)
- : QDialog(VISU::GetDesktop(theModule), Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
- myModule(theModule),
- myViewWindow(theViewWindow),
- myCurrentPlane(-1),
- myPreviewWidget(0),
- myCallback( vtkCallbackCommand::New() ),
- mySegmentationMgr(theMgr)
-{
- myPlanes = mySegmentationMgr->getPlanes();
- myIsVisibleState = mySegmentationMgr->isPlanesVisible();
- mySegmentationMgr->setPlanesVisible(false);
-
- ComputeVisiblePropBounds(myViewWindow->getRenderer(), myBounds);
-
- setWindowTitle(tr("TITLE"));
- setSizeGripEnabled(true);
- setAttribute( Qt::WA_DeleteOnClose, true );
- setModal(false);
-
- myCallback->SetClientData(this);
- myCallback->SetCallback(VisuGUI_ClippingPlaneMgr::ProcessEvents);
-
- QVBoxLayout* aMainLayout = new QVBoxLayout(this);
- aMainLayout->setSpacing(6);
- aMainLayout->setMargin(11);
-
- QWidget* aPlBox = new QWidget(this);
- QHBoxLayout* aPlanesBox = new QHBoxLayout(aPlBox);
- aPlanesBox->setMargin(6);
- aPlanesBox->setSizeConstraint(QLayout::SetMinimumSize);
- aMainLayout->addWidget(aPlBox);
-
- myPlanesList = new QListWidget(this);
- int i;
- for (i = 0; i < myPlanes.size(); i++)
- myPlanesList->addItem(myPlanes.at(i).name);
-
- myPlanesList->setMaximumSize(160, 500);
- myPlanesList->setSelectionMode(QAbstractItemView::SingleSelection);
- connect(myPlanesList, SIGNAL(currentRowChanged(int)), this, SLOT(onPlaneSelection(int)));
- aPlanesBox->addWidget(myPlanesList);
-
- // Planes parameters box
- QFrame* aPlanesFrame = new QFrame(this);
- aPlanesFrame->setWindowTitle(tr("TITLE_PLANES"));
- aPlanesBox->addWidget(aPlanesFrame, 1);
-
- 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 = createVectorTab(aPlanesFrame);
- aFrameLayout->addWidget(myMethodTab);
-
- 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);
- connect(aNewBtn, SIGNAL(clicked()), this, SLOT(onNewPlane()));
- aManageBox->addWidget(aNewBtn);
-
- QPushButton* aDeleteBtn = new QPushButton(tr("BTN_DELETE"), this);
- connect(aDeleteBtn, SIGNAL(clicked()), this, SLOT(onDeletePlane()));
- aManageBox->addWidget(aDeleteBtn);
-
- QPushButton* aImportBtn = new QPushButton(tr("BTN_IMPORT"), this);
- //connect(aImportBtn, SIGNAL(clicked()), this, SLOT(onImportPlane()));
- aManageBox->addWidget(aImportBtn);
-
- aManageBox->addStretch();
-
- myShowPreview = new QCheckBox(tr("CHK_SHOW_PREVIEW"), this);
- myShowPreview->setCheckState(Qt::Checked);
- connect(myShowPreview, SIGNAL(stateChanged(int)), this, SLOT(onShowPreview(int)));
- 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);
-
- 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(onOk()));
- connect(aBtnClose, SIGNAL(clicked()), this, SLOT(onClose()));
- connect(aBtnHelp , SIGNAL(clicked()), this, SLOT(onHelp()));
-
- // compute preview
- for (i = 0; i < myPlanes.size(); i++) {
- PreviewPlane* aPreview = new PreviewPlane(myViewWindow, myPlanes.at(i), myBounds);
- aPreview->setVisible(myShowPreview->checkState() == Qt::Checked);
- myPreviewList.append(aPreview);
- }
- myViewWindow->getRenderer()->ResetCameraClippingRange();
- myViewWindow->Repaint();
-
- if (myPlanes.size() == 0)
- myMethodTab->setEnabled(false);
- else {
- myPlanesList->setCurrentRow(0);
- }
-
- // Save state of planes in actors
- saveState();
-}
-
-
-//****************************************************************
-QWidget* VisuGUI_ClippingPlaneMgr::createVectorTab(QWidget* theParent)
-{
- QWidget* aVectorTab = new QWidget(theParent);
- 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 );
- 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" ), 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 );
- 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( 0.0 );
- connect(myZDir, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged()));
- aDirLayout->addWidget( myZDir );
-
- return aVectorTab;
-}
-
-
-
-//****************************************************************
-VisuGUI_ClippingPlaneMgr::~VisuGUI_ClippingPlaneMgr()
-{
- PreviewPlane* aPreview = 0;
- while (myPreviewList.size() > 0) {
- aPreview = myPreviewList.last();
- myPreviewList.removeLast();
- delete aPreview;
- }
- if (myPreviewWidget) {
- myPreviewWidget->Off();
- myPreviewWidget->Delete();
- }
- myPreviewWidget = 0;
-
- myCallback->Delete();
-}
-
-//****************************************************************
-void VisuGUI_ClippingPlaneMgr::saveState()
-{
- myActorsMap.clear();
- vtkActorCollection* anActors = myViewWindow->getRenderer()->GetActors();
- anActors->InitTraversal();
- PlaneDef aPlane;
- vtkActor* aActor;
- while ( (aActor = anActors->GetNextActor()) ) {
- VISU_Actor* vActor = VISU_Actor::SafeDownCast( aActor );
- if (vActor) {
- ListOfvtkPlanes aList;
- vtkImplicitFunctionCollection* aFunctions = vActor->GetClippingPlanes();
- aFunctions->InitTraversal();
- vtkImplicitFunction* aItem;
- while ((aItem = aFunctions->GetNextItem())) {
- for (int i = 0; i < myPlanes.size(); i++) {
- aPlane = myPlanes.at(i);
- if (aPlane.plane.GetPointer() == aItem)
- aList.append(aPlane.plane);
- }
- }
- myActorsMap[vActor] = aList;
- vActor->RemoveAllClippingPlanes();
- }
- }
- myCopyActorsMap = myActorsMap;
-}
-
-//****************************************************************
-void VisuGUI_ClippingPlaneMgr::deletePlaneFromActors(int thePlaneId)
-{
- vtkPlane* aPl = myPlanes.at(thePlaneId).plane;
- QList<VISU_Actor*> aActors = myActorsMap.keys();
- VISU_Actor* aActor;
- vtkPlane* aPlane;
- for (int i = 0; i < aActors.size(); i++) {
- aActor = aActors.at(i);
- ListOfvtkPlanes& aPlanes = myActorsMap[aActor];
- for (int j = 0; j < aPlanes.size(); j++) {
- aPlane = aPlanes.at(j);
- if (aPlane == aPl) {
- aPlanes.removeAt(j);
- break;
- }
- }
- }
-}
-
-
-//****************************************************************
-void VisuGUI_ClippingPlaneMgr::restoreState(const QMap<VISU_Actor*, ListOfvtkPlanes>& theState)
-{
- QList<VISU_Actor*> aActors = theState.keys();
- VISU_Actor* aActor;
- vtkPlane* aPlane;
- QMapIterator<VISU_Actor*, ListOfvtkPlanes> aIt(theState);
- while (aIt.hasNext()) {
- aIt.next();
- aActor = aIt.key();
- const ListOfvtkPlanes& aPlanes = aIt.value();
- for (int i = 0; i < aPlanes.size(); i++) {
- aPlane = aPlanes.at(i);
- aActor->AddClippingPlane(aPlane);
- }
- }
-}
-
-
-//****************************************************************
-void VisuGUI_ClippingPlaneMgr::onOk()
-{
- savePlane(myCurrentPlane);
- restoreState(myActorsMap);
- mySegmentationMgr->setPlanes(myPlanes);
- if (myIsVisibleState)
- mySegmentationMgr->setPlanesVisible(myIsVisibleState);
- else
- myViewWindow->Repaint();
- close();
-}
-
-//****************************************************************
-void VisuGUI_ClippingPlaneMgr::onClose()
-{
- restoreState(myCopyActorsMap);
- if (myIsVisibleState)
- mySegmentationMgr->setPlanesVisible(myIsVisibleState);
- else
- myViewWindow->Repaint();
- close();
-}
-
-//****************************************************************
-void VisuGUI_ClippingPlaneMgr::onPlaneSelection(int theRow)
-{
- if (myCurrentPlane != -1) {
- savePlane(myCurrentPlane);
- }
- showPlane(theRow);
- myCurrentPlane = theRow;
-}
-
-//****************************************************************
-void VisuGUI_ClippingPlaneMgr::onNewPlane()
-{
- PlaneDef aPlane;
- setEmptyPlane(aPlane);
- myPlanes.append(aPlane);
-
- PreviewPlane* aPreview = new PreviewPlane(myViewWindow, aPlane, myBounds);
- aPreview->setVisible(false);
- myPreviewList.append(aPreview);
-
- myPlanesList->addItem(aPlane.name);
- myPlanesList->setCurrentRow(myPlanes.size() - 1);
- myMethodTab->setEnabled(true);
-
- myViewWindow->getRenderer()->ResetCameraClippingRange();
- myViewWindow->Repaint();
-}
-
-//****************************************************************
-vtkImplicitPlaneWidget* VisuGUI_ClippingPlaneMgr::createPreviewWidget(PlaneDef& thePlane)
-{
- 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(thePlane.plane->GetOrigin());
- aPlaneWgt->SetNormal(thePlane.plane->GetNormal());
- aPlaneWgt->On();
-
- //aPlaneWgt->OutlineTranslationOff();
- //aPlaneWgt->ScaleEnabledOn();
- aPlaneWgt->AddObserver(vtkCommand::InteractionEvent,
- myCallback.GetPointer(),
- 0.);
- return aPlaneWgt;
-}
-
-//****************************************************************
-void VisuGUI_ClippingPlaneMgr::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);
- myViewWindow->Repaint();
-}
-
-//****************************************************************
-void VisuGUI_ClippingPlaneMgr::onDeletePlane()
-{
- if (myCurrentPlane == -1) return;
- disconnect(myPlanesList, SIGNAL(currentRowChanged(int)), this, SLOT(onPlaneSelection(int)));
- deletePlaneFromActors(myCurrentPlane);
- PlaneDef aPlane = myPlanes.at(myCurrentPlane);
- myPlanes.removeAt(myCurrentPlane);
- //aPlane.plane->Delete();
-
- PreviewPlane* aPreview = myPreviewList.at(myCurrentPlane);
- myPreviewList.removeAt(myCurrentPlane);
- delete aPreview;
- if (myPreviewWidget) {
- myPreviewWidget->Off();
- myPreviewWidget->Delete();
- myPreviewWidget = 0;
- }
-
- myPlanesList->takeItem(myCurrentPlane);
- if (myPlanes.size() == 0)
- myCurrentPlane = -1;
- else {
- if (myCurrentPlane >= myPlanes.size())
- myCurrentPlane = myPlanes.size() - 1;
- }
- showPlane(myCurrentPlane);
- myPlanesList->setCurrentRow(myCurrentPlane);
- connect(myPlanesList, SIGNAL(currentRowChanged(int)), this, SLOT(onPlaneSelection(int)));
- myMethodTab->setEnabled(myPlanes.size() > 0);
- myViewWindow->getRenderer()->ResetCameraClippingRange();
- myViewWindow->Repaint();
-}
-
-//****************************************************************
-void VisuGUI_ClippingPlaneMgr::savePlane(int thePlaneNb)
-{
- if (thePlaneNb < 0) return;
- if (myPlanes.size() <= thePlaneNb) return;
- PlaneDef aPlane = myPlanes.at(thePlaneNb);
- aPlane.name = myNameEdt->text();
- aPlane.plane->SetOrigin(myXOrigin->value(),
- myYOrigin->value(),
- myZOrigin->value());
-
- aPlane.plane->SetNormal(myXDir->value(),
- myYDir->value(),
- myZDir->value());
-
- aPlane.isAuto = (myAutoApply->checkState() == Qt::Checked);
- myPlanesList->item(thePlaneNb)->setText(aPlane.name);
- myPlanes.replace(thePlaneNb, aPlane);
-
- myPreviewList.at(myCurrentPlane)->setVisible(myShowPreview->checkState() == Qt::Checked);
- myViewWindow->getRenderer()->ResetCameraClippingRange();
- myViewWindow->Repaint();
-}
-
-//****************************************************************
-void VisuGUI_ClippingPlaneMgr::showPlane(int thePlaneNb)
-{
- if (myPlanes.size() <= thePlaneNb) return;
-
- PlaneDef aNullPlane;
- setEmptyPlane(aNullPlane);
-
- PlaneDef aPlane = (thePlaneNb < 0)? aNullPlane : myPlanes.at(thePlaneNb);
- myNameEdt->setText(aPlane.name);
- double aOrigin[3];
- aPlane.plane->GetOrigin(aOrigin);
- myXOrigin->setValue(aOrigin[0]);
- myYOrigin->setValue(aOrigin[1]);
- myZOrigin->setValue(aOrigin[2]);
-
- double aDir[3];
- aPlane.plane->GetNormal(aDir);
- myXDir->setValue(aDir[0]);
- myYDir->setValue(aDir[1]);
- myZDir->setValue(aDir[2]);
-
- myAutoApply->setCheckState(aPlane.isAuto? Qt::Checked : Qt::Unchecked);
-
- if (myPreviewWidget) {
- myPreviewWidget->Off();
- myPreviewWidget->Delete();
- myPreviewWidget = 0;
- }
- if (thePlaneNb > -1) {
- myPreviewList.at(thePlaneNb)->setVisible(false);
- myPreviewWidget = createPreviewWidget(aPlane);
- }
-}
-
-//****************************************************************
-void VisuGUI_ClippingPlaneMgr::setEmptyPlane(PlaneDef& thePlane) const
-{
- thePlane.name = QString("Plane %1").arg(myPlanes.size());
- thePlane.plane = CutPlaneFunction::New();
- thePlane.plane->Delete();
- thePlane.plane->SetOrigin(0.,0.,0.);
- thePlane.plane->SetNormal(0.,0.,1.);
- thePlane.isAuto = false;
- //thePlane.isOn = false;
-}
-
-//****************************************************************
-void VisuGUI_ClippingPlaneMgr::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_ClippingPlaneMgr* aDlg = (VisuGUI_ClippingPlaneMgr*) 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_ClippingPlaneMgr::setOrigin(double theVal[3])
-{
- myXOrigin->setValue(theVal[0]);
- myYOrigin->setValue(theVal[1]);
- myZOrigin->setValue(theVal[2]);
-}
-
-//****************************************************************
-void VisuGUI_ClippingPlaneMgr::setDirection(double theVal[3])
-{
- myXDir->setValue(theVal[0]);
- myYDir->setValue(theVal[1]);
- myZDir->setValue(theVal[2]);
-}
-
-
-//****************************************************************
-/*void VisuGUI_ClippingPlaneMgr::onImportPlane()
-{
- SalomeApp_Application* aApp = myModule->getApp();
- if (!aApp) return;
-
- ViewManagerList aManagers;
- aApp->viewManagers(SVTK_Viewer::Type(), aManagers);
-
- QStringList aTitles;
- QList<SUIT_ViewWindow*> aViews;
- for (int i = 0; i < aManagers.size(); i++) {
- SUIT_ViewManager* aVMgr = aManagers.at(i);
- QVector<SUIT_ViewWindow*> aWinList = aVMgr->getViews();
- for (int j = 0; j < aWinList.size(); j++) {
- if (aWinList[j] != myViewWindow) {
- aViews.append(aWinList[j]);
- aTitles.append(aWinList[j]->windowTitle());
- }
- }
- }
- if (aTitles.size() == 0) return;
-
- bool aOk = false;
- QString aSelected = QInputDialog::getItem(this, tr("IMPORT_TITLE"),
- tr("SELECT_VIEW"), aTitles,
- 0, false, &aOk);
- if (aOk) {
- int aId = aTitles.indexOf(aSelected);
- if (aId < 0) return;
- SVTK_ViewWindow* aWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(aId));
- if (!aWindow) return;
-
- VisuGUI_ViewExtender* aExtender = (VisuGUI_ViewExtender*) myModule->getViewExtender();
- VisuGUI_SegmentationMgr* aSegmentMgr = aExtender->getSegmentationMgr(aWindow);
- if (!aSegmentMgr) return;
- const QListOfPlanes& aPlanes = aSegmentMgr->getPlanes();
- for (int i = 0; i < aPlanes.size(); i++) {
- const PlaneDef& aSource = aPlanes.at(i);
- PlaneDef aDest;
- aDest.plane = CutPlaneFunction::New();
- aDest.isAuto = aSource.isAuto;
- aDest.name = aWindow->windowTitle() + ":" + aSource.name;
- aDest.plane->SetOrigin(aSource.plane->GetOrigin());
- aDest.plane->SetNormal(aSource.plane->GetNormal());
-
- myPlanes.append(aDest);
- PreviewPlane* aPreview = new PreviewPlane(myViewWindow, aDest, myBounds);
- aPreview->setVisible(myShowPreview->checkState() == Qt::Checked);
- myPreviewList.append(aPreview);
-
- myPlanesList->addItem(aDest.name);
- myMethodTab->setEnabled(true);
-
- }
- myPlanesList->setCurrentRow(myPlanes.size() - 1);
- myViewWindow->getRenderer()->ResetCameraClippingRange();
- myViewWindow->Repaint();
- }
-}
-*/
-//****************************************************************
-void VisuGUI_ClippingPlaneMgr::onShowPreview(int theVal)
-{
- bool isVisible = (theVal == Qt::Checked);
- for (int i = 0; i < myPreviewList.size(); i++)
- myPreviewList.at(i)->setVisible(isVisible);
- myViewWindow->Repaint();
-}
-
-
-//****************************************************************
-void VisuGUI_ClippingPlaneMgr::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"));
- }
-}
-
-
+++ /dev/null
-// 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
-
-
-
-
-class VisuGUI;
-class QListWidget;
-class QLineEdit;
-class QtxDoubleSpinBox;
-class QTabWidget;
-class QLabel;
-class QComboBox;
-class QCheckBox;
-class PreviewPlane;
-
-class vtkImplicitPlaneWidget;
-class vtkCallbackCommand;
-
-class VISU_Actor;
-
-#include <QDialog>
-#include <VisuGUI_SegmentationMgr.h>
-#include <vtkSmartPointer.h>
-#include <vtkActor.h>
-
-
-class VisuGUI_ClippingPlaneMgr : public QDialog
-{
- Q_OBJECT
-public:
-
- VisuGUI_ClippingPlaneMgr(VisuGUI* theModule,
- SVTK_ViewWindow* theViewWindow,
- VisuGUI_SegmentationMgr* theMgr);
- ~VisuGUI_ClippingPlaneMgr();
-
- const QListOfPlanes& getPlanes() const { return myPlanes; }
- SVTK_ViewWindow* getViewWindow() const { return myViewWindow; }
-
-
- void setOrigin(double theVal[3]);
- void setDirection(double theVal[3]);
-
-
- signals:
- void applyPlanes();
-
-private slots:
- void onOk();
- void onClose();
- void onHelp();
- void onPlaneSelection(int theRow);
- void onNewPlane();
- void onDeletePlane();
- void onValueChanged();
- // void onImportPlane();
- void onShowPreview(int);
-
- private:
- QWidget* createVectorTab(QWidget* theParent);
-
- void savePlane(int thePlaneNb);
- void showPlane(int thePlaneNb);
- void setEmptyPlane(PlaneDef& thePlane) const;
-
- vtkImplicitPlaneWidget* createPreviewWidget(PlaneDef& thePlane);
-
- static void ProcessEvents(vtkObject* theObject, unsigned long theEvent,
- void* theClientData, void* theCallData);
-
- void saveState();
- void deletePlaneFromActors(int thePlaneId);
- void restoreState(const QMap<VISU_Actor*, ListOfvtkPlanes>& theState);
-
-
- VisuGUI_SegmentationMgr* mySegmentationMgr;
-
- QListWidget* myPlanesList;
- QLineEdit* myNameEdt;
- VisuGUI* myModule;
- QWidget* myMethodTab;
-
- QtxDoubleSpinBox* myXOrigin;
- QtxDoubleSpinBox* myYOrigin;
- QtxDoubleSpinBox* myZOrigin;
-
- QtxDoubleSpinBox* myXDir;
- QtxDoubleSpinBox* myYDir;
- QtxDoubleSpinBox* myZDir;
-
- QCheckBox* myAutoApply;
- QCheckBox* myShowPreview;
-
- QListOfPlanes myPlanes;
- SVTK_ViewWindow* myViewWindow;
- int myCurrentPlane;
-
- ListOfPreview myPreviewList;
- vtkImplicitPlaneWidget* myPreviewWidget;
-
- vtkSmartPointer<vtkCallbackCommand> myCallback;
-
- //Stores Actors and Ids of applied planes (position in myPlanes)
- QMap<VISU_Actor*, ListOfvtkPlanes> myActorsMap;
- QMap<VISU_Actor*, ListOfvtkPlanes> myCopyActorsMap;
-
- double myBounds[6];
-
- bool myIsVisibleState;
-};
-
-#endif
if ( !prs )
continue;
- prs->RemoveAllClippingPlanes();
+ //prs->RemoveAllClippingPlanes();
+ for (int i = prs->GetNumberOfClippingPlanes() - 1; i >= 0 ; i--) {
+ OrientedPlane* aPlane = dynamic_cast<OrientedPlane*>(prs->GetClippingPlane(i));
+ if (aPlane)
+ prs->RemoveClippingPlane(i);
+ }
if ( val != "Off" ) {
QStringList vals = val.split( gDigitsSep, QString::SkipEmptyParts );
if ( vals.count() == 6 ) { // format check: 6 float values
+++ /dev/null
-// 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_SegmentationMgr.cxx
-// Author : Vitaly Smetannikov
-// Module : VISU
-
-
-#include "VisuGUI_SegmentationMgr.h"
-#include "VisuGUI_Tools.h"
-#include "VisuGUI_ClippingPlaneMgr.h"
-
-#include <SVTK_ViewModel.h>
-#include <SUIT_ResourceMgr.h>
-#include <SUIT_Session.h>
-#include <VTKViewer_Utilities.h>
-
-#include <VISU_PipeLine.hxx>
-#include <VISU_Actor.h>
-#include <VISU_DataSetActor.h>
-
-#include <vtkRenderer.h>
-
-#include <vtkImageData.h>
-#include <vtkCutter.h>
-#include <vtkPolyDataMapper.h>
-#include <vtkActor.h>
-#include <vtkImplicitFunctionCollection.h>
-
-#include <QtxAction.h>
-#include <QtxActionToolMgr.h>
-#include <QDialog>
-#include <QMenu>
-
-#define SIZEFACTOR 1.5
-
-
-#define PRINT3(MARK, VAL) printf("#### %s x=%f, y=%f, z=%f\n", MARK, VAL[0], VAL[1], VAL[2]);
-
-
-void AdjustBounds(const double bounds[6], double newBounds[6], double center[3])
-{
- center[0] = (bounds[0] + bounds[1])/2.0;
- center[1] = (bounds[2] + bounds[3])/2.0;
- center[2] = (bounds[4] + bounds[5])/2.0;
-
- newBounds[0] = center[0] + SIZEFACTOR*(bounds[0]-center[0]);
- newBounds[1] = center[0] + SIZEFACTOR*(bounds[1]-center[0]);
- newBounds[2] = center[1] + SIZEFACTOR*(bounds[2]-center[1]);
- newBounds[3] = center[1] + SIZEFACTOR*(bounds[3]-center[1]);
- newBounds[4] = center[2] + SIZEFACTOR*(bounds[4]-center[2]);
- newBounds[5] = center[2] + SIZEFACTOR*(bounds[5]-center[2]);
-}
-
-
-
-//****************************************************************
-PreviewPlane::PreviewPlane(SVTK_ViewWindow* theWindow, const PlaneDef& thePlane, const double* theBounds):
- myWindow(theWindow),
- myBounds(theBounds)
-{
- double aCenter[3];
- double aBound[6];
-
- AdjustBounds(myBounds, aBound, aCenter);
-
- myPlane = thePlane.plane;
-
- myBox = vtkImageData::New();
- myBox->SetDimensions(2, 2, 2);
- myBox->SetOrigin(aBound[0],aBound[2],aBound[4]);
- myBox->SetSpacing((aBound[1]-aBound[0]),
- (aBound[3]-aBound[2]),
- (aBound[5]-aBound[4]));
-
- myCutter = vtkCutter::New();
- myCutter->SetInput(myBox);
- myCutter->SetCutFunction(myPlane);
-
- myMapper = vtkPolyDataMapper::New();
- myMapper->SetInput(myCutter->GetOutput());
-
- myActor = vtkActor::New();
- myActor->VisibilityOff();
- myActor->PickableOff();
- myActor->SetMapper(myMapper);
- vtkProperty* aProp = vtkProperty::New();
- float anRGB[3];
-
- SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
-
- QColor aFillColor = aResourceMgr->colorValue("SMESH", "fill_color", QColor(0, 170, 255));
- anRGB[0] = aFillColor.red()/255.;
- anRGB[1] = aFillColor.green()/255.;
- anRGB[2] = aFillColor.blue()/255.;
- aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
- aProp->SetOpacity(0.75);
- myActor->SetBackfaceProperty(aProp);
- aProp->Delete();
-
- vtkProperty* aBackProp = vtkProperty::New();
- QColor aBackFaceColor = aResourceMgr->colorValue("SMESH", "backface_color", QColor(0, 0, 255));
- anRGB[0] = aBackFaceColor.red()/255.;
- anRGB[1] = aBackFaceColor.green()/255.;
- anRGB[2] = aBackFaceColor.blue()/255.;
- aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
- aBackProp->SetOpacity(0.75);
- myActor->SetProperty(aBackProp);
- aBackProp->Delete();
-
- myWindow->getRenderer()->AddActor(myActor);
-}
-
-//****************************************************************
-PreviewPlane::~PreviewPlane()
-{
- myWindow->getRenderer()->RemoveActor(myActor);
- myActor->Delete();
-
- myMapper->RemoveAllInputs();
- myMapper->Delete();
- myCutter->Delete();
- myBox->Delete();
-}
-
-
-
-
-
-//****************************************************************
-//****************************************************************
-//****************************************************************
-CutPlaneFunction* CutPlaneFunction::New()
-{
- return new CutPlaneFunction();
-}
-
-void CutPlaneFunction::setActive(bool theActive)
-{
- myIsActive = theActive;
- Modified();
-}
-
-double CutPlaneFunction::EvaluateFunction(double x[3])
-{
- if (myIsActive)
- return vtkPlane::EvaluateFunction(x);
- else
- return -1;
-}
-
-double CutPlaneFunction::EvaluateFunction(double x, double y, double z)
-{
- if (myIsActive)
- return vtkPlane::EvaluateFunction(x,y,z);
- else
- return -1;
-}
-
-CutPlaneFunction::CutPlaneFunction():
- myIsActive(true)
-{
-
-}
-
-CutPlaneFunction::~CutPlaneFunction()
-{
-}
-
-// void CutPlaneFunction::removeCutPlaneFunctions(VISU_Actor* theActor)
-// {
-// VISU_PipeLine* aPL = theActor->GetPipeLine();
-// vtkIdType aNbPlanes = aPL->GetNumberOfClippingPlanes();
-// CutPlaneFunction* aPlane = 0;
-// printf("#### Before delete Nb = %i\n", aNbPlanes);
-// for (vtkIdType i = aNbPlanes - 1; i >= 0; i--) {
-// aPlane = dynamic_cast<CutPlaneFunction*>(aPL->GetClippingPlane(i));
-// if (aPlane) {
-// aPL->RemoveClippingPlane(i);
-// }
-// }
-// printf("#### After delete Nb = %i\n", aPL->GetNumberOfClippingPlanes());
-// }
-
-
-
-//****************************************************************
-//****************************************************************
-//****************************************************************
-VisuGUI_SegmentationMgr::VisuGUI_SegmentationMgr(VisuGUI* theModule, SVTK_ViewWindow* theWindow):
- myIsPlanesNonActive(false),
- myIsPlanesVisible(false),
- myWindow(theWindow),
- 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_PLANES_MGR")),
- tr( "DSK_CLIPPING_PLANE_MGR" ),
- 0,
- this,
- false);
- connect(aAction, SIGNAL( activated() ), this, SLOT( onPlanesMgr() ));
- myActionsMap[ClippingPlaneMgrId] = aAction;
-
- aAction = new QtxAction(tr("MNU_SHOW_CLIPPINGPLANES"),
- aResourceMgr->loadPixmap("VISU",tr("ICON_VVTK_PLANE_SEGMENTATION_SWITCH")),
- tr( "DSK_SHOW_CLIPPINGPLANES" ),
- 0,
- this,
- true);
- connect(aAction, SIGNAL( toggled(bool) ), this, SLOT( setPlanesVisible(bool) ));
- myActionsMap[ShowClippingPlanesId] = aAction;
-
- aAction = new QtxAction(tr("MNU_ACTIVATE_CLIPPINGPLANES"),
- aResourceMgr->loadPixmap("VISU",tr("ICON_DEACTIVATE_PLANES")),
- tr( "DSK_ACTIVATE_CLIPPINGPLANES" ),
- 0,
- this,
- true);
- connect(aAction, SIGNAL( toggled(bool) ), this, SLOT( setPlanesNonActive(bool) ));
- myActionsMap[DeactivateClippingPlanesId] = aAction;
-}
-
-//****************************************************************
-VisuGUI_SegmentationMgr::~VisuGUI_SegmentationMgr()
-{
- deactivate();
-}
-
-//****************************************************************
-void VisuGUI_SegmentationMgr::deactivate()
-{
- if (myNonModalDlg) {
- myNonModalDlg->close();
- myNonModalDlg = 0;
- }
-}
-
-//****************************************************************
-int VisuGUI_SegmentationMgr::createToolbar(QtxActionToolMgr* theMgr)
-{
- int aToolBar = theMgr->createToolBar( tr("VISU_VIEW_TOOLBAR"));
- theMgr->append( myActionsMap[ClippingPlaneMgrId], aToolBar );
- theMgr->append( myActionsMap[DeactivateClippingPlanesId], aToolBar );
- theMgr->append( myActionsMap[ShowClippingPlanesId], aToolBar );
- return aToolBar;
-}
-
-
-//****************************************************************
-const QListOfPlanes& VisuGUI_SegmentationMgr::getPlanes()
-{
- return myListOfPlanes;
-}
-
-//****************************************************************
-void VisuGUI_SegmentationMgr::setPlanes(const QListOfPlanes& theNewPlanes)
-{
- myListOfPlanes = theNewPlanes;
-
- vtkActorCollection* anActors = myWindow->getRenderer()->GetActors();
- anActors->InitTraversal();
- vtkActor* aActor = anActors->GetNextActor();
- VISU_Actor* aVisuActor = 0;
- while (aActor) {
- aVisuActor = VISU_Actor::SafeDownCast(aActor);
- if (aVisuActor) {
- applyPlanes(aVisuActor);
- }
- aActor = anActors->GetNextActor();
- }
- myWindow->Repaint();
-}
-
-//****************************************************************
-void VisuGUI_SegmentationMgr::onAddActor(VTKViewer_Actor* theActor)
-{
- VISU_Actor* aActor = VISU_Actor::SafeDownCast(theActor);
- if (!aActor) return;
- applyPlanes(aActor);
-}
-
-//****************************************************************
-void VisuGUI_SegmentationMgr::applyPlanes(VISU_Actor* theActor)
-{
- for (int i = 0; i < myListOfPlanes.size(); i++) {
- PlaneDef aPlane = myListOfPlanes.at(i);
- if (aPlane.isAuto && (!isContainsPlane(theActor, aPlane.plane))) {
- theActor->AddClippingPlane(aPlane.plane);
- }
- }
-}
-
-
-//****************************************************************
-void VisuGUI_SegmentationMgr::setPlanesNonActive(bool theNonActive)
-{
- if (myIsPlanesNonActive == theNonActive) return;
- myIsPlanesNonActive = theNonActive;
-
- PlaneDef aPlane;
- for (int i = 0; i < myListOfPlanes.size(); i++) {
- aPlane = myListOfPlanes.at(i);
- aPlane.plane->setActive(!theNonActive);
- }
- myWindow->Repaint();
-}
-
-//****************************************************************
-bool VisuGUI_SegmentationMgr::isPlanesNonActive() const
-{
- return myIsPlanesNonActive;
-}
-
-//****************************************************************
-void VisuGUI_SegmentationMgr::setPlanesVisible(bool theVisible)
-{
- if (myIsPlanesVisible == theVisible) return;
- myIsPlanesVisible = theVisible;
- if (myIsPlanesVisible) {
- double aBounds[6];
- ComputeVisiblePropBounds(myWindow->getRenderer(), aBounds);
- for (int i = 0; i < myListOfPlanes.size(); i++) {
- PreviewPlane* aPreview = new PreviewPlane(myWindow, myListOfPlanes.at(i), aBounds);
- aPreview->setVisible(true);
- myPlanesPreview.append(aPreview);
- }
- } else {
- PreviewPlane* aPreview;
- while (myPlanesPreview.size() > 0) {
- aPreview = myPlanesPreview.last();
- myPlanesPreview.removeLast();
- delete aPreview;
- }
- }
- myWindow->Repaint();
-}
-
-//****************************************************************
-bool VisuGUI_SegmentationMgr::isPlanesVisible() const
-{
- return myIsPlanesVisible;
-}
-
-//****************************************************************
-bool VisuGUI_SegmentationMgr::isContainsPlane(VISU_Actor* theActor, vtkPlane* thePlane)
-{
- vtkImplicitFunctionCollection* aFunctions = theActor->GetClippingPlanes();
- aFunctions->InitTraversal();
- vtkImplicitFunction* aItem;
- while ((aItem = aFunctions->GetNextItem())) {
- if (thePlane == aItem)
- return true;
- }
- return false;
-}
-
-//****************************************************************
-void VisuGUI_SegmentationMgr::onPlanesMgr()
-{
- if (myNonModalDlg) return;
-
- VisuGUI_ClippingPlaneMgr* aDlg =
- new VisuGUI_ClippingPlaneMgr(myModule, myWindow, this);
-
- myNonModalDlg = aDlg;
- connect(myNonModalDlg, SIGNAL( destroyed(QObject*) ), this, SLOT( onDialogDestroy() ));
- myNonModalDlg->show();
-}
-
-//****************************************************************
-void VisuGUI_SegmentationMgr::onDialogDestroy()
-{
- disconnect(myNonModalDlg, SIGNAL( destroyed(QObject*) ), this, SLOT( onDialogDestroy() ));
- myNonModalDlg = 0;
-}
-
+++ /dev/null
-// 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_SegmentationMgr.h
-// Author : Vitaly Smetannikov
-// Module : VISU
-#ifndef VisuGUI_SegmentationMgr_HeaderFile
-#define VisuGUI_SegmentationMgr_HeaderFile
-
-
-#include "VisuGUI_ClippingDlg.h"
-
-#include <SVTK_ViewWindow.h>
-#include <vtkSmartPointer.h>
-#include <QObject>
-#include <QMap>
-#include <QList>
-#include <vtkActor.h>
-#include <SALOMEDSClient_SObject.hxx>
-
-class VISU_Actor;
-class vtkPlane;
-class vtkPolyDataMapper;
-class vtkImageData;
-class vtkCutter;
-class QtxAction;
-class QDialog;
-
-class CutPlaneFunction: public vtkPlane
-{
-public:
- static CutPlaneFunction* New();
-
- vtkTypeMacro(CutPlaneFunction, vtkPlane);
-
- virtual double EvaluateFunction(double x[3]);
- virtual double EvaluateFunction(double x, double y, double z);
-
- void setActive(bool theActive);
- bool isActive() const { return myIsActive; }
-
- void setPlaneObject(_PTR(SObject) aSOPlane) { mySObject = aSOPlane; }
- _PTR(SObject) getPlaneObject() const { return mySObject; }
-
-protected:
- CutPlaneFunction();
- ~CutPlaneFunction();
-
-private:
- bool myIsActive;
- _PTR(SObject) mySObject;
-};
-
-
-
-struct PlaneDef
-{
- vtkSmartPointer<CutPlaneFunction> plane;
- bool isAuto;
- QString name;
-};
-
-
-class PreviewPlane
-{
-public:
- PreviewPlane(SVTK_ViewWindow* theWindow, const PlaneDef& thePlane, const double* theBounds);
- ~PreviewPlane();
-
- void setVisible(bool theVisible)
- { myActor->SetVisibility(theVisible); }
-
-private:
- SVTK_ViewWindow* myWindow;
-
- vtkActor* myActor;
- vtkPolyDataMapper* myMapper;
- const double* myBounds;
- vtkPlane* myPlane;
- vtkImageData* myBox;
- vtkCutter* myCutter;
-};
-
-
-typedef QList<PlaneDef> QListOfPlanes;
-typedef QList<vtkPlane*> ListOfvtkPlanes;
-typedef QList<PreviewPlane*> ListOfPreview;
-
-class VisuGUI_SegmentationMgr: public QObject
-{
- Q_OBJECT
-public:
-
- VisuGUI_SegmentationMgr(VisuGUI* theModule, SVTK_ViewWindow* theWindow);
- ~VisuGUI_SegmentationMgr();
-
- const QListOfPlanes& getPlanes();
- void setPlanes(const QListOfPlanes& theNewPlanes);
-
- bool isPlanesNonActive() const;
-
- bool isPlanesVisible() const;
-
- bool isContainsPlane(VISU_Actor* theActor, vtkPlane* thePlane);
-
- int createToolbar(QtxActionToolMgr* theMgr);
-
- void deactivate();
-
-public slots:
- void onAddActor(VTKViewer_Actor*);
- void setPlanesVisible(bool);
- void setPlanesNonActive(bool);
-
-private slots:
- void onPlanesMgr();
- void onDialogDestroy();
-
-
- private:
- void applyPlanes(VISU_Actor* theActor);
-
- enum { ClippingPlaneMgrId, ShowClippingPlanesId, DeactivateClippingPlanesId };
-
- QMap<int, QtxAction*> myActionsMap;
-
- SVTK_ViewWindow* myWindow;
- VisuGUI* myModule;
-
- QDialog* myNonModalDlg;
-
- QListOfPlanes myListOfPlanes;
- bool myIsPlanesNonActive;
- bool myIsPlanesVisible;
-
- ListOfPreview myPlanesPreview;
-};
-
-#endif