From c3f5fb33ede3fc84e36a9f97d530f93f5fe49e44 Mon Sep 17 00:00:00 2001 From: tbaudier Date: Wed, 23 Dec 2015 10:58:53 +0100 Subject: [PATCH] Selection of the 2 points --- vv/qt_ui/vvToolProfile.ui | 81 +++++++++++-------- vv/vvToolProfile.cxx | 159 +++++++++++++++++++++++++++++--------- vv/vvToolProfile.h | 11 +++ 3 files changed, 183 insertions(+), 68 deletions(-) diff --git a/vv/qt_ui/vvToolProfile.ui b/vv/qt_ui/vvToolProfile.ui index b4cdb44..6366b49 100644 --- a/vv/qt_ui/vvToolProfile.ui +++ b/vv/qt_ui/vvToolProfile.ui @@ -18,33 +18,66 @@ - - - - false - - - + + 6 + - + - Foreground (FG) is greater than : + Select point 1 - - - - + - and lower than + Select point 2 - - false + + + + + + Cancel + + + + + + Point1 (mm): + + + + + + + + + + + + + + + + + + Point2 (mm): + + + + + + + + + + + + @@ -137,22 +170,6 @@ - - mRadioButtonLowerThan - toggled(bool) - mThresholdSlider2 - setEnabled(bool) - - - 85 - 129 - - - 305 - 129 - - - mCheckBoxUseBG toggled(bool) diff --git a/vv/vvToolProfile.cxx b/vv/vvToolProfile.cxx index 164b992..54eafd8 100644 --- a/vv/vvToolProfile.cxx +++ b/vv/vvToolProfile.cxx @@ -59,19 +59,21 @@ vvToolProfile::vvToolProfile(vvMainWindowBase * parent, Qt::WindowFlags f) { // GUI Initialization Ui_vvToolProfile::setupUi(mToolWidget); - mInteractiveDisplayIsEnabled = mCheckBoxInteractiveDisplay->isChecked(); + //mInteractiveDisplayIsEnabled = mCheckBoxInteractiveDisplay->isChecked(); // Connect signals & slots - connect(mRadioButtonLowerThan, SIGNAL(toggled(bool)), this, SLOT(enableLowerThan(bool))); - connect(mCheckBoxUseFG, SIGNAL(toggled(bool)), this, SLOT(useFGBGtoggled(bool))); - connect(mCheckBoxUseBG, SIGNAL(toggled(bool)), this, SLOT(useFGBGtoggled(bool))); - connect(mCheckBoxInteractiveDisplay, SIGNAL(toggled(bool)), this, SLOT(InteractiveDisplayToggled(bool))); + connect(mSelectPoint1Button, SIGNAL(clicked()), this, SLOT(selectPoint1())); + connect(mSelectPoint2Button, SIGNAL(clicked()), this, SLOT(selectPoint2())); + connect(mCancelPoints, SIGNAL(clicked()), this, SLOT(cancelPoints())); // Initialize some widget - mThresholdSlider1->SetText(""); - mThresholdSlider2->SetText(""); - mFGSlider->SetText("Foreground value"); - mBGSlider->SetText("Background value"); + //mThresholdSlider1->SetText(""); + //mThresholdSlider2->SetText(""); + //mFGSlider->SetText("Foreground value"); + //mBGSlider->SetText("Background value"); + + mPoint1 = NULL; + mPoint2 = NULL; // Main filter mFilter = clitk::ProfileImageGenericFilter::New(); @@ -89,10 +91,88 @@ vvToolProfile::~vvToolProfile() //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvToolProfile::selectPoint1() +{ + QString position = ""; + point1Selected = false; + if(mCurrentSlicerManager) { + if(mCurrentSlicerManager->GetSelectedSlicer() != -1) { + double x = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[0]; + double y = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[1]; + double z = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[2]; + position += QString::number(x,'f',1) + " "; + position += QString::number(y,'f',1) + " "; + position += QString::number(z,'f',1) + " "; + + mPoint1[0] = x; + mPoint1[1] = y; + mPoint1[2] = z; + + point1Selected = true; + } + } + mPosPoint1Label->setText(position); + isPointsSelected(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolProfile::selectPoint2() +{ + QString position = ""; + point2Selected = false; + if(mCurrentSlicerManager) { + if(mCurrentSlicerManager->GetSelectedSlicer() != -1) { + double x = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[0]; + double y = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[1]; + double z = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[2]; + position += QString::number(x,'f',1) + " "; + position += QString::number(y,'f',1) + " "; + position += QString::number(z,'f',1) + " "; + + mPoint2[0] = x; + mPoint2[1] = y; + mPoint2[2] = z; + + point2Selected = true; + } + } + mPosPoint2Label->setText(position); + isPointsSelected(); +} +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +bool vvToolProfile::isPointsSelected() +{ + if (point1Selected && point2Selected) { + //Lancer le calcule du profil + } + + return (point1Selected && point2Selected); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolProfile::cancelPoints() +{ + QString position = ""; + mPosPoint1Label->setText(position); + mPosPoint2Label->setText(position); + point1Selected = false; + point2Selected = false; + isPointsSelected(); +} +//------------------------------------------------------------------------------ + + //------------------------------------------------------------------------------ void vvToolProfile::InteractiveDisplayToggled(bool b) { - mInteractiveDisplayIsEnabled = b; + /*mInteractiveDisplayIsEnabled = b; if (!mInteractiveDisplayIsEnabled) { RemoveVTKObjects(); } else { @@ -103,7 +183,7 @@ void vvToolProfile::InteractiveDisplayToggled(bool b) } if (mCurrentSlicerManager) mCurrentSlicerManager->Render(); - } + }*/ } //------------------------------------------------------------------------------ @@ -144,6 +224,8 @@ void vvToolProfile::reject() { // DD("vvToolProfile::reject"); RemoveVTKObjects(); + delete [] mPoint1; + delete [] mPoint2; return vvToolWidgetBase::reject(); } //------------------------------------------------------------------------------ @@ -152,7 +234,7 @@ void vvToolProfile::reject() //------------------------------------------------------------------------------ void vvToolProfile::enableLowerThan(bool b) { - if (!b) { + /*if (!b) { mThresholdSlider1->resetMaximum(); for(unsigned int i=0; iHideActors(); @@ -165,7 +247,7 @@ void vvToolProfile::enableLowerThan(bool b) mImageContourLower[i]->ShowActors(); } mCurrentSlicerManager->Render(); - } + }*/ } //------------------------------------------------------------------------------ @@ -188,13 +270,18 @@ void vvToolProfile::InputIsSelected(vvSlicerManager * m) { mCurrentSlicerManager = m; + mPoint1 = new double[3]; + mPoint2 = new double[3]; + //mPoint1 = new double[m->GetImage()->GetNumberOfSpatialDimensions()]; + //mPoint2 = new double[m->GetImage()->GetNumberOfSpatialDimensions()]; + // Specific for this gui - mThresholdSlider1->SetValue(0); - mThresholdSlider2->SetValue(0); - mThresholdSlider1->SetImage(mCurrentImage); - mThresholdSlider2->SetImage(mCurrentImage); - mFGSlider->SetImage(mCurrentImage); - mBGSlider->SetImage(mCurrentImage); + //mThresholdSlider1->SetValue(0); + //mThresholdSlider2->SetValue(0); + //mThresholdSlider1->SetImage(mCurrentImage); + //mThresholdSlider2->SetImage(mCurrentImage); + //mFGSlider->SetImage(mCurrentImage); + //mBGSlider->SetImage(mCurrentImage); // DD(mCurrentSlicerManager->GetFileName().c_str()); // mFGSlider->SetMaximum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMax()); // mFGSlider->SetMinimum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMin()); @@ -202,7 +289,7 @@ void vvToolProfile::InputIsSelected(vvSlicerManager * m) // mBGSlider->SetMinimum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMin()); // Output is uchar ... - mFGSlider->SetMaximum(255); + /*mFGSlider->SetMaximum(255); mFGSlider->SetMinimum(0); mBGSlider->SetMaximum(255); mBGSlider->SetMinimum(0); @@ -211,7 +298,7 @@ void vvToolProfile::InputIsSelected(vvSlicerManager * m) mBGSlider->SetValue(0); mFGSlider->SetSingleStep(1); mBGSlider->SetSingleStep(1); - +*/ // VTK objects for interactive display for(int i=0; iGetNumberOfSlicers(); i++) { mImageContour.push_back(vvImageContour::New()); @@ -223,15 +310,15 @@ void vvToolProfile::InputIsSelected(vvSlicerManager * m) mImageContourLower[i]->SetColor(0.0, 0.0, 1.0); mImageContourLower[i]->SetDepth(100); // to be in front of (whe used with ROI tool) } - valueChangedT1(mThresholdSlider1->GetValue()); + //valueChangedT1(mThresholdSlider1->GetValue()); - connect(mThresholdSlider1, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT1(double))); - connect(mThresholdSlider2, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT2(double))); + //connect(mThresholdSlider1, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT1(double))); + //connect(mThresholdSlider2, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT2(double))); - connect(mCurrentSlicerManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int))); - connect(mCurrentSlicerManager,SIGNAL(UpdateTSlice(int,int)),this,SLOT(UpdateSlice(int, int))); + //connect(mCurrentSlicerManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int))); + //connect(mCurrentSlicerManager,SIGNAL(UpdateTSlice(int,int)),this,SLOT(UpdateSlice(int, int))); - connect(mCurrentSlicerManager,SIGNAL(UpdateOrientation(int,int)),this,SLOT(UpdateOrientation(int, int))); + //connect(mCurrentSlicerManager,SIGNAL(UpdateOrientation(int,int)),this,SLOT(UpdateOrientation(int, int))); // connect(mCurrentSlicerManager, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int))); InteractiveDisplayToggled(mInteractiveDisplayIsEnabled); @@ -269,9 +356,9 @@ void vvToolProfile::Update(int slicer) { if (!mInteractiveDisplayIsEnabled) return; if (!mCurrentSlicerManager) close(); - mImageContour[slicer]->Update(mThresholdSlider1->GetValue()); - if (mRadioButtonLowerThan->isChecked()) - mImageContourLower[slicer]->Update(mThresholdSlider2->GetValue()); + //mImageContour[slicer]->Update(mThresholdSlider1->GetValue()); + //if (mRadioButtonLowerThan->isChecked()) + // mImageContourLower[slicer]->Update(mThresholdSlider2->GetValue()); } //------------------------------------------------------------------------------ @@ -293,7 +380,7 @@ void vvToolProfile::GetArgsInfoFromGUI() bool inverseBGandFG = false; mArgsInfo.lower_given = 1; - mArgsInfo.lower_arg = mThresholdSlider1->GetValue(); + /*mArgsInfo.lower_arg = mThresholdSlider1->GetValue(); if (mRadioButtonLowerThan->isChecked()) { mArgsInfo.upper_given = 1; mArgsInfo.upper_arg = mThresholdSlider2->GetValue(); @@ -317,7 +404,7 @@ void vvToolProfile::GetArgsInfoFromGUI() if (mCheckBoxUseFG->isChecked()) mArgsInfo.mode_arg = (char*)"both"; else mArgsInfo.mode_arg = (char*)"BG"; } else mArgsInfo.mode_arg = (char*)"FG"; - +*/ mArgsInfo.verbose_flag = false; // // Required (even if not used) @@ -359,7 +446,7 @@ void vvToolProfile::apply() //------------------------------------------------------------------------------ void vvToolProfile::valueChangedT2(double v) { - // DD("valueChangedT2"); + /*// DD("valueChangedT2"); if (mRadioButtonLowerThan->isChecked()) { mThresholdSlider1->SetMaximum(v); if (!mInteractiveDisplayIsEnabled) return; @@ -367,7 +454,7 @@ void vvToolProfile::valueChangedT2(double v) mImageContourLower[i]->Update(v); } mCurrentSlicerManager->Render(); - } + }*/ } //------------------------------------------------------------------------------ @@ -375,7 +462,7 @@ void vvToolProfile::valueChangedT2(double v) //------------------------------------------------------------------------------ void vvToolProfile::valueChangedT1(double v) { - // DD("valueChangedT1"); + /*// DD("valueChangedT1"); if (!mCurrentSlicerManager) close(); mThresholdSlider2->SetMinimum(v); // int m1 = (int)lrint(v); @@ -383,6 +470,6 @@ void vvToolProfile::valueChangedT1(double v) for(int i=0;iGetNumberOfSlicers(); i++) { mImageContour[i]->Update(v); } - mCurrentSlicerManager->Render(); + mCurrentSlicerManager->Render();*/ } //------------------------------------------------------------------------------ diff --git a/vv/vvToolProfile.h b/vv/vvToolProfile.h index baaf4a9..dd5efbd 100644 --- a/vv/vvToolProfile.h +++ b/vv/vvToolProfile.h @@ -43,6 +43,8 @@ class vvToolProfile: void GetArgsInfoFromGUI(); virtual void InputIsSelected(vvSlicerManager * m); + bool isPointsSelected(); + //----------------------------------------------------- public slots: virtual void apply(); @@ -56,6 +58,10 @@ class vvToolProfile: void useFGBGtoggled(bool); void InteractiveDisplayToggled(bool b); // void LeftButtonReleaseEvent(int slicer); + + void selectPoint1(); + void selectPoint2(); + void cancelPoints(); protected: void RemoveVTKObjects(); @@ -66,6 +72,11 @@ class vvToolProfile: std::vector mImageContourLower; bool mInteractiveDisplayIsEnabled; + double* mPoint1; + double* mPoint2; + bool point1Selected; + bool point2Selected; + void Update(int slicer); }; // end class vvToolProfile -- 2.47.1