endif(COMMAND cmake_policy)
PROJECT(clitk)
#=========================================================
-IF(CMAKE_COMPILER_IS_GNUCXX)
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
-ENDIF(CMAKE_COMPILER_IS_GNUCXX)
+#IF(CMAKE_COMPILER_IS_GNUCXX)
+# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
+# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ")
+#ENDIF(CMAKE_COMPILER_IS_GNUCXX)
IF(MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
ENDIF(MSVC)
vvResamplerDialog.cxx
vvSegmentationDialog.cxx
vvSurfaceViewerDialog.cxx
+ vvMainWindowBase.cxx
vvMainWindow.cxx
vvDeformationDialog.cxx
vvImageWarp.cxx
vvIntensityValueSlider.cxx
vvToolManager.cxx
vvToolCreatorBase.cxx
+ vvToolWidgetBase.cxx
+ vvToolFoo.cxx
+ vvToolCropImage.cxx
vvToolBinarize.cxx
vvToolInputSelectorWidget.cxx
vvImageContour.cxx
)
QT4_WRAP_CPP(vv_SRCS
+ vvMainWindowBase.h
vvMainWindow.h
QTreePushButton.h
vvInfoPanel.h
vvCropDialog.h
vvIntensityValueSlider.h
vvToolCreatorBase.h
+ vvToolFoo.h
vvToolBinarize.h
vvToolInputSelectorWidget.h
+ vvToolWidgetBase.h
+ vvToolCropImage.h
)
QT4_WRAP_UI(vv_UI_CXX
qt_ui/vvCropDialog.ui
qt_ui/vvDummyWindow.ui #For testing
qt_ui/vvIntensityValueSlider.ui
+ qt_ui/vvToolWidgetBase.ui
+ qt_ui/vvToolFoo.ui
+ qt_ui/vvToolCropImage.ui
qt_ui/vvToolBinarize.ui
qt_ui/vvToolInputSelectorWidget.ui
)
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvToolCropImage</class>
+ <widget class="QWidget" name="vvToolCropImage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>X min</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QSlider" name="xminSlider">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>X max</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSlider" name="xmaxSlider">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Y min</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QSlider" name="yminSlider">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Y max</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QSlider" name="ymaxSlider">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Z min</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QSlider" name="zminSlider">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>Z max</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QSlider" name="zmaxSlider">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QSpinBox" name="spin_xmin"/>
+ </item>
+ <item row="1" column="2">
+ <widget class="QSpinBox" name="spin_xmax"/>
+ </item>
+ <item row="2" column="2">
+ <widget class="QSpinBox" name="spin_ymin"/>
+ </item>
+ <item row="3" column="2">
+ <widget class="QSpinBox" name="spin_ymax"/>
+ </item>
+ <item row="4" column="2">
+ <widget class="QSpinBox" name="spin_zmin"/>
+ </item>
+ <item row="5" column="2">
+ <widget class="QSpinBox" name="spin_zmax"/>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvToolFoo</class>
+ <widget class="QWidget" name="vvToolFoo">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>358</width>
+ <height>213</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <widget class="QPushButton" name="pushButton">
+ <property name="geometry">
+ <rect>
+ <x>150</x>
+ <y>90</y>
+ <width>75</width>
+ <height>23</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Foo !</string>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>pushButton</sender>
+ <signal>clicked()</signal>
+ <receiver>vvToolFoo</receiver>
+ <slot>close()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>220</x>
+ <y>135</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>100</x>
+ <y>-18</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvToolWidgetBase</class>
+ <widget class="QWidget" name="vvToolWidgetBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>615</width>
+ <height>372</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QSplitter" name="splitter">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <widget class="vvToolInputSelectorWidget" name="mToolInputSelectionWidget" native="true"/>
+ <widget class="QWidget" name="mToolWidget" native="true"/>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ <zorder>splitter</zorder>
+ <zorder>buttonBox</zorder>
+ <zorder>mToolInputSelectionWidget</zorder>
+ <zorder>groupBox</zorder>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>vvToolInputSelectorWidget</class>
+ <extends>QWidget</extends>
+ <header location="global">vvToolInputSelectorWidget.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
Program: vv
Module: $RCSfile: vvImageContour.cxx,v $
Language: C++
- Date: $Date: 2010/02/07 12:00:59 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2010/02/24 11:42:42 $
+ Version: $Revision: 1.3 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2010
mSquaresActorList.push_back(mSquaresActor);
mSquaresList.push_back(mSquares);
mClipperList.push_back(mClipper);
-
}
//mSquares->Update();
}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+void vvImageContour::removeActors() {
+ // DD("removeActors");
+ if (!mSlicer) return;
+ mSlice = mSlicer->GetSlice();
+ // DD(mSlice);
+ for(unsigned int i=0; i<mSquaresActorList.size(); i++) {
+ mSquaresActorList[i]->VisibilityOff();
+ //mSquaresActorList[i]->Update();
+ }
+}
+//------------------------------------------------------------------------------
+
+
//------------------------------------------------------------------------------
void vvImageContour::update(int value) {
+ // DD(value);
+ if (!mSlicer) return;
mSlice = mSlicer->GetSlice();
// Only change actor visibility if tslice change
Program: vv
Module: $RCSfile: vvImageContour.h,v $
Language: C++
- Date: $Date: 2010/02/07 12:00:59 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2010/02/24 11:42:42 $
+ Version: $Revision: 1.3 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2010
void setSlicer(vvSlicer * slicer);
// vtkActor * getActor() { return mSquaresActor;}
void update(int value);
+ void removeActors();
protected:
vvSlicer * mSlicer;
Program: vv
Module: $RCSfile: vvIntensityValueSlider.cxx,v $
Language: C++
- Date: $Date: 2010/02/07 12:00:59 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2010/02/24 11:42:42 $
+ Version: $Revision: 1.3 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2008
//------------------------------------------------------------------------------
void vvIntensityValueSlider::Update() {
- DD(mImage->GetScalarTypeAsString());
- DD(mImage->GetFirstVTKImageData()->GetScalarTypeMax());
- DD(mImage->GetFirstVTKImageData()->GetScalarTypeMin());
+ // DD(mImage->GetScalarTypeAsString());
+// DD(mImage->GetFirstVTKImageData()->GetScalarTypeMax());
+// DD(mImage->GetFirstVTKImageData()->GetScalarTypeMin());
// double max = mImage->GetFirstVTKImageData()->GetScalarTypeMax();
// double min = mImage->GetFirstVTKImageData()->GetScalarTypeMin();
mImage->GetFirstVTKImageData()->GetScalarRange(range);
mMin = range[0];
mMax = range[1];
- DD(mMax);
- DD(mMin);
+ // DD(mMax);
+// DD(mMin);
mSlider->setMaximum(mMax);
mSlider->setMinimum(mMin);
mSpinBox->setMaximum(mMax);
Program: vv
Module: $RCSfile: vvMainWindow.cxx,v $
Language: C++
- Date: $Date: 2010/02/17 20:52:39 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2010/02/24 11:42:42 $
+ Version: $Revision: 1.12 $
Author : Pierre Seroul (pierre.seroul@gmail.com)
Copyright (C) 200COLUMN_IMAGE_NAME
#include "vvMeshReader.h"
#include "vvCropDialog.h"
#include "vvConstants.h"
+
#ifdef CLITK_VV_USE_BDCM
#include <bdcmDicomFilesSelectorDialog.h>
#endif
5,Qt::UserRole mSlicerManager id*/
//------------------------------------------------------------------------------
-vvMainWindow::vvMainWindow() {
+vvMainWindow::vvMainWindow():vvMainWindowBase() {
setupUi(this); // this sets up the GUI
mInputPathName = "";
- mCurrentToolInfo = 0;
+ mMenuTools = menuTools;
+ mMainWidget = this;
//Init the contextMenu
this->setContextMenuPolicy(Qt::CustomContextMenu);
connect(actionAdd_fusion_image,SIGNAL(triggered()),this,SLOT(AddFusionImage()));
contextActions.push_back(actionAdd_fusion_image);
-
//init the DataTree
mSlicerManagers.resize(0);
}
// Adding all new tools (insertion in the menu)
- vvToolManager::GetInstance()->Initialize(this);
+ vvToolManager::GetInstance()->InsertToolsInMenu(this);
}
//------------------------------------------------------------------------------
QApplication::restoreOverrideCursor();
}
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvMainWindow::AddContour(int image_index, vvMesh::Pointer contour, bool propagation)
{
QTreeWidgetItem *item = new QTreeWidgetItem();
mSlicerManagers[image_index]->AddContour(contour,propagation);
mSlicerManagers[image_index]->Render();
}
+//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::OpenVTKContour()
QApplication::restoreOverrideCursor();
}
}
+//------------------------------------------------------------------------------
+
+
//------------------------------------------------------------------------------
void vvMainWindow::OpenDCStructContour()
{
}
}
}
+//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::ComputeDeformableRegistration()
}
else QMessageBox::information(this, "Need to open image","You must open an image first.");
}
+//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::WarpImage()
else
QMessageBox::warning(this,tr("No vector field"),tr("Sorry, can't warp without a vector field"));
}
+//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::WarpImage(vvSlicerManager* selected_slicer,int reference_phase)
else
QMessageBox::warning(this,tr("No vector field"),tr("Sorry, can't warp without a vector field."));
}
+//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
vvMainWindow::~vvMainWindow() {
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::MergeImages() {
QString Extensions = EXTENSIONS;
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::MergeImagesWithTime() {
QString Extensions = EXTENSIONS;
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::OpenDicom() {
std::vector<std::string> files;
}
QApplication::restoreOverrideCursor();
-
- // vvToolManager::GetInstance()->UpdateEnabledTool();
- // emit SlicerManagersHasChanged();
}
//------------------------------------------------------------------------------
presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset());
colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap());
- infoPanel->setFileName(image);
- infoPanel->setDimension(dim);
- infoPanel->setSizePixel(GetVectorIntAsString(inputSize));
- infoPanel->setSizeMM(GetVectorDoubleAsString(sizeMM));
- infoPanel->setOrigin(GetVectorDoubleAsString(origin));
- infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing));
- infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")");
-
- landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(),
- mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size());
- landmarksPanel->SetCurrentPath(mInputPathName.toStdString());
- landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str());
-
- overlayPanel->getCurrentImageName(mSlicerManagers[index]->GetFileName().c_str());
- for (int i = 0; i < 4;i++)
- {
- if (DataTree->selectedItems()[0]->data(i+1,Qt::CheckStateRole).toInt() > 0 || i == 3)
- {
- mSlicerManagers[index]->UpdateInfoOnCursorPosition(i);
- break;
- }
- }
- windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow());
- levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel());
- presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset());
- colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap());
+ infoPanel->setFileName(image);
+ infoPanel->setDimension(dim);
+ infoPanel->setSizePixel(GetVectorIntAsString(inputSize));
+ infoPanel->setSizeMM(GetVectorDoubleAsString(sizeMM));
+ infoPanel->setOrigin(GetVectorDoubleAsString(origin));
+ infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing));
+ infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")");
- if (mSlicerManagers[index]->GetSlicer(0)->GetVF())
- {
- overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str());
- overlayPanel->getVFProperty(mSlicerManagers[index]->GetSlicer(0)->GetVFSubSampling(),
- mSlicerManagers[index]->GetSlicer(0)->GetVFScale(),
- mSlicerManagers[index]->GetSlicer(0)->GetVFLog());
- }
- else
- {
- overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str());
- overlayPanel->getVFProperty(-1,-1,-1);
- }
- if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay())
- {
- overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str());
- overlayPanel->getOverlayProperty(mSlicerManagers[index]->GetOverlayColor());
- }
- else
- {
- overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str());
- overlayPanel->getOverlayProperty(-1);
- }
- if (mSlicerManagers[index]->GetSlicer(0)->GetFusion())
- {
- overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
- overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(),
- mSlicerManagers[index]->GetFusionColorMap(),
- mSlicerManagers[index]->GetFusionWindow(),
- mSlicerManagers[index]->GetFusionLevel());
- }
- else
- {
- overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
- overlayPanel->getFusionProperty(-1, -1,-1,-1);
- }
- }
+ landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(),
+ mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size());
+ landmarksPanel->SetCurrentPath(mInputPathName.toStdString());
+ landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str());
+
+ overlayPanel->getCurrentImageName(mSlicerManagers[index]->GetFileName().c_str());
+ for (int i = 0; i < 4;i++)
+ {
+ if (DataTree->selectedItems()[0]->data(i+1,Qt::CheckStateRole).toInt() > 0 || i == 3)
+ {
+ mSlicerManagers[index]->UpdateInfoOnCursorPosition(i);
+ break;
+ }
+ }
+ windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow());
+ levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel());
+ presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset());
+ colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap());
+
+ if (mSlicerManagers[index]->GetSlicer(0)->GetVF())
+ {
+ overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str());
+ overlayPanel->getVFProperty(mSlicerManagers[index]->GetSlicer(0)->GetVFSubSampling(),
+ mSlicerManagers[index]->GetSlicer(0)->GetVFScale(),
+ mSlicerManagers[index]->GetSlicer(0)->GetVFLog());
+ }
+ else
+ {
+ overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str());
+ overlayPanel->getVFProperty(-1,-1,-1);
+ }
+ if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay())
+ {
+ overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str());
+ overlayPanel->getOverlayProperty(mSlicerManagers[index]->GetOverlayColor());
+ }
+ else
+ {
+ overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str());
+ overlayPanel->getOverlayProperty(-1);
+ }
+ if (mSlicerManagers[index]->GetSlicer(0)->GetFusion())
+ {
+ overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
+ overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(),
+ mSlicerManagers[index]->GetFusionColorMap(),
+ mSlicerManagers[index]->GetFusionWindow(),
+ mSlicerManagers[index]->GetFusionLevel());
+ }
+ else
+ {
+ overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
+ overlayPanel->getFusionProperty(-1, -1,-1,-1);
+ }
+ }
}
//------------------------------------------------------------------------------
msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
if (msgBox.exec() == QMessageBox::AcceptRole)
{
+
+ // Tell tools that we close an image
+ emit AnImageIsBeingClosed(mSlicerManagers[index]);
+
std::vector<vvSlicerManager*>::iterator Manageriter = mSlicerManagers.begin();
DataTree->takeTopLevelItem(index);
for (int i = 0; i < index; i++)
mSlicerManagers[index]->RemoveActors();
delete mSlicerManagers[index];
mSlicerManagers.erase(Manageriter);
+
+ //
InitDisplay();
}
}
-
- // vvToolManager::GetInstance()->UpdateEnabledTool();
- // emit SlicerManagersHasChanged();
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::ReloadImage(QTreeWidgetItem* item, int column) {
// int index = GetSlicerIndexFromItem(item);
-// QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-// if (item->data(1,Qt::UserRole).toString() == "vector")
-// mSlicerManagers[index]->ReloadVF();
-// else
-// mSlicerManagers[index]->Reload();
+ // QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+ // if (item->data(1,Qt::UserRole).toString() == "vector")
+ // mSlicerManagers[index]->ReloadVF();
+ // else
+ // mSlicerManagers[index]->Reload();
-// QApplication::restoreOverrideCursor();
+ // QApplication::restoreOverrideCursor();
int index = GetSlicerIndexFromItem(item);
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
QString role=item->data(1,Qt::UserRole).toString();
if (DataTree->topLevelItem(i)->data(COLUMN_UL_VIEW,Qt::CheckStateRole).toInt() > 1)
{
mSlicerManagers[i]->GetSlicer(0)->SetSlice(value);
- // mSlicerManagers[i]->UpdateSlice(0); // <-- too much update...
+ //mSlicerManagers[i]->UpdateSlice(0); // <-- NO ! too much update...
break;
}
}
//------------------------------------------------------------------------------
void vvMainWindow::UpdateSlice(int slicer, int slice) {
- if (slicer == 0)
- NOVerticalSlider->setValue(slice);
+ if (slicer == 0) {
+ if (slice != NOVerticalSlider->value())
+ NOVerticalSlider->setValue(slice);
+ }
else if (slicer == 1)
NEVerticalSlider->setValue(slice);
else if (slicer == 2)
ShowLastImage();
InitDisplay();
qApp->processEvents();
-
- // vvToolManager::GetInstance()->UpdateEnabledTool();
- // emit SlicerManagersHasChanged();
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-vvMainWindowToolInfo * vvMainWindow::GetInfoForTool() {
- DD("GetInfoForTool");
- if (mCurrentToolInfo ==0) mCurrentToolInfo = new vvMainWindowToolInfo;
-
- mCurrentToolInfo->mMenuTools = menuTools;
- mCurrentToolInfo->mSlicerManagers = &mSlicerManagers;
+void vvMainWindow::UpdateCurrentSlicer() {
+ DD("UpdateCurrentSlicer");
int index = -1;
DD(DataTree->selectedItems().size());
if (DataTree->selectedItems().size() > 0) {
DD(DataTree->selectedItems()[0]);
DD(index);
}
- mCurrentToolInfo->mSlicerManagerCurrentIndex = index;
-
- return mCurrentToolInfo;
+ mSlicerManagerCurrentIndex = index;
}
//------------------------------------------------------------------------------
-
#include <vector>
#include "ui_vvMainWindow.h"
-
+#include "vvMainWindowBase.h"
+#include "vvToolManager.h"
#include "vvConstants.h"
-#include "vvImage.h"
#include "vvMesh.h"
-#include "vvToolManager.h"
-#include "clitkCommon.h"
class vvSlicerManager;
class vvHelpDialog;
class vvDicomSeriesSelector;
//------------------------------------------------------------------------------
-struct vvMainWindowToolInfo {
- QMenu * mMenuTools;
- std::vector<vvSlicerManager*> * mSlicerManagers;
- int mSlicerManagerCurrentIndex;
-};
-//------------------------------------------------------------------------------
-
-
-//------------------------------------------------------------------------------
-class vvMainWindow : public QMainWindow, private Ui::vvMainWindow
+class vvMainWindow: public vvMainWindowBase,
+ private Ui::vvMainWindow
{
Q_OBJECT
///This is used to show an image when opened or computed
void ShowLastImage();
- vvMainWindowToolInfo * GetInfoForTool();
+ virtual void UpdateCurrentSlicer();
+ //vvMainWindowToolInfo * GetInfoForTool();
+// void AddRunningTool(vvToolCreatorBase * tool);
public slots:
///Allows the user to open and select various surfaces contained in a dicom-struct file
private:
//variables
- std::vector<vvSlicerManager*> mSlicerManagers;
+ // std::vector<vvSlicerManager*> mSlicerManagers;
vvHelpDialog *help_dialog;
vvDocumentation *documentation;
vvDicomSeriesSelector *dicomSeriesSelector;
std::vector<QSlider*> verticalSliders;
int mFrameRate;
- vvMainWindowToolInfo * mCurrentToolInfo;
+ // vvMainWindowToolInfo * mCurrentToolInfo;
+ // std::vector<vvToolCreatorBase*> mListOfRunningTool;
static vvMainWindow * mSingleton;
};
--- /dev/null
+/*=========================================================================
+
+ Program: vv
+ Module: $RCSfile: vvMainWindowBase.cxx,v $
+ Language: C++
+ Date: $Date: 2010/02/24 11:43:37 $
+ Version: $Revision: 1.1 $
+ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+ Copyright (C) 2010
+ Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+ CREATIS-LRMN http://www.creatis.insa-lyon.fr
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 3 of the License.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ =========================================================================*/
+
+#include "vvMainWindowBase.h"
+
+
--- /dev/null
+/*=========================================================================
+
+ Program: vv
+ Module: $RCSfile: vvMainWindowBase.h,v $
+ Language: C++
+ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+Copyright (C) 2010
+Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+CREATIS-LRMN http://www.creatis.insa-lyon.fr
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 3 of the License.
+
+This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ =========================================================================*/
+
+#ifndef VVMAINWINDOWBASE_H
+#define VVMAINWINDOWBASE_H
+
+#include "clitkCommon.h"
+#include "vvImage.h"
+#include <qmainwindow.h>
+
+class vvSlicerManager;
+class QMenu;
+
+//------------------------------------------------------------------------------
+class vvMainWindowBase : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ vvMainWindowBase() { mSlicerManagerCurrentIndex = -1; }
+ ~vvMainWindowBase() { }
+
+ virtual void AddImage(vvImage::Pointer image,std::string filename) = 0;
+ virtual void UpdateCurrentSlicer() = 0;
+ const std::vector<vvSlicerManager*> & GetSlicerManagers() const { return mSlicerManagers; }
+ QMenu * GetMenu() const { return mMenuTools; }
+ int GetSlicerManagerCurrentIndex() const { return mSlicerManagerCurrentIndex; }
+ QWidget * GetMainWidget() { return mMainWidget; }
+
+signals:
+ void AnImageIsBeingClosed(vvSlicerManager *);
+
+protected:
+ std::vector<vvSlicerManager*> mSlicerManagers;
+ QMenu * mMenuTools;
+ int mSlicerManagerCurrentIndex;
+ QWidget* mMainWidget;
+};
+//------------------------------------------------------------------------------
+
+#endif
/*=========================================================================
-Program: vv
-Language: C++
-Author : Pierre Seroul (pierre.seroul@gmail.com)
+ Program: vv
+ Language: C++
+ Author : Pierre Seroul (pierre.seroul@gmail.com)
-Copyright (C) 2008
-Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
-CREATIS-LRMN http://www.creatis.insa-lyon.fr
+ Copyright (C) 2008
+ Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+ CREATIS-LRMN http://www.creatis.insa-lyon.fr
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, version 3 of the License.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 3 of the License.
-This program 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 General Public License for more details.
+ This program 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 General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
-=========================================================================*/
+ =========================================================================*/
#include "vvSlicerManagerCommand.h"
#include "vvSlicerManager.h"
#include <cmath>
+//------------------------------------------------------------------------------
vvSlicerManagerCallback::vvSlicerManagerCallback()
{
- mStartSlicer = -1;
+ mStartSlicer = -1;
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
//return the num of the current slicer if visible (-1 else)
int vvSlicerManagerCallback::FindSlicerNumber(vtkRenderWindow* renwin)
{
- int result=-1;
- for (int i = 0; i < SM->NumberOfSlicers(); i++)
+ int result=-1;
+ for (int i = 0; i < SM->NumberOfSlicers(); i++)
{
- if (SM->GetSlicer(i)->GetRenderWindow() == renwin
- && SM->GetSlicer(i)->GetRenderer()->GetDraw())
+ if (SM->GetSlicer(i)->GetRenderWindow() == renwin
+ && SM->GetSlicer(i)->GetRenderer()->GetDraw())
{
- DD(i);
- result=i;
+ // DD(i);
+ result=i;
}
}
- return result;
+ return result;
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicerManagerCallback::Execute(vtkObject *caller,
- unsigned long event,
- void *vtkNotUsed(callData))
+ unsigned long event,
+ void *vtkNotUsed(callData))
{
- //KeyPress event
- vvInteractorStyleNavigator *isi =
- dynamic_cast<vvInteractorStyleNavigator *>(caller);
- if (isi)
+ //KeyPress event
+ vvInteractorStyleNavigator *isi =
+ dynamic_cast<vvInteractorStyleNavigator *>(caller);
+ if (isi)
{
- double x = isi->GetInteractor()->GetEventPosition()[0];
- double y = isi->GetInteractor()->GetEventPosition()[1];
- double z;
+ double x = isi->GetInteractor()->GetEventPosition()[0];
+ double y = isi->GetInteractor()->GetEventPosition()[1];
+ double z;
- int VisibleInWindow = this->FindSlicerNumber(isi->GetInteractor()->GetRenderWindow());
- vtkRenderer* renderer=NULL;
- if (VisibleInWindow>-1)
- renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
- newLandmark = false;
+ int VisibleInWindow = this->FindSlicerNumber(isi->GetInteractor()->GetRenderWindow());
+ vtkRenderer* renderer=NULL;
+ if (VisibleInWindow>-1)
+ renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
+ newLandmark = false;
- if (event == vtkCommand::StartPickEvent && VisibleInWindow == -1)
+ if (event == vtkCommand::StartPickEvent && VisibleInWindow == -1)
{
- for (int i = 0; i < this->SM->NumberOfSlicers(); i++)
+ for (int i = 0; i < this->SM->NumberOfSlicers(); i++)
{
- if (this->SM->GetSlicer(i)->GetCursorVisibility())
+ if (this->SM->GetSlicer(i)->GetCursorVisibility())
{
- this->SM->GetSlicer(i)->SetCursorVisibility(0);
- this->SM->GetSlicer(i)->Render();
+ this->SM->GetSlicer(i)->SetCursorVisibility(0);
+ this->SM->GetSlicer(i)->Render();
}
}
}
- if ( VisibleInWindow > -1 )
+ if ( VisibleInWindow > -1 )
{
- if (event == vtkCommand::KeyPressEvent)
+ if (event == vtkCommand::KeyPressEvent)
{
- std::string KeyPress = isi->GetInteractor()->GetKeySym();
- if (KeyPress == "f" || KeyPress == "F")
+ std::string KeyPress = isi->GetInteractor()->GetKeySym();
+ if (KeyPress == "f" || KeyPress == "F")
{
- FlyToPosition(isi->GetInteractor(),this->SM->GetSlicer(VisibleInWindow));
+ FlyToPosition(isi->GetInteractor(),this->SM->GetSlicer(VisibleInWindow));
}
- if (KeyPress == "0")
+ if (KeyPress == "0")
{
- this->SM->SetPreset(0);
- this->SM->UpdateWindowLevel();
- return;
+ this->SM->SetPreset(0);
+ this->SM->UpdateWindowLevel();
+ return;
}
- if (KeyPress == "1")
+ if (KeyPress == "1")
{
- this->SM->SetPreset(1);
- this->SM->UpdateWindowLevel();
- return;
+ this->SM->SetPreset(1);
+ this->SM->UpdateWindowLevel();
+ return;
}
- if (KeyPress == "2")
+ if (KeyPress == "2")
{
- this->SM->SetPreset(2);
- this->SM->UpdateWindowLevel();
+ this->SM->SetPreset(2);
+ this->SM->UpdateWindowLevel();
- return;
+ return;
}
- if (KeyPress == "3")
+ if (KeyPress == "3")
{
- this->SM->SetPreset(3);
- this->SM->UpdateWindowLevel();
- return;
+ this->SM->SetPreset(3);
+ this->SM->UpdateWindowLevel();
+ return;
}
- if (KeyPress == "4")
+ if (KeyPress == "4")
{
- this->SM->SetPreset(4);
- this->SM->UpdateWindowLevel();
- return;
+ this->SM->SetPreset(4);
+ this->SM->UpdateWindowLevel();
+ return;
}
- if (KeyPress == "5")
+ if (KeyPress == "5")
{
- this->SM->SetPreset(5);
- this->SM->UpdateWindowLevel();
- return;
+ this->SM->SetPreset(5);
+ this->SM->UpdateWindowLevel();
+ return;
}
- if (KeyPress == "6")
+ if (KeyPress == "6")
{
- this->SM->SetColorMap(0);
- this->SM->UpdateWindowLevel();
- return;
+ this->SM->SetColorMap(0);
+ this->SM->UpdateWindowLevel();
+ return;
}
- if (KeyPress == "7")
+ if (KeyPress == "7")
{
- this->SM->SetColorMap(1);
- this->SM->UpdateWindowLevel();
- return;
+ this->SM->SetColorMap(1);
+ this->SM->UpdateWindowLevel();
+ return;
}
- if (KeyPress == "8")
+ if (KeyPress == "8")
{
- this->SM->SetColorMap(2);
- this->SM->UpdateWindowLevel();
- return;
+ this->SM->SetColorMap(2);
+ this->SM->UpdateWindowLevel();
+ return;
}
- if (KeyPress == "9")
+ if (KeyPress == "9")
{
- this->SM->SetColorMap(3);
- this->SM->UpdateWindowLevel();
- return;
+ this->SM->SetColorMap(3);
+ this->SM->UpdateWindowLevel();
+ return;
}
- if (KeyPress == "equal") //keycodes are in vtkWin32RenderWindowInteractor
+ if (KeyPress == "equal") //keycodes are in vtkWin32RenderWindowInteractor
{
- this->SM->SetPreset(7);
- //this->SM->SetColorMap(1);
- this->SM->UpdateWindowLevel();
- return;
+ this->SM->SetPreset(7);
+ //this->SM->SetColorMap(1);
+ this->SM->UpdateWindowLevel();
+ return;
}
- if (KeyPress == "minus")
+ if (KeyPress == "minus")
{
- std::cout << "KeyPress : - " << std::endl;
- this->SM->SetColorWindow(-this->SM->GetColorWindow());
- this->SM->SetColorMap(-1);
- this->SM->UpdateWindowLevel();
- return;
+ std::cout << "KeyPress : - " << std::endl;
+ this->SM->SetColorWindow(-this->SM->GetColorWindow());
+ this->SM->SetColorMap(-1);
+ this->SM->UpdateWindowLevel();
+ return;
}
- if (KeyPress == "u")
+ if (KeyPress == "u")
{
- this->SM->ToggleContourSuperposition();
- this->SM->Render();
- return;
+ this->SM->ToggleContourSuperposition();
+ this->SM->Render();
+ return;
}
- if (KeyPress == "i")
+ if (KeyPress == "i")
{
- this->SM->ToggleInterpolation();
- this->SM->Render();
- return;
+ this->SM->ToggleInterpolation();
+ this->SM->Render();
+ return;
}
- if (KeyPress == "h")
+ if (KeyPress == "h")
{
- this->SM->SetCursorVisibility(0);
- this->SM->Render();
- return;
+ this->SM->SetCursorVisibility(0);
+ this->SM->Render();
+ return;
}
- if (KeyPress == "l")
+ if (KeyPress == "l")
{
- this->SM->Reload();
- this->SM->Render();
- return;
+ this->SM->Reload();
+ this->SM->Render();
+ return;
}
- if (KeyPress == "r" || KeyPress=="R")
+ if (KeyPress == "r" || KeyPress=="R")
{
- this->SM->GetSlicer(VisibleInWindow)->ResetCamera();
- this->SM->GetSlicer(VisibleInWindow)->Render();
- return;
+ this->SM->GetSlicer(VisibleInWindow)->ResetCamera();
+ this->SM->GetSlicer(VisibleInWindow)->Render();
+ return;
}
- if (KeyPress == "g")
+ if (KeyPress == "g")
{
- double* cursorPos = this->SM->GetSlicer(VisibleInWindow)->GetCursorPosition();
- this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(
- cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
- this->SM->UpdateViews(1,VisibleInWindow);
- this->SM->UpdateLinked(VisibleInWindow);
- return;
+ double* cursorPos = this->SM->GetSlicer(VisibleInWindow)->GetCursorPosition();
+ this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(
+ cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
+ this->SM->UpdateViews(1,VisibleInWindow);
+ this->SM->UpdateLinked(VisibleInWindow);
+ return;
}
- if (KeyPress == "F5")
+ if (KeyPress == "F5")
{
- this->SM->GetSlicer(VisibleInWindow)->FlipHorizontalView();
- this->SM->GetSlicer(VisibleInWindow)->Render();
- return;
+ this->SM->GetSlicer(VisibleInWindow)->FlipHorizontalView();
+ this->SM->GetSlicer(VisibleInWindow)->Render();
+ return;
}
- if (KeyPress == "F6")
+ if (KeyPress == "F6")
{
- this->SM->GetSlicer(VisibleInWindow)->FlipVerticalView();
- this->SM->GetSlicer(VisibleInWindow)->Render();
- return;
+ this->SM->GetSlicer(VisibleInWindow)->FlipVerticalView();
+ this->SM->GetSlicer(VisibleInWindow)->Render();
+ return;
}
- if (KeyPress == "Up")
+ if (KeyPress == "Up")
{
- this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()+1);
- this->SM->UpdateSlice(VisibleInWindow);
- this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
+ this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()+1);
+ this->SM->UpdateSlice(VisibleInWindow);
+ this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
}
- if (KeyPress == "Down")
+ if (KeyPress == "Down")
{
- this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()-1);
- this->SM->UpdateSlice(VisibleInWindow);
- this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
+ this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()-1);
+ this->SM->UpdateSlice(VisibleInWindow);
+ this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
}
- if (KeyPress == "space")
+ if (KeyPress == "space")
{
- newLandmark = true;
+ newLandmark = true;
}
- if (KeyPress == "Left")
- this->SM->SetPreviousTSlice(VisibleInWindow);
- if (KeyPress == "Right")
- this->SM->SetNextTSlice(VisibleInWindow);
+ if (KeyPress == "Left")
+ this->SM->SetPreviousTSlice(VisibleInWindow);
+ if (KeyPress == "Right")
+ this->SM->SetNextTSlice(VisibleInWindow);
- if (KeyPress == "F1")
+ if (KeyPress == "F1")
{
- this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Sagital\n<slice>");
- this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(0);
- this->SM->UpdateSliceRange(VisibleInWindow);
- this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
+ this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Sagital\n<slice>");
+ this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(0);
+ this->SM->UpdateSliceRange(VisibleInWindow);
+ this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
}
- if (KeyPress == "F2")
+ if (KeyPress == "F2")
{
- this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Coronal\n<slice>");
- this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(1);
- this->SM->UpdateSliceRange(VisibleInWindow);
- this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
+ this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Coronal\n<slice>");
+ this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(1);
+ this->SM->UpdateSliceRange(VisibleInWindow);
+ this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
}
- if (KeyPress == "F3")
+ if (KeyPress == "F3")
{
- this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Axial\n<slice>");
- this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(2);
- this->SM->UpdateSliceRange(VisibleInWindow);
- this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
+ this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Axial\n<slice>");
+ this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(2);
+ this->SM->UpdateSliceRange(VisibleInWindow);
+ this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
}
}
- //All type of mouse events
- if (event == vtkCommand::LeaveEvent)
+ //All type of mouse events
+ if (event == vtkCommand::LeaveEvent)
{
- this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
- -VTK_DOUBLE_MAX,this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
- this->SM->GetSlicer(VisibleInWindow)->Render();
- return;
+ this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
+ -VTK_DOUBLE_MAX,this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
+ this->SM->GetSlicer(VisibleInWindow)->Render();
+ return;
}
- if (event == vtkCommand::StartWindowLevelEvent)
+ if (event == vtkCommand::StartWindowLevelEvent)
{
- mStartSlicer = -1;
- this->InitialWindow = this->SM->GetColorWindow();
- this->InitialLevel = this->SM->GetColorLevel();
+ mStartSlicer = -1;
+ this->InitialWindow = this->SM->GetColorWindow();
+ this->InitialLevel = this->SM->GetColorLevel();
- if (VisibleInWindow > -1)
+ if (VisibleInWindow > -1)
{
- mStartSlicer = VisibleInWindow;
+ mStartSlicer = VisibleInWindow;
}
- return;
+ return;
}
- if (event == vtkCommand::EndWindowLevelEvent)
+ if (event == vtkCommand::EndWindowLevelEvent)
{
- mStartSlicer = -1;
+ mStartSlicer = -1;
}
}
- if (VisibleInWindow > -1)
+ if (VisibleInWindow > -1)
{
- this->SM->Activated();
- //if(!this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->GetVisibility())
- this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetVisibility(1);
+ this->SM->Activated();
+ //if(!this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->GetVisibility())
+ this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetVisibility(1);
- if (event == vtkCommand::MouseWheelForwardEvent && !isi->GetInteractor()->GetControlKey())
+ if (event == vtkCommand::MouseWheelForwardEvent && !isi->GetInteractor()->GetControlKey())
{
- this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()+1);
- this->SM->UpdateSlice(VisibleInWindow);
- this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
+ this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()+1);
+ this->SM->UpdateSlice(VisibleInWindow);
+ this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
}
- else if (event == vtkCommand::MouseWheelForwardEvent && isi->GetInteractor()->GetControlKey())
+ else if (event == vtkCommand::MouseWheelForwardEvent && isi->GetInteractor()->GetControlKey())
{
- double factor = 2;
- this->Dolly(pow((double)1.1, factor),isi->GetInteractor());
+ double factor = 2;
+ this->Dolly(pow((double)1.1, factor),isi->GetInteractor());
}
- else if (event == vtkCommand::MouseWheelBackwardEvent && !isi->GetInteractor()->GetControlKey())
+ else if (event == vtkCommand::MouseWheelBackwardEvent && !isi->GetInteractor()->GetControlKey())
{
- this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()-1);
- this->SM->UpdateSlice(VisibleInWindow);
- this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
+ this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()-1);
+ this->SM->UpdateSlice(VisibleInWindow);
+ this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
}
- else if (event == vtkCommand::MouseWheelBackwardEvent && isi->GetInteractor()->GetControlKey())
+ else if (event == vtkCommand::MouseWheelBackwardEvent && isi->GetInteractor()->GetControlKey())
{
- double factor = -2;
- this->Dolly(pow((double)1.1, factor),isi->GetInteractor());
+ double factor = -2;
+ this->Dolly(pow((double)1.1, factor),isi->GetInteractor());
}
- double xWorld=0; double yWorld=0; double zWorld=0;
-
- //Move into World Coordinate
- renderer->DisplayToNormalizedDisplay(x,y);
- renderer->NormalizedDisplayToViewport(x,y);
- renderer->ViewportToNormalizedViewport(x,y);
- renderer->NormalizedViewportToView(x,y,z);
- renderer->ViewToWorld(x,y,z);
- switch (this->SM->GetSlicer(VisibleInWindow)->GetSliceOrientation())
+ double xWorld=0; double yWorld=0; double zWorld=0;
+
+ //Move into World Coordinate
+ renderer->DisplayToNormalizedDisplay(x,y);
+ renderer->NormalizedDisplayToViewport(x,y);
+ renderer->ViewportToNormalizedViewport(x,y);
+ renderer->NormalizedViewportToView(x,y,z);
+ renderer->ViewToWorld(x,y,z);
+ switch (this->SM->GetSlicer(VisibleInWindow)->GetSliceOrientation())
{
case vtkImageViewer2::SLICE_ORIENTATION_XY:
- xWorld = x;
- yWorld = y;
- zWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
- this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[2] +
- this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[2];
- break;
+ xWorld = x;
+ yWorld = y;
+ zWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
+ this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[2] +
+ this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[2];
+ break;
case vtkImageViewer2::SLICE_ORIENTATION_XZ:
- xWorld = x;
- yWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
- this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[1] +
- this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[1];
- zWorld = z;
- break;
+ xWorld = x;
+ yWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
+ this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[1] +
+ this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[1];
+ zWorld = z;
+ break;
case vtkImageViewer2::SLICE_ORIENTATION_YZ:
- xWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
- this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[0] +
- this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[0];
- yWorld = y;
- zWorld = z;
- break;
+ xWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
+ this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[0] +
+ this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[0];
+ yWorld = y;
+ zWorld = z;
+ break;
}
- this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(xWorld,yWorld,zWorld,
- this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
- if (newLandmark)
+ this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(xWorld,yWorld,zWorld,
+ this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
+ if (newLandmark)
{
- this->SM->AddLandmark(xWorld,yWorld,zWorld,
- this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
- this->SM->GetSlicer(VisibleInWindow)->UpdateLandmarks();
- this->SM->Render();
+ this->SM->AddLandmark(xWorld,yWorld,zWorld,
+ this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
+ this->SM->GetSlicer(VisibleInWindow)->UpdateLandmarks();
+ this->SM->Render();
}
- if (event == vtkCommand::PickEvent || event == vtkCommand::StartPickEvent)
+ if (event == vtkCommand::PickEvent || event == vtkCommand::StartPickEvent)
{
- this->SM->UpdateViews(1,VisibleInWindow);
- this->SM->UpdateLinked(VisibleInWindow);
- this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
+ this->SM->UpdateViews(1,VisibleInWindow);
+ this->SM->UpdateLinked(VisibleInWindow);
+ this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
}
- else
+ else
{
- this->SM->GetSlicer(VisibleInWindow)->Render();
+ this->SM->GetSlicer(VisibleInWindow)->Render();
}
- //this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
- //-VTK_DOUBLE_MAX,this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
- //this->SM->GetSlicer(VisibleInWindow)->Render();
+ //this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
+ //-VTK_DOUBLE_MAX,this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
+ //this->SM->GetSlicer(VisibleInWindow)->Render();
}
- if (event == vtkCommand::WindowLevelEvent && mStartSlicer > -1)
+ if (event == vtkCommand::WindowLevelEvent && mStartSlicer > -1)
{
- this->SM->GetSlicer(mStartSlicer)->GetAnnotation()->SetVisibility(1);
- // Adjust the window level here
- int *size = isi->GetInteractor()->GetRenderWindow()->GetSize();
- double window = this->InitialWindow;
- double level = this->InitialLevel;
- double range[2];
- this->SM->GetImage()->GetScalarRange(range);
-
- // Compute normalized delta
- double dx = static_cast<double>(isi->GetWindowLevelCurrentPosition()[0] -
- isi->GetWindowLevelStartPosition()[0]) / size[0];
- double dy = static_cast<double>(isi->GetWindowLevelStartPosition()[1] -
- isi->GetWindowLevelCurrentPosition()[1]) / size[1];
- //Window is exponential in nature, use exponential to avoid falling into negative numbers
- dx = std::exp(1.0 * (dx*fabs(dx) + dx)) ; //Quadratic behavior for more reactive interface
- dy = 0.15 * (dy*fabs(dy) + dy) * (range[1]-range[0]);//Quadratic behavior for more reactive interface
-
- this->SM->SetColorWindow(window*dx);
- this->SM->SetColorLevel(level-dy);
- this->SM->SetPreset(6);
- this->SM->UpdateWindowLevel();
- this->SM->Render();
- return;
+ this->SM->GetSlicer(mStartSlicer)->GetAnnotation()->SetVisibility(1);
+ // Adjust the window level here
+ int *size = isi->GetInteractor()->GetRenderWindow()->GetSize();
+ double window = this->InitialWindow;
+ double level = this->InitialLevel;
+ double range[2];
+ this->SM->GetImage()->GetScalarRange(range);
+
+ // Compute normalized delta
+ double dx = static_cast<double>(isi->GetWindowLevelCurrentPosition()[0] -
+ isi->GetWindowLevelStartPosition()[0]) / size[0];
+ double dy = static_cast<double>(isi->GetWindowLevelStartPosition()[1] -
+ isi->GetWindowLevelCurrentPosition()[1]) / size[1];
+ //Window is exponential in nature, use exponential to avoid falling into negative numbers
+ dx = std::exp(1.0 * (dx*fabs(dx) + dx)) ; //Quadratic behavior for more reactive interface
+ dy = 0.15 * (dy*fabs(dy) + dy) * (range[1]-range[0]);//Quadratic behavior for more reactive interface
+
+ this->SM->SetColorWindow(window*dx);
+ this->SM->SetColorLevel(level-dy);
+ this->SM->SetPreset(6);
+ this->SM->UpdateWindowLevel();
+ this->SM->Render();
+ return;
}
}
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicerManagerCallback::Dolly(double factor, vtkRenderWindowInteractor *interactor)
{
- int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
- vtkRenderer* renderer;
- if (VisibleInWindow>-1)
- renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
- else
+ int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
+ vtkRenderer* renderer;
+ if (VisibleInWindow>-1)
+ renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
+ else
{
- return;
+ return;
}
- double viewFocus[4],viewPoint[4],motionVector[3], focalDepth;
- double oldPos[3], newPos[3], distance[2];
- vtkCamera *camera = renderer->GetActiveCamera();
- camera->GetFocalPoint(viewFocus);
-
- renderer->SetWorldPoint(viewFocus[0], viewFocus[0], viewFocus[0], 1.0);
- renderer->WorldToDisplay();
- renderer->GetDisplayPoint(viewFocus);
-
- focalDepth = viewFocus[2];
-
- oldPos[0] = renderer->GetCenter()[0];
- oldPos[1] = renderer->GetCenter()[1];
- oldPos[2] = focalDepth;
-
- distance[0] = 1/factor*
- (interactor->GetEventPosition()[0]-renderer->GetCenter()[0]);
- distance[1] = 1/factor*
- (interactor->GetEventPosition()[1]-renderer->GetCenter()[1]);
-
- newPos[0] = interactor->GetEventPosition()[0] - distance[0];
- newPos[1] = interactor->GetEventPosition()[1] - distance[1];
- newPos[2] = focalDepth;
-
- renderer->DisplayToNormalizedDisplay(oldPos[0],oldPos[1]);
- renderer->NormalizedDisplayToViewport(oldPos[0],oldPos[1]);
- renderer->ViewportToNormalizedViewport(oldPos[0],oldPos[1]);
- renderer->NormalizedViewportToView(oldPos[0],oldPos[1],oldPos[2]);
- renderer->ViewToWorld(oldPos[0],oldPos[1],oldPos[2]);
-
- renderer->DisplayToNormalizedDisplay(newPos[0],newPos[1]);
- renderer->NormalizedDisplayToViewport(newPos[0],newPos[1]);
- renderer->ViewportToNormalizedViewport(newPos[0],newPos[1]);
- renderer->NormalizedViewportToView(newPos[0],newPos[1],newPos[2]);
- renderer->ViewToWorld(newPos[0],newPos[1],newPos[2]);
-
- motionVector[0] = newPos[0] - oldPos[0];
- motionVector[1] = newPos[1] - oldPos[1];
- motionVector[2] = newPos[2] - oldPos[2];
-
- camera->GetFocalPoint(viewFocus);
- camera->GetPosition(viewPoint);
- camera->SetFocalPoint(motionVector[0] + viewFocus[0],
- motionVector[1] + viewFocus[1],
- motionVector[2] + viewFocus[2]);
-
- camera->SetPosition(motionVector[0] + viewPoint[0],
- motionVector[1] + viewPoint[1],
- motionVector[2] + viewPoint[2]);
-
- if (camera->GetParallelProjection())
+ double viewFocus[4],viewPoint[4],motionVector[3], focalDepth;
+ double oldPos[3], newPos[3], distance[2];
+ vtkCamera *camera = renderer->GetActiveCamera();
+ camera->GetFocalPoint(viewFocus);
+
+ renderer->SetWorldPoint(viewFocus[0], viewFocus[0], viewFocus[0], 1.0);
+ renderer->WorldToDisplay();
+ renderer->GetDisplayPoint(viewFocus);
+
+ focalDepth = viewFocus[2];
+
+ oldPos[0] = renderer->GetCenter()[0];
+ oldPos[1] = renderer->GetCenter()[1];
+ oldPos[2] = focalDepth;
+
+ distance[0] = 1/factor*
+ (interactor->GetEventPosition()[0]-renderer->GetCenter()[0]);
+ distance[1] = 1/factor*
+ (interactor->GetEventPosition()[1]-renderer->GetCenter()[1]);
+
+ newPos[0] = interactor->GetEventPosition()[0] - distance[0];
+ newPos[1] = interactor->GetEventPosition()[1] - distance[1];
+ newPos[2] = focalDepth;
+
+ renderer->DisplayToNormalizedDisplay(oldPos[0],oldPos[1]);
+ renderer->NormalizedDisplayToViewport(oldPos[0],oldPos[1]);
+ renderer->ViewportToNormalizedViewport(oldPos[0],oldPos[1]);
+ renderer->NormalizedViewportToView(oldPos[0],oldPos[1],oldPos[2]);
+ renderer->ViewToWorld(oldPos[0],oldPos[1],oldPos[2]);
+
+ renderer->DisplayToNormalizedDisplay(newPos[0],newPos[1]);
+ renderer->NormalizedDisplayToViewport(newPos[0],newPos[1]);
+ renderer->ViewportToNormalizedViewport(newPos[0],newPos[1]);
+ renderer->NormalizedViewportToView(newPos[0],newPos[1],newPos[2]);
+ renderer->ViewToWorld(newPos[0],newPos[1],newPos[2]);
+
+ motionVector[0] = newPos[0] - oldPos[0];
+ motionVector[1] = newPos[1] - oldPos[1];
+ motionVector[2] = newPos[2] - oldPos[2];
+
+ camera->GetFocalPoint(viewFocus);
+ camera->GetPosition(viewPoint);
+ camera->SetFocalPoint(motionVector[0] + viewFocus[0],
+ motionVector[1] + viewFocus[1],
+ motionVector[2] + viewFocus[2]);
+
+ camera->SetPosition(motionVector[0] + viewPoint[0],
+ motionVector[1] + viewPoint[1],
+ motionVector[2] + viewPoint[2]);
+
+ if (camera->GetParallelProjection())
{
- camera->SetParallelScale(camera->GetParallelScale() / factor);
+ camera->SetParallelScale(camera->GetParallelScale() / factor);
}
- else
+ else
{
- camera->Dolly(factor);
+ camera->Dolly(factor);
}
- if (interactor->GetLightFollowCamera())
+ if (interactor->GetLightFollowCamera())
{
- renderer->UpdateLightsGeometryToFollowCamera();
+ renderer->UpdateLightsGeometryToFollowCamera();
}
- renderer->ResetCameraClippingRange();
- //interactor->Render();
+ renderer->ResetCameraClippingRange();
+ //interactor->Render();
}
void vvSlicerManagerCallback::FlyToPosition(vtkRenderWindowInteractor *interactor,vvSlicer* slicer)
{
- double flyFrom[3], flyTo[3];
- double d[3], focalPt[3], position[3], positionFrom[3];
- int i, j;
- int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
- vtkRenderer* renderer=NULL;
- if (VisibleInWindow>-1)
- renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
- else
- return;
-
- interactor->GetPicker()->Pick(interactor->GetEventPosition()[0],
- interactor->GetEventPosition()[1], 0.0,
- renderer);
-
- vtkAssemblyPath *path=NULL;
- vtkAbstractPropPicker *picker;
- if ( (picker=vtkAbstractPropPicker::SafeDownCast(interactor->GetPicker())))
+ double flyFrom[3], flyTo[3];
+ double d[3], focalPt[3], position[3], positionFrom[3];
+ int i, j;
+ int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
+ vtkRenderer* renderer=NULL;
+ if (VisibleInWindow>-1)
+ renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
+ else
+ return;
+
+ interactor->GetPicker()->Pick(interactor->GetEventPosition()[0],
+ interactor->GetEventPosition()[1], 0.0,
+ renderer);
+
+ vtkAssemblyPath *path=NULL;
+ vtkAbstractPropPicker *picker;
+ if ( (picker=vtkAbstractPropPicker::SafeDownCast(interactor->GetPicker())))
{
- path = picker->GetPath();
+ path = picker->GetPath();
}
- if ( path != NULL )
+ if ( path != NULL )
{
- flyTo[0] = picker->GetPickPosition()[0];
- flyTo[1] = picker->GetPickPosition()[1];
- flyTo[2] = picker->GetPickPosition()[2];
- renderer->GetActiveCamera()->GetFocalPoint(flyFrom);
- renderer->GetActiveCamera()->GetPosition(positionFrom);
+ flyTo[0] = picker->GetPickPosition()[0];
+ flyTo[1] = picker->GetPickPosition()[1];
+ flyTo[2] = picker->GetPickPosition()[2];
+ renderer->GetActiveCamera()->GetFocalPoint(flyFrom);
+ renderer->GetActiveCamera()->GetPosition(positionFrom);
- switch (slicer->GetSliceOrientation())
+ switch (slicer->GetSliceOrientation())
{
case vtkImageViewer2::SLICE_ORIENTATION_XY:
- flyTo[2] = flyFrom[2];
- break;
+ flyTo[2] = flyFrom[2];
+ break;
case vtkImageViewer2::SLICE_ORIENTATION_XZ:
- flyTo[1] = flyFrom[1];
- break;
+ flyTo[1] = flyFrom[1];
+ break;
case vtkImageViewer2::SLICE_ORIENTATION_YZ:
- flyTo[0] = flyFrom[0];
- break;
+ flyTo[0] = flyFrom[0];
+ break;
}
- for (i=0; i<3; i++)
+ for (i=0; i<3; i++)
{
- d[i] = flyTo[i] - flyFrom[i];
+ d[i] = flyTo[i] - flyFrom[i];
}
- double distance = vtkMath::Normalize(d);
- double delta = distance/15;
+ double distance = vtkMath::Normalize(d);
+ double delta = distance/15;
- for (i=1; i<=15; i++)
+ for (i=1; i<=15; i++)
{
- for (j=0; j<3; j++)
+ for (j=0; j<3; j++)
{
- focalPt[j] = flyFrom[j] + d[j]*i*delta;
- position[j] = positionFrom[j] + d[j]*i*delta;
+ focalPt[j] = flyFrom[j] + d[j]*i*delta;
+ position[j] = positionFrom[j] + d[j]*i*delta;
}
- renderer->GetActiveCamera()->SetFocalPoint(focalPt);
- renderer->GetActiveCamera()->SetPosition(position);
- renderer->GetActiveCamera()->Dolly(0.3/15 + 1.0);
- renderer->ResetCameraClippingRange();
- interactor->Render();
+ renderer->GetActiveCamera()->SetFocalPoint(focalPt);
+ renderer->GetActiveCamera()->SetPosition(position);
+ renderer->GetActiveCamera()->Dolly(0.3/15 + 1.0);
+ renderer->ResetCameraClippingRange();
+ interactor->Render();
}
}
}
Program: vv
Module: $RCSfile: vvToolBase.h,v $
Language: C++
- Date: $Date: 2010/02/09 14:19:32 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2010/02/24 11:42:42 $
+ Version: $Revision: 1.3 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2008
#ifndef VVTOOLBASE_H
#define VVTOOLBASE_H
-#include "vvToolCreatorBase.h"
-#include "vvToolInputSelectorWidget.h"
-#include "clitkImageToImageGenericFilter.h"
+#include "vvToolBaseBase.h"
+#include "vvToolCreator.h"
//------------------------------------------------------------------------------
template<class ToolType>
-class vvToolBase {
+class vvToolBase : public vvToolBaseBase {
public:
+ vvToolBase(vvMainWindowBase * m);
static void Initialize(); // can't be virtual, must be overwritten
- void UpdateInfoFromMainWindow();
- vvMainWindowToolInfo * mMainWindowToolInfo;
static void SetToolName(QString n) { vvToolCreator<ToolType>::mSingleton->mToolName = n; }
static void SetToolMenuName(QString n) { vvToolCreator<ToolType>::mSingleton->mToolMenuName = n; }
static void SetToolIconFilename(QString n) { vvToolCreator<ToolType>::mSingleton->mToolIconFilename = n; }
static void SetToolTip(QString n) { vvToolCreator<ToolType>::mSingleton->mToolTip = n; }
- void InitializeListOfInputImages();
- void InitializeListOfInputImages(vvToolInputSelectorWidget * w,
- clitk::ImageToImageGenericFilterBase * f);
- std::vector<vvSlicerManager*> mSlicerManagersCompatible;
- unsigned int mCurrentIndex;
-
- vvImage::Pointer mCurrentImage;
- vvSlicerManager * mCurrentSliceManager;
- clitk::ImageToImageGenericFilterBase * mFilter;
-
};
//------------------------------------------------------------------------------
-
-//------------------------------------------------------------------------------
-template<class ToolType>
-void vvToolBase<ToolType>::UpdateInfoFromMainWindow() {
- mMainWindowToolInfo = vvToolCreator<ToolType>::mSingleton->mMainWindow->GetInfoForTool();
-}
-//------------------------------------------------------------------------------
-
-
-//------------------------------------------------------------------------------
-template<class ToolType>
-void vvToolBase<ToolType>::Initialize() {
- SetToolName("Unnamed tool");
- SetToolMenuName("Unnamed tool");
- SetToolIconFilename("");
- SetToolTip("Unamed tool.");
-}
-//------------------------------------------------------------------------------
-
-
-//------------------------------------------------------------------------------
-template<class ToolType>
-void vvToolBase<ToolType>::InitializeListOfInputImages(vvToolInputSelectorWidget * w,
- clitk::ImageToImageGenericFilterBase * f) {
- mFilter = f;
- InitializeListOfInputImages();
- w->Initialize(mSlicerManagersCompatible, mCurrentIndex);
- w->SetToolTip(mFilter->GetAvailableImageTypes().c_str());
-}
-//------------------------------------------------------------------------------
-
-//------------------------------------------------------------------------------
-template<class ToolType>
-void vvToolBase<ToolType>::InitializeListOfInputImages() {
- UpdateInfoFromMainWindow();
-
- std::vector<vvSlicerManager*> & mSlicerManagers = *mMainWindowToolInfo->mSlicerManagers;
- mCurrentIndex = mMainWindowToolInfo->mSlicerManagerCurrentIndex;
- DD("InputUpdate");
- DD(mCurrentIndex);
- // HERE : Check if image is ok (dimension, type etc ...)
-
- if (mFilter) {
- mFilter->PrintAvailableImageTypes();
-
- }
- else {
- /// if not set, do not check filter type
- std::cerr << "*** ERROR, set mFilter member in the vvTool class before calling InitializeListOfInputImages" << std::endl;
- exit(0);
- }
-
- //unsigned int previousIndex = mInputSequenceBox->mCurrentIndex();
- mSlicerManagersCompatible.clear();
- // mInputSequenceBox->clear();
- for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
-
- vvImage * image = mSlicerManagers[i]->GetImage();
-
- if (mFilter->CheckImageType(image->GetNumberOfDimensions(),
- image->GetNumberOfScalarComponents(),
- image->GetScalarTypeAsString())) {
- mSlicerManagersCompatible.push_back(mSlicerManagers[i]);
- if (mCurrentIndex == i) {
- mCurrentIndex = mSlicerManagersCompatible.size()-1;
- }
- }
- else {
- std::cerr << mSlicerManagers[i]->GetFileName().c_str() << " not compatible image" << std::endl;
- if (mCurrentIndex == i) {
- mCurrentIndex = 0;
- }
- }
- }
-}
-//------------------------------------------------------------------------------
-
+#include "vvToolBase.txx"
#endif
--- /dev/null
+/*=========================================================================
+
+ Program: vv
+ Module: $RCSfile: vvToolBase.txx,v $
+ Language: C++
+ Date: $Date: 2010/02/24 11:43:37 $
+ Version: $Revision: 1.1 $
+ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+ Copyright (C) 2008
+ Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+ CREATIS http://www.creatis.insa-lyon.fr
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 3 of the License.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ =========================================================================*/
+
+//------------------------------------------------------------------------------
+template<class ToolType>
+vvToolBase<ToolType>::vvToolBase(vvMainWindowBase * m) {
+ mMainWindowBase = m;
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// Default value (to be overwritten)
+template<class ToolType>
+void vvToolBase<ToolType>::Initialize() {
+ SetToolName("Unnamed tool (use SetToolName in Initialize())");
+ SetToolMenuName("Unnamed tool");
+ SetToolIconFilename("");
+ SetToolTip("Unamed tool.");
+}
+//------------------------------------------------------------------------------
+
Program: vv
Module: $RCSfile: vvToolBinarize.cxx,v $
Language: C++
- Date: $Date: 2010/02/07 12:00:59 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2010/02/24 11:42:42 $
+ Version: $Revision: 1.8 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2008
//------------------------------------------------------------------------------
-vvToolBinarize::vvToolBinarize(QWidget * parent, Qt::WindowFlags f)
- :QDialog(parent,f), vvToolBase<vvToolBinarize>(), Ui::vvToolBinarize()
-{
- // Set Modality : dialog is not modal but stay always on top because
- // parent is set at construction
- setModal(false);
- setAttribute(Qt::WA_DeleteOnClose);
+void vvToolBinarize::Initialize() {
+ SetToolName("Binarize");
+ SetToolMenuName("Binarize");
+ SetToolIconFilename(":/new/prefix1/icons/binarize.png");
+ SetToolTip("Image interactive binarization with thresholds.");
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+vvToolBinarize::vvToolBinarize(vvMainWindowBase * parent, Qt::WindowFlags f)
+ :vvToolWidgetBase(parent,f),
+ vvToolBase<vvToolBinarize>(parent),
+ Ui::vvToolBinarize()
+{
// GUI Initialization
- setupUi(this);
+ Ui_vvToolBinarize::setupUi(mToolWidget);
// Connect signals & slots
- connect(mToolInputSelectionWidget, SIGNAL(accepted()), this, SLOT(InputIsSelected()));
- connect(mToolInputSelectionWidget, SIGNAL(rejected()), this, SLOT(close()));
- connect(buttonBox, SIGNAL(accepted()), this, SLOT(apply()));
- connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
connect(mThresholdSlider1, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT1(double)));
connect(mThresholdSlider2, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT2(double)));
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)));
- // VTK objects
- //mImageContour = new vvImageContour;
-
- //new vector of contours
-
// Initialize some widget
mThresholdSlider1->SetText("");
mThresholdSlider2->SetText("");
mFGSlider->SetText("Foreground value");
mBGSlider->SetText("Background value");
- // Disable main widget while input image is not selected
- toolMainWidget->setEnabled(false);
-
// Main filter
mFilter = new clitk::BinarizeImageGenericFilter<args_info_clitkBinarizeImage>; //DS PUT IN BASECLASS ?
-
- // Initialize the input selection (mFilter should be create before !)
- InitializeListOfInputImages(mToolInputSelectionWidget, mFilter);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
vvToolBinarize::~vvToolBinarize() {
- //delete mImageContour;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvToolBinarize::InputIsSelected() {
-
+void vvToolBinarize::InputIsSelected(vvSlicerManager * m) {
+ mCurrentSlicerManager = m;
// Common
- int index = mToolInputSelectionWidget->GetSelectedInputIndex();
- mCurrentSliceManager = mSlicerManagersCompatible[index];
- mCurrentImage = mCurrentSliceManager->GetImage();
- toolMainWidget->setEnabled(true);
+ mCurrentImage = mCurrentSlicerManager->GetImage();
// Specific for this gui
mThresholdSlider1->SetValue(0);
mThresholdSlider2->SetImage(mCurrentImage);
mFGSlider->SetImage(mCurrentImage);
mBGSlider->SetImage(mCurrentImage);
- DD(mCurrentSliceManager->GetFileName().c_str());
+ // DD(mCurrentSlicerManager->GetFileName().c_str());
mFGSlider->SetMaximum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMax());
mFGSlider->SetMinimum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMin());
mBGSlider->SetMaximum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMax());
mBGSlider->SetValue(0);
// VTK objects for interactive display
- for(int i=0;i<mCurrentSliceManager->NumberOfSlicers(); i++) {
+ for(int i=0;i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
mImageContour.push_back(new vvImageContour);
- mImageContour[i]->setSlicer(mCurrentSliceManager->GetSlicer(i));
+ mImageContour[i]->setSlicer(mCurrentSlicerManager->GetSlicer(i));
}
valueChangedT1(mThresholdSlider1->GetValue());
- connect(mCurrentSliceManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
- connect(mCurrentSliceManager,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)));
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvToolBinarize::UpdateSlice(int slicer,int slices) {
- DD(slicer);
- for(int i=0;i<mCurrentSliceManager->NumberOfSlicers(); i++) {
+ if (!mCurrentSlicerManager) close();
+ for(int i=0;i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
mImageContour[i]->update(mThresholdSlider1->GetValue());
}
- mCurrentSliceManager->Render();
+ mCurrentSlicerManager->Render();
}
//------------------------------------------------------------------------------
mArgsInfo.lower_given = 1;
mArgsInfo.lower_arg = mThresholdSlider1->GetValue();
- DD(mArgsInfo.lower_arg);
+ // DD(mArgsInfo.lower_arg);
if (mRadioButtonLowerThan->isChecked()) {
mArgsInfo.upper_given = 1;
mArgsInfo.upper_arg = mThresholdSlider2->GetValue();
mArgsInfo.fg_arg = mFGSlider->GetValue();
mArgsInfo.bg_arg = mBGSlider->GetValue();
- DD(inverseBGandFG);
+ // DD(inverseBGandFG);
if (inverseBGandFG) {
mArgsInfo.fg_arg = mFGSlider->GetValue();
mArgsInfo.bg_arg = mBGSlider->GetValue();
//------------------------------------------------------------------------------
void vvToolBinarize::apply() {
+ if (!mCurrentSlicerManager) close();
GetArgsInfoFromGUI();
// Main filter
// Output ???
vvImage::Pointer output = filter->GetOutputVVImage();
std::ostringstream osstream;
- osstream << "Binarized_" << mCurrentSliceManager->GetSlicer(0)->GetFileName();
- CREATOR(vvToolBinarize)->mMainWindow->AddImage(output,osstream.str());
+ osstream << "Binarized_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName();
+ CREATOR(vvToolBinarize)->GetMainWindow()->AddImage(output,osstream.str());
close();
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvToolBinarize::valueChangedT1(double v) {
+ // DD(v);
+ if (!mCurrentSlicerManager) close();
+// DD(mCurrentSlicerManager->GetSlicer(0));
mThresholdSlider2->SetMinimum(v);
int m1 = (int)lrint(v);
- for(int i=0;i<mCurrentSliceManager->NumberOfSlicers(); i++) {
+ for(int i=0;i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
mImageContour[i]->update(m1);
}
- mCurrentSliceManager->Render();
+ mCurrentSlicerManager->Render();
}
//------------------------------------------------------------------------------
Program: vv
Module: $RCSfile: vvToolBinarize.h,v $
Language: C++
- Date: $Date: 2010/02/07 12:00:59 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2010/02/24 11:42:42 $
+ Version: $Revision: 1.6 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2010
#define VVTOOLBINARIZE_H
#include <QtDesigner/QDesignerExportWidget>
-#include <QDialog>
+//#include <QDialog>
#include "vvToolBase.h"
+#include "vvToolWidgetBase.h"
#include "vvImageContour.h"
#include "ui_vvToolBinarize.h"
#include "clitkBinarizeImage_ggo.h"
//------------------------------------------------------------------------------
class vvToolBinarize:
- public QDialog, public vvToolBase<vvToolBinarize>, private Ui::vvToolBinarize
+ public vvToolWidgetBase,
+ public vvToolBase<vvToolBinarize>,
+ private Ui::vvToolBinarize
{
Q_OBJECT
public:
- vvToolBinarize(QWidget * parent=0, Qt::WindowFlags f=0);
+ vvToolBinarize(vvMainWindowBase * parent=0, Qt::WindowFlags f=0);
~vvToolBinarize();
//-----------------------------------------------------
- typedef vvToolBinarize Self;
-
- //-----------------------------------------------------
- static void Initialize() {
- SetToolName("Binarize");
- SetToolMenuName("Binarize");
- SetToolIconFilename(":/new/prefix1/icons/binarize.png");
- SetToolTip("Image interactive binarization with thresholds.");
- }
-
+ static void Initialize();
void InputIsSet(bool b);
void GetArgsInfoFromGUI();
void valueChangedT1(double v);
void valueChangedT2(double v);
void UpdateSlice(int slicer,int slices);
- void InputIsSelected();
+ void InputIsSelected(vvSlicerManager * m);
void enableLowerThan(bool b);
void useFGBGtoggled(bool);
+ virtual bool close() { DD("vvToolBinarize::close");
+ for(unsigned int i=0; i<mImageContour.size(); i++)
+ mImageContour[i]->removeActors();
+ if (mCurrentSlicerManager)
+ mCurrentSlicerManager->Render();
+ return vvToolWidgetBase::close(); }
+
+ virtual void reject() { DD("vvToolBinarize::reject");
+ for(unsigned int i=0; i<mImageContour.size(); i++)
+ mImageContour[i]->removeActors();
+ if (mCurrentSlicerManager)
+ mCurrentSlicerManager->Render();
+ return vvToolWidgetBase::reject(); }
+
protected:
Ui::vvToolBinarize ui;
--- /dev/null
+/*=========================================================================
+
+ Program: vv
+ Module: $RCSfile: vvToolCreator.h,v $
+ Language: C++
+ Date: $Date: 2010/02/24 11:43:37 $
+ Version: $Revision: 1.1 $
+ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+ Copyright (C) 2008
+ Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+ CREATIS-LRMN http://www.creatis.insa-lyon.fr
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 3 of the License.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ =========================================================================*/
+
+#ifndef VVTOOLCREATOR_H
+#define VVTOOLCREATOR_H
+
+#include "vvToolCreatorBase.h"
+
+//------------------------------------------------------------------------------
+template<class ToolType>
+class vvToolCreator: public vvToolCreatorBase {
+public:
+ vvToolCreator(QString name):vvToolCreatorBase(name) {;}
+ virtual void InsertToolInMenu(vvMainWindowBase * m);
+ virtual void MenuSpecificToolSlot() { CreateTool<ToolType>(); }
+ static vvToolCreator<ToolType> * mSingleton;
+};
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+#define CREATOR(CLASSNAME) vvToolCreator<CLASSNAME>::mSingleton
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+#define ADD_TOOL(NAME) \
+ template<> \
+ vvToolCreator<NAME> * vvToolCreator<NAME>::mSingleton = \
+ new vvToolCreator<NAME>(#NAME);
+//------------------------------------------------------------------------------
+
+#include "vvToolCreator.txx"
+
+#endif
+
--- /dev/null
+/*=========================================================================
+
+ Program: vv
+ Module: $RCSfile: vvToolCreator.txx,v $
+ Language: C++
+ Date: $Date: 2010/02/24 11:43:37 $
+ Version: $Revision: 1.1 $
+ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+ Copyright (C) 2008
+ Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+ CREATIS-LRMN http://www.creatis.insa-lyon.fr
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 3 of the License.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ =========================================================================*/
+
+//------------------------------------------------------------------------------
+// Call when the ToolType is inserted into the menu
+template<class ToolType>
+void vvToolCreator<ToolType>::InsertToolInMenu(vvMainWindowBase * m) {
+ mMainWindow = m;
+
+ // Default Initialization
+ mToolMenuName = mToolName;
+ mToolIconFilename = "noicon";
+ mToolTip = mToolName;
+
+ // User Tool Initialization
+ ToolType::Initialize();
+
+ // Common Initialization (insertion into menu)
+ vvToolCreatorBase::InsertToolInMenu(mMainWindow);
+}
+//------------------------------------------------------------------------------
Program: vv
Module: $RCSfile: vvToolCreatorBase.cxx,v $
Language: C++
- Date: $Date: 2010/01/29 13:54:37 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2010/02/24 11:42:42 $
+ Version: $Revision: 1.2 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2008
=========================================================================*/
#include "vvToolCreatorBase.h"
-#include "vvSlicerManager.h"
#include "vvToolManager.h"
#include <QAction>
+#include <QMenu>
//------------------------------------------------------------------------------
vvToolCreatorBase::vvToolCreatorBase(QString name) {
//------------------------------------------------------------------------------
-void vvToolCreatorBase::Initialize(vvMainWindow * m) {
- mMainWindow = m;
-
- // Create main Action
+void vvToolCreatorBase::InsertToolInMenu(vvMainWindowBase * m) {
+ mMainWindow = m;
+ // Create main action
if (mToolIconFilename == "noicon")
mAction = new QAction(QString("&").append(mToolMenuName), this);
else
mAction = new QAction(QIcon(mToolIconFilename),
QString("&").append(mToolMenuName), this);
mAction->setStatusTip(mToolTip);
+ // Connect the action
connect(mAction, SIGNAL(triggered()), this, SLOT(MenuToolSlot()));
- mMainWindow->GetInfoForTool()->mMenuTools->addAction(mAction);
- //UpdateEnabledTool();
+ mMainWindow->GetMenu()->addAction(mAction);
}
//------------------------------------------------------------------------------
-
-//------------------------------------------------------------------------------
-void vvToolCreatorBase::UpdateEnabledTool() {
- DD("Update enabled tool");
-
- DD(mMainWindow->GetInfoForTool()->mSlicerManagers->size());
- if (mMainWindow->GetInfoForTool()->mSlicerManagers->size() < 1)
- mAction->setEnabled(false);
- else mAction->setEnabled(true);
-}
-//------------------------------------------------------------------------------
Program: vv
Module: $RCSfile: vvToolCreatorBase.h,v $
Language: C++
- Date: $Date: 2010/01/29 13:54:37 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2010/02/24 11:42:42 $
+ Version: $Revision: 1.2 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2008
#ifndef VVTOOLCREATORBASE_H
#define VVTOOLCREATORBASE_H
-#include "clitkCommon.h"
#include <QObject>
+#include "vvSlicerManager.h"
+#include "vvMainWindowBase.h"
-// For vvMainWindowToolInfo
-#include "vvMainWindow.h"
-class vvMainWindow;
-// struct vvMainWindowToolInfo;
class QAction;
+class vvToolBaseBase;
//------------------------------------------------------------------------------
class vvToolCreatorBase: public QObject {
public:
vvToolCreatorBase(QString name);
- virtual ~vvToolCreatorBase() {;}
-
- virtual void Initialize(vvMainWindow * m);
- virtual void UpdateEnabledTool();
+ virtual ~vvToolCreatorBase() {;}
+ virtual void InsertToolInMenu(vvMainWindowBase * m);
template<class ToolType> void CreateTool();
virtual void MenuSpecificToolSlot() = 0;
-
+ vvMainWindowBase * GetMainWindow() const { return mMainWindow; }
+
QString mToolName;
QString mToolMenuName;
QString mToolIconFilename;
QString mToolTip;
QAction * mAction;
- vvMainWindow * mMainWindow;
-
public slots:
virtual void MenuToolSlot() { MenuSpecificToolSlot(); }
-};
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-template<class ToolType>
-class vvToolCreator: public vvToolCreatorBase {
-public:
- vvToolCreator(QString name):vvToolCreatorBase(name) {;}
- virtual void Initialize(vvMainWindow * m);
- static vvToolCreator<ToolType> * mSingleton;
- virtual void MenuSpecificToolSlot() { CreateTool<ToolType>(); }
+protected:
+ vvMainWindowBase * mMainWindow;
+ std::vector<vvToolBaseBase*> mListOfTool;
};
//------------------------------------------------------------------------------
-
-//------------------------------------------------------------------------------
-#define CREATOR(CLASSNAME) vvToolCreator<CLASSNAME>::mSingleton
-//------------------------------------------------------------------------------
-
-
-//------------------------------------------------------------------------------
-#define ADD_TOOL(NAME) \
- template<> \
- vvToolCreator<NAME> * vvToolCreator<NAME>::mSingleton = \
- new vvToolCreator<NAME>(#NAME);
-//------------------------------------------------------------------------------
-
#include "vvToolCreatorBase.txx"
#endif
Program: vv
Module: $RCSfile: vvToolCreatorBase.txx,v $
Language: C++
- Date: $Date: 2010/01/29 13:54:37 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2010/02/24 11:42:42 $
+ Version: $Revision: 1.2 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2008
=========================================================================*/
-#include "vvMainWindow.h"
-#include "vvSlicerManager.h"
-
//------------------------------------------------------------------------------
+// Called when the tool is created
template<class ToolType>
void vvToolCreatorBase::CreateTool() {
- DD("Create new tool ");
+ // Get information on the current image
+ mMainWindow->UpdateCurrentSlicer();
+ // Create the tool
ToolType * tool = new ToolType(mMainWindow);
+ // Put it in the list of open tools
+ mListOfTool.push_back(tool);
+ // Go !
tool->show();
}
//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-template<class ToolType>
-void vvToolCreator<ToolType>::Initialize(vvMainWindow * m) {
- // Set MainWindow pointer
- mMainWindow = m;
-
- // Default Initialization
- mToolMenuName = mToolName;
- mToolIconFilename = "noicon";
- mToolTip = mToolName;
-
- // User Tool Initialization
- ToolType::Initialize();
-
- // Common Initialization (insertion into menu)
- vvToolCreatorBase::Initialize(mMainWindow);
-}
-//------------------------------------------------------------------------------
-
-// template<class ToolType>
-// void vvToolCreator<ToolType>::UpdateInfoFromMainWindow() { mMainWindowToolInfo = CREATOR(ToolType)->mMainWindow->GetInfoForTool(); }
--- /dev/null
+/*=========================================================================
+
+ Program: vv
+ Module: $RCSfile: vvToolCropImage.cxx,v $
+ Language: C++
+ Date: $Date: 2010/02/24 11:43:37 $
+ Version: $Revision: 1.1 $
+ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+ Copyright (C) 2008
+ Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+ CREATIS-LRMN http://www.creatis.insa-lyon.fr
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 3 of the License.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ =========================================================================*/
+
+#include "vvToolCropImage.h"
+
+//------------------------------------------------------------------------------
+// Create the tool and automagically (I like this word) insert it in
+// the main window menu.
+ADD_TOOL(vvToolCropImage);
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvToolCropImage::vvToolCropImage(vvMainWindowBase * parent, Qt::WindowFlags f):
+ vvToolWidgetBase(parent, f),
+ vvToolBase<vvToolCropImage>(parent),
+ Ui::vvToolCropImage() {
+ // GUI Initialization
+ Ui_vvToolCropImage::setupUi(mToolWidget);
+
+ // Initialize the input selection
+ //UpdateInfoFromMainWindow();
+ // InitializeListOfInputImages(*mMainWindowToolInfo->mSlicerManagers,
+// mMainWindowToolInfo->mSlicerManagerCurrentIndex);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvToolCropImage::~vvToolCropImage() {
+
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolCropImage::InputIsSelected(vvSlicerManager * slicer) {
+ DD("InputIsSelected");
+}
+//------------------------------------------------------------------------------
--- /dev/null
+/*=========================================================================
+
+ Program: vv
+ Module: $RCSfile: vvToolCropImage.h,v $
+ Language: C++
+ Date: $Date: 2010/02/24 11:43:37 $
+ Version: $Revision: 1.1 $
+ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+ Copyright (C) 2010
+ Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+ CREATIS http://www.creatis.insa-lyon.fr
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 3 of the License.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ =========================================================================*/
+
+#ifndef VVTOOLCROPIMAGE_H
+#define VVTOOLCROPIMAGE_H
+
+#include <QtDesigner/QDesignerExportWidget>
+#include <QDialog>
+
+#include "vvToolBase.h"
+#include "vvToolWidgetBase.h"
+#include "vvMainWindowBase.h"
+#include "ui_vvToolCropImage.h"
+
+//------------------------------------------------------------------------------
+class vvToolCropImage:
+ public vvToolWidgetBase,
+ public vvToolBase<vvToolCropImage>,
+ private Ui::vvToolCropImage
+{
+ Q_OBJECT
+ public:
+ vvToolCropImage(vvMainWindowBase * parent=0, Qt::WindowFlags f=0);
+ ~vvToolCropImage();
+
+ //-----------------------------------------------------
+ typedef vvToolCropImage Self;
+ bool close() { return QWidget::close(); }
+ virtual void InputIsSelected(vvSlicerManager *m);
+ //void AnImageIsBeingClosed(vvSlicerManager * m) { vvToolWidgetBase::TTAnImageIsBeingClosed(m); }
+
+ void bar() { DD("crop::bar"); }
+
+
+public slots:
+ void apply() { DD("Apply"); }
+
+ //-----------------------------------------------------
+ static void Initialize() {
+ SetToolName("Crop");
+ SetToolMenuName("Crop");
+ SetToolIconFilename(":/new/prefix1/icons/binarize.png");
+ SetToolTip("Crop image.");
+ }
+
+ protected:
+ Ui::vvToolCropImage ui;
+
+
+}; // end class vvToolCropImage
+//------------------------------------------------------------------------------
+
+#endif
+
--- /dev/null
+/*=========================================================================
+
+ Program: vv
+ Module: $RCSfile: vvToolFoo.cxx,v $
+ Language: C++
+ Date: $Date: 2010/02/24 11:43:37 $
+ Version: $Revision: 1.1 $
+ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+ Copyright (C) 2010
+ Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+ CREATIS http://www.creatis.insa-lyon.fr
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 3 of the License.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ =========================================================================*/
+
+#include "vvToolFoo.h"
+
+//------------------------------------------------------------------------------
+// Create the tool and automagically (I like this word) insert it in
+// the main window menu.
+ADD_TOOL(vvToolFoo);
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+vvToolFoo::vvToolFoo(vvMainWindowBase * parent, Qt::WindowFlags f)
+ :QDialog(parent),
+ vvToolBase<vvToolFoo>(parent),
+ Ui::vvToolFoo() {
+ // Setup the UI
+ Ui_vvToolFoo::setupUi(this);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvToolFoo::~vvToolFoo() {
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolFoo::Initialize() {
+ SetToolName("Foo");
+ SetToolMenuName("Foo");
+ SetToolIconFilename(":/new/prefix1/icons/ducky.png");
+ SetToolTip("Make 'foo' on an image.");
+}
+//------------------------------------------------------------------------------
+
+
+
--- /dev/null
+/*=========================================================================
+
+ Program: vv
+ Module: $RCSfile: vvToolFoo.h,v $
+ Language: C++
+ Date: $Date: 2010/02/24 11:43:37 $
+ Version: $Revision: 1.1 $
+ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+ Copyright (C) 2010
+ Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+ CREATIS http://www.creatis.insa-lyon.fr
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 3 of the License.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ =========================================================================*/
+
+#ifndef VVTOOLFOO_H
+#define VVTOOLFOO_H
+
+#include <QtDesigner/QDesignerExportWidget>
+#include <QDialog>
+
+#include "vvToolBase.h"
+#include "ui_vvToolFoo.h"
+
+//------------------------------------------------------------------------------
+class vvToolFoo:
+ public QDialog,
+ public vvToolBase<vvToolFoo>,
+ private Ui::vvToolFoo
+{
+ Q_OBJECT
+ public:
+ vvToolFoo(vvMainWindowBase* parent=0, Qt::WindowFlags f=0);
+ ~vvToolFoo();
+
+ static void Initialize();
+
+ protected:
+ Ui::vvToolFoo ui;
+
+}; // end class vvToolFoo
+//------------------------------------------------------------------------------
+
+#endif
+
Program: vv
Module: $RCSfile: vvToolInputSelectorWidget.cxx,v $
Language: C++
- Date: $Date: 2010/01/29 13:54:37 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2010/02/24 11:42:42 $
+ Version: $Revision: 1.2 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2010
//------------------------------------------------------------------------------
void vvToolInputSelectorWidget::Initialize(std::vector<vvSlicerManager*> l, int index) {
- DD("Initialize"); DD(index);
mInputSequenceBox->clear();
mSlicerManagerList = l;
mCurrentIndex = index;
//------------------------------------------------------------------------------
void vvToolInputSelectorWidget::SetToolTip(QString s) {
- // mLabelSelection->setToolTip(s);
- //mInputSequenceBox->setToolTip(s);
setToolTip(s);
}
//------------------------------------------------------------------------------
Program: vv
Module: $RCSfile: vvToolInputSelectorWidget.h,v $
Language: C++
- Date: $Date: 2010/02/05 09:06:46 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2010/02/24 11:42:42 $
+ Version: $Revision: 1.3 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2010
#include <QtDesigner/QDesignerExportWidget>
#include <QDialog>
-
#include "ui_vvToolInputSelectorWidget.h"
+#include "vvImage.h"
class vvSlicerManager;
Ui::vvToolInputSelectorWidget ui;
std::vector<vvSlicerManager*> mSlicerManagerList;
int mCurrentIndex;
+ vvSlicerManager * mCurrentSliceManager;
}; // end class vvToolInputSelectorWidget
//------------------------------------------------------------------------------
Program: vv
Module: $RCSfile: vvToolManager.cxx,v $
Language: C++
- Date: $Date: 2010/02/03 10:54:08 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2010/02/24 11:42:42 $
+ Version: $Revision: 1.3 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2008
=========================================================================*/
#include "vvToolManager.h"
-#include "vvMainWindow.h"
+#include "vvToolCreatorBase.h"
+#include "vvMainWindowBase.h"
+//------------------------------------------------------------------------------
+/// Unique static instance
vvToolManager* vvToolManager::mSingleton=0;
+//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
vvToolManager * vvToolManager::GetInstance() {
//------------------------------------------------------------------------------
-void vvToolManager::Initialize(vvMainWindow * m) {
+void vvToolManager::InsertToolsInMenu(vvMainWindowBase * m) {
for(unsigned int i=0; i<GetInstance()->mListOfTools.size(); i++) {
- GetInstance()->mListOfTools[i]->Initialize(m);
+ GetInstance()->mListOfTools[i]->InsertToolInMenu(m);
}
}
//------------------------------------------------------------------------------
-
-//------------------------------------------------------------------------------
-void vvToolManager::UpdateEnabledTool() {
- for(unsigned int i=0; i<GetInstance()->mListOfTools.size(); i++) {
- GetInstance()->mListOfTools[i]->UpdateEnabledTool();
- }
-}
-//------------------------------------------------------------------------------
Program: vv
Module: $RCSfile: vvToolManager.h,v $
Language: C++
- Date: $Date: 2010/02/03 10:54:08 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2010/02/24 11:42:42 $
+ Version: $Revision: 1.3 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2008
#ifndef VVTOOLMANAGER_H
#define VVTOOLMANAGER_H
-#include "vvToolCreatorBase.h"
#include "clitkCommon.h"
class vvToolCreatorBase;
-class vvMainWindow;
+class vvMainWindowBase;
//------------------------------------------------------------------------------
// Manage a list of ToolCreator. Each tool will be automagically
// MainWindow will call the 'Initialize' to insert the tool in the
// menu bar.
class vvToolManager {
+
public:
- // Functions
+
+ /// Get or build unique instance with this method
static vvToolManager * GetInstance();
+
+ /// Add a tool creator in the list (called before main, via static member initialization)
static void AddTool(vvToolCreatorBase * v);
- static void Initialize(vvMainWindow * m);
- static void UpdateEnabledTool();
- // Variables
- std::vector<vvToolCreatorBase *> mListOfTools;
+
+ /// Called in MainWindow, insert all tools into the menu
+ static void InsertToolsInMenu(vvMainWindowBase * m);
+
+protected:
+
+ /// Singleton object pointer
static vvToolManager * mSingleton;
+
+ /// list of all tool creators
+ std::vector<vvToolCreatorBase *> mListOfTools;
};
//------------------------------------------------------------------------------
--- /dev/null
+/*=========================================================================
+
+ Program: vv
+ Module: $RCSfile: vvToolWidgetBase.cxx,v $
+ Language: C++
+ Date: $Date: 2010/02/24 11:43:37 $
+ Version: $Revision: 1.1 $
+ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+ Copyright (C) 2008
+ Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+ CREATIS-LRMN http://www.creatis.insa-lyon.fr
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 3 of the License.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ =========================================================================*/
+
+#include "vvToolWidgetBase.h"
+#include "vvMainWindowBase.h"
+#include "vvSlicerManager.h"
+
+//------------------------------------------------------------------------------
+vvToolWidgetBase::vvToolWidgetBase(vvMainWindowBase * parent, Qt::WindowFlags f)
+ :QDialog(parent, f),
+ Ui::vvToolWidgetBase() {
+
+ // Set Modality : dialog is not modal but stay always on top because
+ // parent is set at construction
+ mIsInitialized = false;
+ mFilter = 0;
+ mMainWindowBase = parent;
+ setModal(false);
+ setAttribute(Qt::WA_DeleteOnClose);
+
+ // GUI Initialization
+ setupUi(this);
+
+ // Connect signals & slots
+ connect(mMainWindowBase, SIGNAL(AnImageIsBeingClosed(vvSlicerManager*)),
+ this, SLOT(AnImageIsBeingClosed(vvSlicerManager*)));
+ connect(mToolInputSelectionWidget, SIGNAL(accepted()), this, SLOT(InputIsSelected()));
+ connect(mToolInputSelectionWidget, SIGNAL(rejected()), this, SLOT(close()));
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(apply()));
+ connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
+
+ // Disable main widget while input image is not selected
+ mToolWidget->setEnabled(false);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvToolWidgetBase::~vvToolWidgetBase() {
+
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolWidgetBase::show() {
+ if (!mIsInitialized) {
+ InitializeInputs();
+ }
+ QDialog::show();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+bool vvToolWidgetBase::close() {
+ return QDialog::close();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolWidgetBase::AnImageIsBeingClosed(vvSlicerManager * m) {
+ if (m == mCurrentSlicerManager) {
+ close();
+ }
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolWidgetBase::InitializeInputs() {
+ if (mFilter) {
+ int j=0;
+ mToolInputSelectionWidget->SetToolTip(QString("%1").arg(mFilter->GetAvailableImageTypes().c_str()));
+ for(unsigned int i=0; i<mMainWindowBase->GetSlicerManagers().size(); i++) {
+ vvImage * s = mMainWindowBase->GetSlicerManagers()[i]->GetImage();
+ if (mFilter->CheckImageType(s->GetNumberOfDimensions(),
+ s->GetNumberOfScalarComponents(),
+ s->GetScalarTypeAsString())) {
+ mSlicerManagersCompatible.push_back(mMainWindowBase->GetSlicerManagers()[i]);
+ if ((int)i == mMainWindowBase->GetSlicerManagerCurrentIndex()) mCurrentCompatibleIndex = j;
+ j++;
+ }
+ }
+ }
+ else {
+ mSlicerManagersCompatible = mMainWindowBase->GetSlicerManagers();
+ mCurrentCompatibleIndex = mMainWindowBase->GetSlicerManagerCurrentIndex();
+ }
+ mToolInputSelectionWidget->Initialize(mSlicerManagersCompatible,
+ mCurrentCompatibleIndex);
+ mIsInitialized = true;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolWidgetBase::InputIsSelected() {
+ // Common
+ int index = mToolInputSelectionWidget->GetSelectedInputIndex();
+ mCurrentSlicerManager = mSlicerManagersCompatible[index];
+ mToolWidget->setEnabled(true);
+ if (!mCurrentSlicerManager) close();
+ InputIsSelected(mCurrentSlicerManager);
+}
+//------------------------------------------------------------------------------
+
--- /dev/null
+/*=========================================================================
+
+ Program: vv
+ Module: $RCSfile: vvToolWidgetBase.h,v $
+ Language: C++
+ Date: $Date: 2010/02/24 11:43:37 $
+ Version: $Revision: 1.1 $
+ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+ Copyright (C) 2010
+ Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+ CREATIS http://www.creatis.insa-lyon.fr
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 3 of the License.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ =========================================================================*/
+
+#ifndef VVTOOLWIDGETBASE_H
+#define VVTOOLWIDGETBASE_H
+
+#include <QtDesigner/QDesignerExportWidget>
+#include "ui_vvToolWidgetBase.h"
+#include "clitkImageToImageGenericFilter.h"
+class vvMainWindowBase;
+
+//------------------------------------------------------------------------------
+class vvToolWidgetBase:
+ public QDialog,
+ public Ui::vvToolWidgetBase
+{
+ Q_OBJECT
+ public:
+
+ vvToolWidgetBase(vvMainWindowBase * parent=0, Qt::WindowFlags f=0);
+ ~vvToolWidgetBase();
+
+ virtual void InputIsSelected(vvSlicerManager *m) = 0;
+
+public slots:
+ virtual void apply() = 0;
+ void InputIsSelected();
+ void AnImageIsBeingClosed(vvSlicerManager * m);
+ void show();
+ virtual bool close();
+
+protected:
+ void InitializeInputs();
+ Ui::vvToolWidgetBase ui;
+ clitk::ImageToImageGenericFilterBase * mFilter;
+ vvMainWindowBase * mMainWindowBase;
+ std::vector<vvSlicerManager*> mSlicerManagersCompatible;
+ vvSlicerManager * mCurrentSlicerManager;
+ int mCurrentCompatibleIndex;
+ vvImage * mCurrentImage;
+ bool mIsInitialized;
+
+}; // end class vvToolWidgetBase
+//------------------------------------------------------------------------------
+
+#endif
+