From 1a305acd8ed2b68a71fe5b0645b1bb4a683a4c20 Mon Sep 17 00:00:00 2001 From: ouv Date: Thu, 15 Dec 2005 08:59:26 +0000 Subject: [PATCH] Fixed bug GVIEW10826 : magnification do not work with segmentation --- src/VISU_I/VISU_GaussPoints_i.cc | 2 +- src/VVTK/VVTK_SegmentationCursorDlg.cxx | 88 ++++++++++++++++++++++--- src/VVTK/VVTK_SegmentationCursorDlg.h | 15 +++++ src/VVTK/VVTK_SizeBox.cxx | 54 +++++++++++++-- src/VVTK/VVTK_SizeBox.h | 3 +- 5 files changed, 146 insertions(+), 16 deletions(-) diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index 64a3eed9..b54e5ffa 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -711,7 +711,7 @@ VISU::GaussPoints_i ::UpdateFromActor(VISU_GaussPtsAct* theActor) { if(MYDEBUG) MESSAGE("GaussPoints_i::UpdateFromActor - this = "<ChangeMagnification(theActor->ChangeMagnification()); + myGaussPointsPL->ChangeMagnification(theActor->GetChangeMagnification()); UpdateActors(); } diff --git a/src/VVTK/VVTK_SegmentationCursorDlg.cxx b/src/VVTK/VVTK_SegmentationCursorDlg.cxx index b17cc183..b15e62fc 100644 --- a/src/VVTK/VVTK_SegmentationCursorDlg.cxx +++ b/src/VVTK/VVTK_SegmentationCursorDlg.cxx @@ -49,6 +49,7 @@ #include "QtxAction.h" #include "QtxDblSpinBox.h" +#include "QtxIntSpinBox.h" using namespace std; @@ -132,6 +133,10 @@ VVTK_SegmentationCursorDlg::VVTK_SegmentationCursorDlg( QWidget* parent, const c myEventCallbackCommand->SetClientData(this); myEventCallbackCommand->SetCallback(VVTK_SegmentationCursorDlg::ProcessEvents); + myInsideCursorSettings->AddObserver(VISU::UpdateFromSettingsEvent, + myEventCallbackCommand.GetPointer(), + myPriority); + SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); setCaption( tr( "SEGMENTATION_CURSOR_DLG_TITLE" ) ); @@ -294,7 +299,7 @@ VVTK_SegmentationCursorDlg::VVTK_SegmentationCursorDlg( QWidget* parent, const c // Size myInsideSizeBox = new VVTK_SizeBox( anInsideGroup ); - myInsideSizeBox->setType( VVTK_SizeBox::Results ); + myInsideSizeBox->setType( VVTK_SizeBox::Inside ); anInsideGroupLayout->addWidget( myInsidePrimitiveBox, 0, 0 ); anInsideGroupLayout->addWidget( myInsideSizeBox, 1, 0 ); @@ -319,7 +324,35 @@ VVTK_SegmentationCursorDlg::VVTK_SegmentationCursorDlg( QWidget* parent, const c anOutsideGroupLayout->addWidget( myOutsidePrimitiveBox, 0, 0 ); anOutsideGroupLayout->addWidget( myOutsideSizeBox, 1, 0 ); - // + + + // Magnification + QGroupBox* MagnificationGroup = new QGroupBox ( tr( "MAGNIFICATION_TITLE" ), myGaussPointsBox, "MagnificationGroup" ); + MagnificationGroup->setColumnLayout(0, Qt::Vertical ); + MagnificationGroup->layout()->setSpacing( 0 ); + MagnificationGroup->layout()->setMargin( 0 ); + + QGridLayout* MagnificationGroupLayout = new QGridLayout (MagnificationGroup->layout()); + MagnificationGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + MagnificationGroupLayout->setSpacing(6); + MagnificationGroupLayout->setMargin(11); + + myMagnificationLabel = new QLabel( tr( "MAGNIFICATION" ), MagnificationGroup ); + myMagnificationSpinBox = new QtxIntSpinBox( 1, 10000, 10, MagnificationGroup ); + myMagnificationSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + MagnificationGroupLayout->addWidget( myMagnificationLabel, 0, 0 ); + MagnificationGroupLayout->addWidget( myMagnificationSpinBox, 0, 1 ); + + // Increment + myIncrementLabel = new QLabel( tr( "INCREMENT" ), MagnificationGroup ); + myIncrementSpinBox = new QtxDblSpinBox( 0.01, 10, 0.1, MagnificationGroup ); + myIncrementSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + MagnificationGroupLayout->addWidget( myIncrementLabel, 0, 2 ); + MagnificationGroupLayout->addWidget( myIncrementSpinBox, 0, 3 ); + + myTabBox->addTab( myGaussPointsBox, tr( "GAUSS_POINTS_TAB" ) ); myTabBox->showPage( myGaussPointsBox ); @@ -356,6 +389,27 @@ VVTK_SegmentationCursorDlg::~VVTK_SegmentationCursorDlg() SetWidgetCtrl(NULL); } +float VVTK_SegmentationCursorDlg::getMagnification() const +{ + return myMagnificationSpinBox->value() / 100.0; +} + +void VVTK_SegmentationCursorDlg::setMagnification( float theMagnification ) +{ + myMagnificationSpinBox->setValue( ( int )( theMagnification * 100 ) ); +} + +float VVTK_SegmentationCursorDlg::getIncrement() const +{ + return myIncrementSpinBox->value(); +} + +void VVTK_SegmentationCursorDlg::setIncrement( float theIncrement ) +{ + myIncrementSpinBox->setValue( theIncrement ); +} + + void VVTK_SegmentationCursorDlg::SetWidgetCtrl( VISU_WidgetCtrl* theWidgetCtrl ) { if(myWidgetCtrl == theWidgetCtrl) @@ -383,6 +437,16 @@ void VVTK_SegmentationCursorDlg::ProcessEvents(vtkObject* vtkNotUsed(theObject), case vtkCommand::EndInteractionEvent: self->UpdateSegmentation(); break; + case VISU::UpdateFromSettingsEvent: + self->GetOutsideCursorSettings()->SetMagnification( self->GetInsideCursorSettings()->GetMagnification() ); + self->GetOutsideCursorSettings()->SetIncrement( self->GetInsideCursorSettings()->GetIncrement() ); + + self->UpdateInsideGaussPoints(); + self->UpdateOutsideGaussPoints(); + + self->GetInsideCursorSettings()->InvokeEvent(VISU::UpdateInsideSettingsEvent,NULL); + self->GetOutsideCursorSettings()->InvokeEvent(VISU::UpdateOutsideSettingsEvent,NULL); + break; } } @@ -423,6 +487,7 @@ void VVTK_SegmentationCursorDlg::UpdateSegmentation() myZOriginSpinBox->setValue( origin[2] ); aRadius=pSphereWidget->GetRadius(); myRadiusSpinBox->setValue(aRadius); + myRatioSpinBox->setValue(pSphereWidget->GetRatio()); } } @@ -450,8 +515,9 @@ void VVTK_SegmentationCursorDlg::UpdateInsideGaussPoints() myInsideSizeBox->setMinSize( myInsideCursorSettings->GetMinSize() ); myInsideSizeBox->setMaxSize( myInsideCursorSettings->GetMaxSize() ); - myInsideSizeBox->setMagnification( myInsideCursorSettings->GetMagnification() ); - myInsideSizeBox->setIncrement( myInsideCursorSettings->GetIncrement() ); + + this->setMagnification( myInsideCursorSettings->GetMagnification() ); + this->setIncrement( myInsideCursorSettings->GetIncrement() ); return; } @@ -483,10 +549,10 @@ void VVTK_SegmentationCursorDlg::UpdateInsideGaussPoints() myInsideSizeBox->setMaxSize( aMaxSize / 100.0 ); aMagnification = aResourceMgr->integerValue( "VISU", "inside_point_sprite_magnification", aMagnification ); - myInsideSizeBox->setMagnification( aMagnification / 100.0 ); + this->setMagnification( aMagnification / 100.0 ); anIncrement = aResourceMgr->doubleValue( "VISU", "inside_point_sprite_increment", anIncrement ); - myInsideSizeBox->setIncrement( anIncrement ); + this->setIncrement( anIncrement ); ApplyInsideGaussPoints(); } @@ -647,6 +713,8 @@ void VVTK_SegmentationCursorDlg::ApplySegmentationCursor() aRadius=myRadiusSpinBox->value(); pSphereWidget->SetRadius(aRadius); + pSphereWidget->SetRatio(myRatioSpinBox->value()); + myWidgetCtrl->InvokeEvent(vtkCommand::EndInteractionEvent,NULL); myWidgetCtrl->GetInteractor()->Render(); } @@ -669,8 +737,9 @@ void VVTK_SegmentationCursorDlg::ApplyInsideGaussPoints() myInsideCursorSettings->SetMinSize( myInsideSizeBox->getMinSize() ); myInsideCursorSettings->SetMaxSize( myInsideSizeBox->getMaxSize() ); - myInsideCursorSettings->SetMagnification( myInsideSizeBox->getMagnification() ); - myInsideCursorSettings->SetIncrement( myInsideSizeBox->getIncrement() ); + + myInsideCursorSettings->SetMagnification( this->getMagnification() ); + myInsideCursorSettings->SetIncrement( this->getIncrement() ); myInsideCursorSettings->InvokeEvent(VISU::UpdateInsideSettingsEvent,NULL); } @@ -700,6 +769,9 @@ void VVTK_SegmentationCursorDlg::ApplyOutsideGaussPoints() aColor[2] = aButtonColor.blue() / 255.0; myOutsideCursorSettings->SetColor( aColor ); + myOutsideCursorSettings->SetMagnification( this->getMagnification() ); + myOutsideCursorSettings->SetIncrement( this->getIncrement() ); + myOutsideCursorSettings->InvokeEvent(VISU::UpdateOutsideSettingsEvent,NULL); } diff --git a/src/VVTK/VVTK_SegmentationCursorDlg.h b/src/VVTK/VVTK_SegmentationCursorDlg.h index 29f5fed2..ea6d3bdf 100644 --- a/src/VVTK/VVTK_SegmentationCursorDlg.h +++ b/src/VVTK/VVTK_SegmentationCursorDlg.h @@ -30,6 +30,7 @@ class QVBox; class QtxAction; class QtxDblSpinBox; +class QtxIntSpinBox; class VISU_GaussPtsAct1; class VISU_InsideCursorSettings; @@ -79,6 +80,15 @@ public: VISU_InsideCursorSettings* GetInsideCursorSettings(); VISU_OutsideCursorSettings* GetOutsideCursorSettings(); + vtkSmartPointer GetEventCallbackCommand() { return myEventCallbackCommand; } + +public: + float getMagnification() const; + void setMagnification( float ); + + float getIncrement() const; + void setIncrement( float ); + protected: void ApplySegmentationCursor(); void ApplyInsideGaussPoints(); @@ -154,6 +164,11 @@ private: QString myOutsideAlphaTexture; vtkSmartPointer myOutsideCursorSettings; + + QLabel* myMagnificationLabel; + QtxIntSpinBox* myMagnificationSpinBox; + QLabel* myIncrementLabel; + QtxDblSpinBox* myIncrementSpinBox; }; #endif diff --git a/src/VVTK/VVTK_SizeBox.cxx b/src/VVTK/VVTK_SizeBox.cxx index 227a3b96..654b69a7 100644 --- a/src/VVTK/VVTK_SizeBox.cxx +++ b/src/VVTK/VVTK_SizeBox.cxx @@ -98,7 +98,7 @@ VVTK_SizeBox::VVTK_SizeBox( QWidget* parent ) : // Magnification myMagnificationLabel = new QLabel( tr( "MAGNIFICATION" ), SizeGroup ); - myMagnificationSpinBox = new QtxIntSpinBox( 10, 1000, 10, SizeGroup ); + myMagnificationSpinBox = new QtxIntSpinBox( 1, 10000, 10, SizeGroup ); myMagnificationSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); SizeGroupLayout->addWidget( myMagnificationLabel, 2, 0 ); @@ -155,7 +155,15 @@ void VVTK_SizeBox::onToggleResults() myMaxSizeLabel->show(); myMaxSizeSpinBox->show(); + myMagnificationLabel->show(); + myMagnificationSpinBox->show(); + + myIncrementLabel->show(); + myIncrementSpinBox->show(); + myColorGroup->hide(); + + myUniformCheckBox->hide(); } void VVTK_SizeBox::onToggleGeometry() @@ -174,11 +182,44 @@ void VVTK_SizeBox::onToggleGeometry() myMaxSizeLabel->hide(); myMaxSizeSpinBox->hide(); + myMagnificationLabel->show(); + myMagnificationSpinBox->show(); + + myIncrementLabel->show(); + myIncrementSpinBox->show(); + myColorGroup->show(); myUniformCheckBox->hide(); } +void VVTK_SizeBox::onToggleInside() +{ + myType = VVTK_SizeBox::Inside; + + myOutsideSizeLabel->hide(); + myOutsideSizeSpinBox->hide(); + + myGeomSizeLabel->hide(); + myGeomSizeSpinBox->hide(); + + myMinSizeLabel->show(); + myMinSizeSpinBox->show(); + + myMaxSizeLabel->show(); + myMaxSizeSpinBox->show(); + + myMagnificationLabel->hide(); + myMagnificationSpinBox->hide(); + + myIncrementLabel->hide(); + myIncrementSpinBox->hide(); + + myColorGroup->hide(); + + myUniformCheckBox->hide(); +} + void VVTK_SizeBox::onToggleOutside() { myType = VVTK_SizeBox::Outside; @@ -214,6 +255,7 @@ void VVTK_SizeBox::setType( int theType ) { case VVTK_SizeBox::Results : onToggleResults(); break; case VVTK_SizeBox::Geometry : onToggleGeometry(); break; + case VVTK_SizeBox::Inside : onToggleInside(); break; case VVTK_SizeBox::Outside : onToggleOutside(); break; default : break; } @@ -226,7 +268,7 @@ float VVTK_SizeBox::getOutsideSize() const void VVTK_SizeBox::setOutsideSize( float theOutsideSize ) { - myOutsideSizeSpinBox->setValue( theOutsideSize * 100.0 ); + myOutsideSizeSpinBox->setValue( ( int )( theOutsideSize * 100 ) ); } float VVTK_SizeBox::getGeomSize() const @@ -236,7 +278,7 @@ float VVTK_SizeBox::getGeomSize() const void VVTK_SizeBox::setGeomSize( float theGeomSize ) { - myGeomSizeSpinBox->setValue( theGeomSize * 100.0 ); + myGeomSizeSpinBox->setValue( ( int )( theGeomSize * 100 ) ); } float VVTK_SizeBox::getMinSize() const @@ -246,7 +288,7 @@ float VVTK_SizeBox::getMinSize() const void VVTK_SizeBox::setMinSize( float theMinSize ) { - myMinSizeSpinBox->setValue( theMinSize * 100.0 ); + myMinSizeSpinBox->setValue( ( int )( theMinSize * 100 ) ); } float VVTK_SizeBox::getMaxSize() const @@ -256,7 +298,7 @@ float VVTK_SizeBox::getMaxSize() const void VVTK_SizeBox::setMaxSize( float theMaxSize ) { - myMaxSizeSpinBox->setValue( theMaxSize * 100.0 ); + myMaxSizeSpinBox->setValue( ( int )( theMaxSize * 100 ) ); } float VVTK_SizeBox::getMagnification() const @@ -266,7 +308,7 @@ float VVTK_SizeBox::getMagnification() const void VVTK_SizeBox::setMagnification( float theMagnification ) { - myMagnificationSpinBox->setValue( theMagnification * 100.0 ); + myMagnificationSpinBox->setValue( ( int )( theMagnification * 100 ) ); } float VVTK_SizeBox::getIncrement() const diff --git a/src/VVTK/VVTK_SizeBox.h b/src/VVTK/VVTK_SizeBox.h index 55067caa..a47f342c 100644 --- a/src/VVTK/VVTK_SizeBox.h +++ b/src/VVTK/VVTK_SizeBox.h @@ -44,7 +44,7 @@ class VVTK_SizeBox : public QVBox Q_OBJECT public: - enum { Results = 0, Geometry, Outside }; + enum { Results = 0, Geometry, Inside, Outside }; public: VVTK_SizeBox( QWidget* ); @@ -81,6 +81,7 @@ public: protected slots: void onToggleResults(); void onToggleGeometry(); + void onToggleInside(); void onToggleOutside(); void onColorButtonPressed(); -- 2.39.2