--- /dev/null
+// 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 <qtabwidget.h>
+#include <qvbox.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+
+#include <vtkRenderer.h>
+#include <vtkRenderWindowInteractor.h>
+
+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<VVTK_SegmentationCursorDlg*>(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 );
+}