From: ouv Date: Tue, 20 Sep 2005 07:37:53 +0000 (+0000) Subject: Segmentation Cursor dialog implemented X-Git-Tag: BR-D5-38-2003_D2005-12-10~180 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ff9199995b43e04c4b72dfb43b89a3d4f1a0b0a3;p=modules%2Fvisu.git Segmentation Cursor dialog implemented --- diff --git a/src/VVTK/Makefile.in b/src/VVTK/Makefile.in index c215b302..9b1f8014 100755 --- a/src/VVTK/Makefile.in +++ b/src/VVTK/Makefile.in @@ -17,6 +17,7 @@ EXPORT_HEADERS = \ VVTK_ViewManager.h \ VVTK_ViewModel.h \ VVTK_InteractorStyle.h \ + VVTK_SegmentationCursorDlg.h \ VVTK_ViewWindow.h \ VVTK_View.h @@ -27,6 +28,7 @@ LIB_SRC = \ VVTK_ViewManager.cxx \ VVTK_ViewModel.cxx \ VVTK_InteractorStyle.cxx \ + VVTK_SegmentationCursorDlg.cxx \ VVTK_ViewWindow.cxx \ VVTK_Renderer.cxx \ VVTK_View.cxx @@ -35,6 +37,7 @@ LIB_MOC = \ VVTK_ViewWindow.h \ VVTK_ViewModel.h \ VVTK_ViewManager.h \ + VVTK_SegmentationCursorDlg.h \ VVTK_View.h CPPFLAGS += \ diff --git a/src/VVTK/VVTK_SegmentationCursorDlg.cxx b/src/VVTK/VVTK_SegmentationCursorDlg.cxx new file mode 100644 index 00000000..56255e1e --- /dev/null +++ b/src/VVTK/VVTK_SegmentationCursorDlg.cxx @@ -0,0 +1,252 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VVTK_SegmentationCursorDlg.cxx +// Author : Oleg Uvarov +// Module : VISU + +#include "VVTK_SegmentationCursorDlg.h" + +#include "VISU_ImplicitFunctionWidget.h" + +#include "QtxAction.h" +#include "QtxDblSpinBox.h" + +#include "utilities.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace std; + +VVTK_SegmentationCursorDlg::VVTK_SegmentationCursorDlg( QWidget* parent, const char* name ) + :QDialog( parent, name, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), + myEventCallbackCommand( vtkCallbackCommand::New() ) +{ + myPriority = 0.0; + myEventCallbackCommand->Delete(); + myEventCallbackCommand->SetClientData(this); + myEventCallbackCommand->SetCallback(VVTK_SegmentationCursorDlg::ProcessEvents); + + setCaption( tr( "SEGMENTATION_CURSOR_DLG_TITLE" ) ); + setSizeGripEnabled(TRUE); + + QVBoxLayout* TopLayout = new QVBoxLayout( this ); + TopLayout->setSpacing(6); + TopLayout->setMargin(11); + + QTabWidget* TabBox = new QTabWidget( this ); + + // Segmentation cursor pane + QVBox* SegmentationCursorBox = new QVBox( this ); + SegmentationCursorBox->setMargin(11); + SegmentationCursorBox->setSpacing(6); + + // Origin + QGroupBox* OriginGroup = new QGroupBox( tr( "ORIGIN_TITLE" ), SegmentationCursorBox, "OriginGroup" ); + OriginGroup->setColumnLayout( 0, Qt::Vertical ); + OriginGroup->layout()->setSpacing( 0 ); + OriginGroup->layout()->setMargin( 0 ); + + QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() ); + OriginGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + OriginGroupLayout->setSpacing(6); + OriginGroupLayout->setMargin(11); + + QLabel* XOriginLabel = new QLabel( tr( "ORIGIN_X" ), OriginGroup ); + myXOriginSpinBox = new QtxDblSpinBox( -1000.0, 1000.0, 1.0, OriginGroup ); + myXOriginSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myXOriginSpinBox->setMinimumWidth( 100 ); + myXOriginSpinBox->setValue( 0.0 ); + + QLabel* YOriginLabel = new QLabel( tr( "ORIGIN_Y" ), OriginGroup ); + myYOriginSpinBox = new QtxDblSpinBox( -1000.0, 1000.0, 1.0, OriginGroup ); + myYOriginSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myYOriginSpinBox->setMinimumWidth( 100 ); + myYOriginSpinBox->setValue( 0.0 ); + + QLabel* ZOriginLabel = new QLabel( tr( "ORIGIN_Z" ), OriginGroup ); + myZOriginSpinBox = new QtxDblSpinBox( -1000.0, 1000.0, 1.0, OriginGroup ); + myZOriginSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myZOriginSpinBox->setMinimumWidth( 100 ); + myZOriginSpinBox->setValue( 0.0 ); + + OriginGroupLayout->addWidget( XOriginLabel, 0, 0 ); + OriginGroupLayout->addWidget( myXOriginSpinBox, 0, 1 ); + OriginGroupLayout->addWidget( YOriginLabel, 0, 2 ); + OriginGroupLayout->addWidget( myYOriginSpinBox, 0, 3 ); + OriginGroupLayout->addWidget( ZOriginLabel, 0, 4 ); + OriginGroupLayout->addWidget( myZOriginSpinBox, 0, 5 ); + + // Direction + QGroupBox* DirectionGroup = new QGroupBox( tr( "DIRECTION_TITLE" ), SegmentationCursorBox, "DirectionGroup" ); + DirectionGroup->setColumnLayout( 0, Qt::Vertical ); + DirectionGroup->layout()->setSpacing( 0 ); + DirectionGroup->layout()->setMargin( 0 ); + + QGridLayout* DirectionGroupLayout = new QGridLayout( DirectionGroup->layout() ); + DirectionGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + DirectionGroupLayout->setSpacing(6); + DirectionGroupLayout->setMargin(11); + + QLabel* DXDirectionLabel = new QLabel( tr( "DIRECTION_DX" ), DirectionGroup ); + myDXDirectionSpinBox = new QtxDblSpinBox( -1.0, 1.0, 0.1, DirectionGroup ); + myDXDirectionSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myDXDirectionSpinBox->setMinimumWidth( 100 ); + myDXDirectionSpinBox->setValue( 0.0 ); + + QLabel* DYDirectionLabel = new QLabel( tr( "DIRECTION_DY" ), DirectionGroup ); + myDYDirectionSpinBox = new QtxDblSpinBox( -1.0, 1.0, 0.1, DirectionGroup ); + myDYDirectionSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myDYDirectionSpinBox->setMinimumWidth( 100 ); + myDYDirectionSpinBox->setValue( 0.0 ); + + QLabel* DZDirectionLabel = new QLabel( tr( "DIRECTION_DZ" ), DirectionGroup ); + myDZDirectionSpinBox = new QtxDblSpinBox( -1.0, 1.0, 0.1, DirectionGroup ); + myDZDirectionSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myDZDirectionSpinBox->setMinimumWidth( 100 ); + myDZDirectionSpinBox->setValue( 1.0 ); + + DirectionGroupLayout->addWidget( DXDirectionLabel, 0, 0 ); + DirectionGroupLayout->addWidget( myDXDirectionSpinBox, 0, 1 ); + DirectionGroupLayout->addWidget( DYDirectionLabel, 0, 2 ); + DirectionGroupLayout->addWidget( myDYDirectionSpinBox, 0, 3 ); + DirectionGroupLayout->addWidget( DZDirectionLabel, 0, 4 ); + DirectionGroupLayout->addWidget( myDZDirectionSpinBox, 0, 5 ); + + // Depth + QGroupBox* DepthGroup = new QGroupBox( tr( "DEPTH_TITLE" ), SegmentationCursorBox, "DepthGroup" ); + DepthGroup->setColumnLayout( 0, Qt::Vertical ); + DepthGroup->layout()->setSpacing( 0 ); + DepthGroup->layout()->setMargin( 0 ); + + QGridLayout* DepthGroupLayout = new QGridLayout( DepthGroup->layout() ); + DepthGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + DepthGroupLayout->setSpacing(6); + DepthGroupLayout->setMargin(11); + + QLabel* DepthLabel = new QLabel( tr( "DEPTH" ), DepthGroup ); + myDepthSpinBox = new QtxDblSpinBox( 0.0, 100.0, 1.0, DepthGroup ); + myDepthSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myDepthSpinBox->setMinimumWidth( 100 ); + myDepthSpinBox->setValue( 10.0 ); + + DepthGroupLayout->addWidget( DepthLabel, 0, 0 ); + DepthGroupLayout->addWidget( myDepthSpinBox, 0, 1 ); + + + TabBox->addTab( SegmentationCursorBox, tr("SEGMENTATION_CURSOR_TAB") ); + + // Common buttons =========================================================== + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + QPushButton* buttonApply = new QPushButton( tr( "&Apply" ), GroupButtons, "buttonApply" ); + buttonApply->setAutoDefault( TRUE ); + buttonApply->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + + QPushButton* buttonClose = new QPushButton( tr( "&Close" ) , GroupButtons, "buttonClose" ); + buttonClose->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonClose, 0, 2 ); + + TopLayout->addWidget( TabBox ); + TopLayout->addWidget( GroupButtons ); + + connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onClickApply() ) ); + connect( buttonClose, SIGNAL( clicked() ), this, SLOT( onClickClose() ) ); +} + +VVTK_SegmentationCursorDlg::~VVTK_SegmentationCursorDlg() +{ +} + +void VVTK_SegmentationCursorDlg::SetWidget( VISU_ImplicitFunctionWidget* theWidget ) +{ + myWidget = theWidget; + + myWidget->AddObserver(vtkCommand::EndInteractionEvent, + myEventCallbackCommand.GetPointer(), + myPriority); +} + +void VVTK_SegmentationCursorDlg::ProcessEvents(vtkObject* vtkNotUsed(theObject), + unsigned long theEvent, + void* theClientData, + void* vtkNotUsed(theCallData)) +{ + VVTK_SegmentationCursorDlg* self = reinterpret_cast(theClientData); + + switch(theEvent){ + case vtkCommand::EndInteractionEvent: + self->OnEndInteractionEvent(); + break; + } +} + +void VVTK_SegmentationCursorDlg::OnEndInteractionEvent() +{ + Update(); +} + +void VVTK_SegmentationCursorDlg::Update() +{ + float origin[3]; + myWidget->GetOrigin( origin ); + myXOriginSpinBox->setValue( origin[0] ); + myYOriginSpinBox->setValue( origin[1] ); + myZOriginSpinBox->setValue( origin[2] ); + + float normal[3]; + myWidget->GetNormal( normal ); + myDXDirectionSpinBox->setValue( normal[0] ); + myDYDirectionSpinBox->setValue( normal[1] ); + myDZDirectionSpinBox->setValue( normal[2] ); + + myDepthSpinBox->setValue( myWidget->Distance() ); +} + +void VVTK_SegmentationCursorDlg::onClickApply() +{ + float origin[3]; + origin[0] = myXOriginSpinBox->value(); + origin[1] = myYOriginSpinBox->value(); + origin[2] = myZOriginSpinBox->value(); + myWidget->SetOrigin( origin ); + + float normal[3]; + normal[0] = myDXDirectionSpinBox->value(); + normal[1] = myDYDirectionSpinBox->value(); + normal[2] = myDZDirectionSpinBox->value(); + myWidget->SetNormal( normal ); + + myWidget->SetDistance( myDepthSpinBox->value() ); + + myWidget->UpdatePlacement(); + + myWidget->GetInteractor()->Render(); +} + +void VVTK_SegmentationCursorDlg::onClickClose() +{ + reject(); + + myAction->setOn( false ); +} diff --git a/src/VVTK/VVTK_SegmentationCursorDlg.h b/src/VVTK/VVTK_SegmentationCursorDlg.h new file mode 100644 index 00000000..d0740d98 --- /dev/null +++ b/src/VVTK/VVTK_SegmentationCursorDlg.h @@ -0,0 +1,72 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VVTK_SegmentationCursorDlg.h +// Author : Oleg Uvarov +// Module : VISU + +#ifndef VVTK_SEGMENTATIONCURSORDLG_H +#define VVTK_SEGMENTATIONCURSORDLG_H + +#include + +#include +#include +#include + +class QtxAction; +class QtxDblSpinBox; +class QPushButton; + +class VISU_ImplicitFunctionWidget; + +class VVTK_SegmentationCursorDlg : public QDialog +{ + Q_OBJECT + +public: + VVTK_SegmentationCursorDlg( QWidget* parent = 0, const char* name = 0 ); + ~VVTK_SegmentationCursorDlg(); + + void SetWidget( VISU_ImplicitFunctionWidget* ); + void SetAction( QtxAction* theAction ) { myAction = theAction; } + + void InitFromWidget(); + + void Update(); + + void OnEndInteractionEvent(); + +private: + static void ProcessEvents(vtkObject* theObject, + unsigned long theEvent, + void* theClientData, + void* theCallData); + +private slots: + void onClickApply(); + void onClickClose(); + +private: + float myPriority; + vtkSmartPointer myEventCallbackCommand; + + VISU_ImplicitFunctionWidget* myWidget; + QtxAction* myAction; + + QtxDblSpinBox* myXOriginSpinBox; + QtxDblSpinBox* myYOriginSpinBox; + QtxDblSpinBox* myZOriginSpinBox; + + QtxDblSpinBox* myDXDirectionSpinBox; + QtxDblSpinBox* myDYDirectionSpinBox; + QtxDblSpinBox* myDZDirectionSpinBox; + + QtxDblSpinBox* myDepthSpinBox; + +}; + +#endif diff --git a/src/VVTK/VVTK_View.cxx b/src/VVTK/VVTK_View.cxx index 69edd938..d1428bb3 100644 --- a/src/VVTK/VVTK_View.cxx +++ b/src/VVTK/VVTK_View.cxx @@ -32,6 +32,7 @@ #include "SVTK_RenderWindowInteractor.h" #include "VVTK_Renderer.h" +#include "VVTK_SegmentationCursorDlg.h" #include "SUIT_ResourceMgr.h" #include "QtxAction.h" @@ -142,6 +143,9 @@ VVTK_MainWindow1 anAction->setStatusTip(tr("DSC_VVTK_PLANE_SEGMENTATION_SWITCH")); connect(anAction, SIGNAL(toggled(bool)), this, SLOT(OnPlaneSegmentationSwitch(bool))); anAction->addTo( myPtsToolBar ); + + mySegmentationCursorDlg = new VVTK_SegmentationCursorDlg( this, "SegmentationCursorDlg" ); + mySegmentationCursorDlg->SetAction( anAction ); } void @@ -150,6 +154,7 @@ VVTK_MainWindow1 { myRenderer = VVTK_Renderer1::New(); VVTK_MainWindowBase::Initialize(myRenderer); + mySegmentationCursorDlg->SetWidget( myRenderer->GetImplicitFunctionWidget() ); myRenderer->Delete(); } @@ -186,6 +191,14 @@ VVTK_MainWindow1 { myRenderer->GetImplicitFunctionWidget()->SetEnabled(theIsPlaneSegmentationOn); mySplitter->setCollapsible(this,!theIsPlaneSegmentationOn); + + if( theIsPlaneSegmentationOn ) + { + mySegmentationCursorDlg->Update(); + mySegmentationCursorDlg->show(); + } + else + mySegmentationCursorDlg->hide(); } diff --git a/src/VVTK/VVTK_View.h b/src/VVTK/VVTK_View.h index 033b10a4..9cc036b5 100644 --- a/src/VVTK/VVTK_View.h +++ b/src/VVTK/VVTK_View.h @@ -12,6 +12,7 @@ class VVTK_Renderer1; class VVTK_Renderer2; class QSplitter; +class VVTK_SegmentationCursorDlg; //---------------------------------------------------------------------------- class VVTK_EXPORT VVTK_MainWindowBase: public SVTK_MainWindow @@ -68,6 +69,8 @@ public: protected: VVTK_Renderer1* myRenderer; QSplitter* mySplitter; + + VVTK_SegmentationCursorDlg* mySegmentationCursorDlg; };