smesh/src/SMESHGUI/SMESHGUI_ClippingDlg.h

275 lines
7.8 KiB
C
Raw Normal View History

2019-02-14 16:55:47 +05:00
// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
2004-12-01 15:48:31 +05:00
//
2012-08-09 16:03:55 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2004-12-01 15:48:31 +05:00
//
2012-08-09 16:03:55 +06:00
// 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
2014-02-20 18:25:37 +06:00
// version 2.1 of the License, or (at your option) any later version.
2004-12-01 15:48:31 +05:00
//
2012-08-09 16:03:55 +06:00
// 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.
2004-12-01 15:48:31 +05:00
//
2012-08-09 16:03:55 +06:00
// 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
2009-02-17 10:27:49 +05:00
//
2012-08-09 16:03:55 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2009-02-17 10:27:49 +05:00
//
2012-08-09 16:03:55 +06:00
2009-02-17 10:27:49 +05:00
// SMESH SMESHGUI : GUI for SMESH component
// File : SMESHGUI_ClippingDlg.h
// Author : Nicolas REJNERI, Open CASCADE S.A.S.
//
#ifndef SMESHGUI_CLIPPINGDLG_H
#define SMESHGUI_CLIPPINGDLG_H
2004-12-01 15:48:31 +05:00
2009-02-17 10:27:49 +05:00
// SMESH includes
#include "SMESH_SMESHGUI.hxx"
2009-02-17 10:27:49 +05:00
// SALOME includes
#include <SVTK_ViewWindow.h>
// Qt includes
#include <QDialog>
2012-08-09 16:03:55 +06:00
#include <QPointer>
2004-12-01 15:48:31 +05:00
2009-02-17 10:27:49 +05:00
// VTK includes
2012-08-09 16:03:55 +06:00
#include <vtkPlane.h>
2004-12-01 15:48:31 +05:00
#include <vtkSmartPointer.h>
2009-02-17 10:27:49 +05:00
// STL includes
2012-08-09 16:03:55 +06:00
#include <list>
#include <map>
2004-12-01 15:48:31 +05:00
#include <vector>
class QGroupBox;
2004-12-01 15:48:31 +05:00
class QLabel;
class QPushButton;
class QCheckBox;
class QComboBox;
2012-08-09 16:03:55 +06:00
class QListWidget;
class QListWidgetItem;
class QStackedLayout;
class QSlider;
class QMenu;
2012-08-09 16:03:55 +06:00
class SALOME_Actor;
class SMESHGUI;
2004-12-01 15:48:31 +05:00
class SMESH_Actor;
class QtxDoubleSpinBox;
class QtxDoubleSpinSlider;
class QtxIntSpinSlider;
2012-08-09 16:03:55 +06:00
class vtkActor;
class vtkDataSetMapper;
class vtkPlaneSource;
class vtkCallbackCommand;
class vtkObject;
class vtkImplicitPlaneWidget;
2004-12-01 15:48:31 +05:00
2009-02-17 10:27:49 +05:00
namespace SMESH
{
enum Mode { Absolute, Relative };
2009-02-17 10:27:49 +05:00
enum Orientation { XY, YZ, ZX };
2004-12-01 15:48:31 +05:00
2012-08-09 16:03:55 +06:00
class OrientedPlane: public vtkPlane
{
vtkDataSetMapper* myMapper;
public:
static OrientedPlane *New();
static OrientedPlane *New(SVTK_ViewWindow* theViewWindow);
vtkTypeMacro (OrientedPlane, vtkPlane);
2012-08-09 16:03:55 +06:00
QPointer<SVTK_ViewWindow> myViewWindow;
SMESH::Orientation myRelativeOrientation;
float myDistance;
double myAngle[2];
double X, Y, Z, Dx, Dy, Dz;
int myAbsoluteOrientation;
bool IsInvert;
bool IsOpenGLClipping;
Mode PlaneMode;
2012-08-09 16:03:55 +06:00
vtkPlaneSource* myPlaneSource;
SALOME_Actor *myActor;
2012-08-09 16:03:55 +06:00
void SetOrientation (SMESH::Orientation theOrientation) { myRelativeOrientation = theOrientation; }
SMESH::Orientation GetOrientation() { return myRelativeOrientation; }
2012-08-09 16:03:55 +06:00
void SetDistance (float theDistance) { myDistance = theDistance; }
float GetDistance() { return myDistance; }
2012-08-09 16:03:55 +06:00
void ShallowCopy (OrientedPlane* theOrientedPlane);
OrientedPlane* InvertPlane ();
2012-08-09 16:03:55 +06:00
protected:
OrientedPlane(SVTK_ViewWindow* theViewWindow);
OrientedPlane();
2012-08-09 16:03:55 +06:00
void Init();
2012-08-09 16:03:55 +06:00
~OrientedPlane();
private:
// Not implemented.
OrientedPlane (const OrientedPlane&);
void operator= (const OrientedPlane&);
2012-08-09 16:03:55 +06:00
};
typedef vtkSmartPointer<OrientedPlane> TPlane;
typedef std::list<vtkActor*> TActorList;
struct TPlaneData
{
TPlaneData( TPlane thePlane,
TActorList theActorList )
{
Plane = thePlane;
ActorList = theActorList;
}
TPlane Plane;
TActorList ActorList;
};
typedef std::vector<TPlane> TPlaneVector;
typedef std::vector<TPlaneData> TPlaneDataVector;
};
2004-12-01 15:48:31 +05:00
//=================================================================================
// class : SMESHGUI_ClippingDlg
// purpose :
//=================================================================================
class SMESHGUI_EXPORT SMESHGUI_ClippingDlg : public QDialog
{
2009-02-17 10:27:49 +05:00
Q_OBJECT
2004-12-01 15:48:31 +05:00
public:
2012-08-09 16:03:55 +06:00
SMESHGUI_ClippingDlg( SMESHGUI*, SVTK_ViewWindow* );
2009-02-17 10:27:49 +05:00
~SMESHGUI_ClippingDlg();
2004-12-01 15:48:31 +05:00
static bool AddPlane ( SMESH::TActorList theActorList,
SMESH::OrientedPlane* thePlane );
protected:
void keyPressEvent( QKeyEvent* );
static void ProcessEvents( vtkObject* theObject,
unsigned long theEvent,
void* theClientData,
void* theCallData);
2004-12-01 15:48:31 +05:00
private:
double getDistance() const;
void setDistance( const double );
double getRotation1() const;
double getRotation2() const;
void setRotation( const double, const double );
void setOrigin(double theVal[3]);
void setDirection(double theVal[3]);
void initializePlaneData();
void initParam();
void synchronize();
void updateActorList();
void updateActorItem( QListWidgetItem* theItem,
bool theUpdateSelectAll,
bool theUpdateClippingPlaneMap );
SMESH::TActorList getCurrentActors();
void dumpPlaneData() const;
void absolutePlaneToRelative ( double theOrigin[3], double theDir[3] );
void setBoundsForPreviewWidget();
vtkImplicitPlaneWidget* createPreviewWidget();
2012-08-09 16:03:55 +06:00
private:
2009-02-17 10:27:49 +05:00
SMESHGUI* mySMESHGUI;
2012-08-09 16:03:55 +06:00
SVTK_ViewWindow* myViewWindow;
SMESH::TPlaneDataVector myPlanes;
vtkCallbackCommand* myCallback;
vtkImplicitPlaneWidget* myPreviewWidget;
double myBounds[6];
2009-02-17 10:27:49 +05:00
QComboBox* ComboBoxPlanes;
QCheckBox* isOpenGLClipping;
2009-02-17 10:27:49 +05:00
QPushButton* buttonNew;
QMenu* MenuMode;
2009-02-17 10:27:49 +05:00
QPushButton* buttonDelete;
2012-08-09 16:03:55 +06:00
QListWidget* ActorList;
QCheckBox* SelectAllCheckBox;
QStackedLayout* ModeStackedLayout;
QGroupBox* GroupAbsolutePoint;
QLabel* TextLabelX;
QLabel* TextLabelY;
QLabel* TextLabelZ;
QtxDoubleSpinBox* SpinBox_X;
QtxDoubleSpinBox* SpinBox_Y;
QtxDoubleSpinBox* SpinBox_Z;
QPushButton* resetButton;
QGroupBox* GroupAbsoluteDirection;
QLabel* TextLabelDx;
QLabel* TextLabelDy;
QLabel* TextLabelDz;
QtxDoubleSpinBox* SpinBox_Dx;
QtxDoubleSpinBox* SpinBox_Dy;
QtxDoubleSpinBox* SpinBox_Dz;
QPushButton* invertButton;
QComboBox* CBAbsoluteOrientation;
QGroupBox* GroupRelative;
2009-02-17 10:27:49 +05:00
QLabel* TextLabelOrientation;
QLabel* TextLabelDistance;
QLabel* TextLabelRotation1;
QLabel* TextLabelRotation2;
QtxDoubleSpinSlider* SpinSliderDistance;
QtxIntSpinSlider* SpinSliderRotation1;
QtxIntSpinSlider* SpinSliderRotation2;
QComboBox* CBRelativeOrientation;
2009-02-17 10:27:49 +05:00
QCheckBox* PreviewCheckBox;
QCheckBox* AutoApplyCheckBox;
2009-02-17 10:27:49 +05:00
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QPushButton* buttonHelp;
bool myIsSelectPlane;
bool myIsPreviewMoved;
2009-02-17 10:27:49 +05:00
QString myHelpFileName;
SMESH::Mode CurrentMode;
2013-02-28 21:07:35 +06:00
protected slots:
virtual void reject();
2013-02-28 21:07:35 +06:00
2004-12-01 15:48:31 +05:00
public slots:
void onModeAbsolute();
void onModeRelative();
void ClickOnNew();
void ClickOnDelete();
void onSelectPlane( int );
void onSelectAll( int );
void onActorItemChanged( QListWidgetItem* );
void SetCurrentPlaneParam();
void onIsOpenGLClipping(bool);
void OnPreviewToggle( bool );
void onAutoApply(bool);
void ClickOnOk();
void ClickOnApply();
void ClickOnHelp();
void onSelectAbsoluteOrientation( int );
void onSelectRelativeOrientation( int );
void onReset();
void onInvert();
2004-12-01 15:48:31 +05:00
};
2009-02-17 10:27:49 +05:00
#endif // SMESHGUI_CLIPPINGDLG_H