}
//--------------------------------------------------------------------
-
//--------------------------------------------------------------------
void clitk::DicomRT_ROI::Print(std::ostream & os) const {
//--------------------------------------------------------------------
+//--------------------------------------------------------------------
+void clitk::DicomRT_ROI::SetBackgroundValueLabelImage(double bg){
+ mBackgroundValue = bg;
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+double clitk::DicomRT_ROI::GetBackgroundValueLabelImage() const {
+ return mBackgroundValue;
+}
+//--------------------------------------------------------------------
+
+
//--------------------------------------------------------------------
void clitk::DicomRT_ROI::Read(std::map<int, std::string> & rois, gdcm::SQItem * item) {
void SetDisplayColor(double r, double v, double b);
+ double GetBackgroundValueLabelImage() const;
+ void SetBackgroundValueLabelImage(double bg);
+
protected:
void ComputeMesh();
std::string mName;
vtkPolyData * mMesh;
bool mMeshIsUpToDate;
vvImage::Pointer mImage;
+ double mBackgroundValue;
};
//--------------------------------------------------------------------
<< " ";
for(unsigned int i=0; i< dim-1; i++)
os << inputSpacing[i] << "x";
- os << inputSpacing[dim-1];
+ os << inputSpacing[dim-1]
+ << " ";
+ for(unsigned int i=0; i< dim-1; i++)
+ os << inputOrigin[i] << "x";
+ os << inputOrigin[dim-1] << " ";
}
else {
os << "Dim = " << dim << "D" << std::endl;
======================================================================-====*/
#ifndef CLITKIMAGECOMMON_TXX
#define CLITKIMAGECOMMON_TXX
-/**
- -------------------------------------------------
- * @file clitkImageCommon.txx
- * @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
- * @date 07 Sep 2007 11:34:19
- *
- * @brief
- *
- *
- -------------------------------------------------*/
+
//--------------------------------------------------------------------
template<class PixelType>
template<class ImageType>
typename ImageType::Pointer NewImageLike(const typename ImageType::Pointer input, bool allocate) {
typename ImageType::Pointer output = ImageType::New();
- output->SetRegions(input->GetLargestPossibleRegion());
- output->SetOrigin(input->GetOrigin());
- output->SetSpacing(input->GetSpacing());
+ output->CopyInformation(input);
+ output->SetRegions(input->GetLargestPossibleRegion());
if (allocate) output->Allocate();
return output;
}
#=========================================================
-OPTION(CLITK_VV_USE_BDCM "Build vv with Dicom selector bdcm" OFF)
+# OPTION(CLITK_VV_USE_BDCM "Build vv with Dicom selector bdcm" OFF)
SET(vv_SRCS
vvInfoPanel.cxx
ENDIF(NOT __APPLE__)
#=========================================================
-IF (CLITK_VV_USE_BDCM)
- FIND_PACKAGE(bdcm)
- IF(bdcm_FOUND)
- INCLUDE(${bdcm_USE_FILE})
- ELSE(bdcm_FOUND)
- MESSAGE(FATAL_ERROR
- "Cannot build without BDCM. Please set BDCM_DIR.")
- ENDIF(bdcm_FOUND)
- #LINK_DIRECTORIES(/home/dsarrut/src/bdcm/build/)
- #INCLUDE_DIRECTORIES(/home/dsarrut/src/bdcm/src2/)
+# IF (CLITK_VV_USE_BDCM)
+# FIND_PACKAGE(bdcm)
+# IF(bdcm_FOUND)
+# INCLUDE(${bdcm_USE_FILE})
+# ELSE(bdcm_FOUND)
+# MESSAGE(FATAL_ERROR
+# "Cannot build without BDCM. Please set BDCM_DIR.")
+# ENDIF(bdcm_FOUND)
+# #LINK_DIRECTORIES(/home/dsarrut/src/bdcm/build/)
+# #INCLUDE_DIRECTORIES(/home/dsarrut/src/bdcm/src2/)
- FIND_PACKAGE(GDCM)
- IF(GDCM_FOUND)
- INCLUDE(${GDCM_USE_FILE})
- ELSE(GDCM_FOUND)
- MESSAGE(FATAL_ERROR
- "Cannot build without GDCM. Please set GDCM_DIR.")
- ENDIF(GDCM_FOUND)
+# FIND_PACKAGE(GDCM)
+# IF(GDCM_FOUND)
+# INCLUDE(${GDCM_USE_FILE})
+# ELSE(GDCM_FOUND)
+# MESSAGE(FATAL_ERROR
+# "Cannot build without GDCM. Please set GDCM_DIR.")
+# ENDIF(GDCM_FOUND)
-ENDIF (CLITK_VV_USE_BDCM)
+# ENDIF (CLITK_VV_USE_BDCM)
IF(WIN32)
SET(EXE_ICON vvIcon.rc)
<rect>
<x>0</x>
<y>0</y>
- <width>601</width>
- <height>414</height>
+ <width>483</width>
+ <height>519</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_3">
+ <layout class="QVBoxLayout" name="verticalLayout_4">
<item>
- <widget class="QComboBox" name="mOpenComboBox">
- <property name="currentIndex">
- <number>0</number>
- </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
- <property name="text">
- <string>Open binary image</string>
- </property>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="title">
+ <string>Add Label Image from file</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QPushButton" name="mOpenBinaryButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>24</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Open label image</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../vvIcons.qrc">
+ <normaloff>:/common/icons/fileopen.png</normaloff>:/common/icons/fileopen.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QLabel" name="dimensionStaticLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+<html><head><meta name="qrichtext" content="1" /><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:9pt;">Background value :</span></p></body></html></string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="mBackgroundValueSpinBox"/>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
</item>
<item>
- <property name="text">
- <string>Open DICOM RT StructureSet</string>
- </property>
+ <widget class="QGroupBox" name="groupBox_4">
+ <property name="title">
+ <string>Add DICOM RT contours</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QPushButton" name="mOpenBinaryButton_3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>24</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Open DICOM RT Struct</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../vvIcons.qrc">
+ <normaloff>:/common/icons/fileopen.png</normaloff>:/common/icons/fileopen.png</iconset>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</item>
<item>
- <property name="text">
- <string>Open VTK mesh</string>
- </property>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
</item>
- </widget>
+ </layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<string>Name</string>
</property>
</column>
- <column>
- <property name="text">
- <string>Show</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Refresh</string>
- </property>
- </column>
<item>
<property name="text">
<string>1</string>
<property name="text">
<string>Default</string>
</property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../vvIcons.qrc">
- <normaloff>:/common/icons/standardbutton-cancel-16.png</normaloff>
- <normalon>:/common/icons/standardbutton-apply-16.png</normalon>:/common/icons/standardbutton-cancel-16.png</iconset>
- </property>
<property name="flags">
<set>ItemIsSelectable|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate</set>
</property>
<property name="text">
<string>2</string>
</property>
+ <property name="text">
+ <string/>
+ </property>
</item>
</item>
<item>
<property name="text">
<string>1</string>
</property>
+ <property name="text">
+ <string/>
+ </property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
+ <property name="text">
+ <string/>
+ </property>
</item>
</item>
</widget>
<string>Current ROI</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_6">
+ <item>
+ <widget class="QCheckBox" name="mCheckBoxShow">
+ <property name="text">
+ <string>Show</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="mChangeColorButton">
+ <property name="toolTip">
+ <string/>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>color</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="mChangeColorButton_2">
+ <property name="toolTip">
+ <string/>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../vvIcons.qrc">
+ <normaloff>:/common/icons/rotateright.png</normaloff>:/common/icons/rotateright.png</iconset>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="QLabel" name="vectorFieldNameLabel_7">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Opacity</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="horizontalSlider">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="spinBox"/>
+ </item>
+ </layout>
+ </item>
<item>
<widget class="QLabel" name="vectorFieldNameLabel_5">
<property name="sizePolicy">
<resources>
<include location="../vvIcons.qrc"/>
</resources>
- <connections/>
+ <connections>
+ <connection>
+ <sender>horizontalSlider</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>spinBox</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>344</x>
+ <y>416</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>426</x>
+ <y>416</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>spinBox</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>horizontalSlider</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>432</x>
+ <y>421</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>351</x>
+ <y>421</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
</ui>
//------------------------------------------------------------------------------
-
//------------------------------------------------------------------------------
void vvBinaryImageOverlayActor::setSlicer(vvSlicer * slicer) {
mSlicer = slicer;
// Create an actor for each time slice
for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) {
DD(numImage);
+
+ // how many intensity ?
+
+
vtkImageMapToRGBA * mOverlayMapper = vtkImageMapToRGBA::New();
mOverlayMapper->SetInput(mImage->GetVTKImages()[0]); // DS TODO : to change if it is 4D !!!
vtkLookupTable * lut = vtkLookupTable::New();
DD(lut->IsOpaque ());
lut->SetRange(0,1);
lut->SetNumberOfTableValues(2);
- lut->SetTableValue(0, 0, 0, 0, 0.0); // BG
+ lut->SetTableValue(mBackgroundValue, 0, 0, 0, 0.0); // BG
lut->SetTableValue(1, mColor[0], mColor[1], mColor[2], mAlpha); // FG
DD(mColor[0]);
mOverlayMapper->SetLookupTable(lut);
//------------------------------------------------------------------------------
-void vvBinaryImageOverlayActor::setImage(vvImage::Pointer image) {
+void vvBinaryImageOverlayActor::setImage(vvImage::Pointer image, double bg) {
mImage = image;
+ mBackgroundValue = bg;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvBinaryImageOverlayActor::update(int slicer, int slice) {
- // DD("update");
- // DD(slicer);
- // DD(slice);
if (!mSlicer) return;
- // DD(mSlicer->GetSlice());
- // DD(mSlicer->GetTSlice());
if (mPreviousSlice == mSlicer->GetSlice()) {
if (mPreviousTSlice == mSlicer->GetTSlice()) {
- DD("=========== NOTHING");
+ //DD("=========== NOTHING");
return; // Nothing to do
}
}
mTSlice = mSlicer->GetTSlice();
// Update extent
- // DD("Update extent");
-
- /*
-1 - get extent
-2 - orientation
-3 - compute new extent : ComputeImageDisplayedExtent
-4 - ClipDisplayedExtent
-5 - actor SetDisplayExtent
-
-==> à mettre dans slicer.
- ==> fct (image input, image à overl)
- */
int * imageExtent = mSlicer->GetExtent();
int orientation = mSlicer->GetOrientation();
int maskExtent[6];
// << maskExtent[3] << " " << maskExtent[4] << " " << maskExtent[5] << std::endl;
SetDisplayExtentAndCameraPosition(orientation, mSlice, maskExtent, mImageActorList[mTSlice], 0.0);
- // TOO SLOW ?
- //mSlicer->Render();
-
- //
+ // set previous slice
mPreviousTSlice = mSlicer->GetTSlice();
mPreviousSlice = mSlicer->GetSlice();
}
int * extent,
vtkImageActor * actor,
double position) {
- // DD("SetDisplayExtentAndCameraPosition");
- //DD(orientation);
- //DD(slice);
actor->SetDisplayExtent(extent);
-
+ // Set position
if (orientation == vtkImageViewer2::SLICE_ORIENTATION_XY) {
if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice)
actor->SetPosition(0,0, position);
void hideActors();
void showActors();
void setColor(double r, double g, double b);
- void setImage(vvImage::Pointer image);
+ void setImage(vvImage::Pointer image, double bg);
void initialize();
protected:
vvImage::Pointer mImage;
std::vector<double> mColor;
double mAlpha;
+ double mBackgroundValue;
std::vector<vtkImageMapToRGBA *> mMapperList;
std::vector<vtkImageActor*> mImageActorList;
{
mSlicerManagers[i]->GetSlicer(0)->SetSlice(value);
mSlicerManagers[i]->VerticalSliderHasChanged(0, value);
- // mSlicerManagers[i]->UpdateSlice(0);
- // <-- DS add this. Not too much update ? YES.
+ // mSlicerManagers[i]->UpdateSlice(0); // <-- DS add this. Not too much update ? YES.
+ mSlicerManagers[i]->GetSlicer(0)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
break;
}
}
if (DataTree->topLevelItem(i)->data(COLUMN_UR_VIEW,Qt::CheckStateRole).toInt() > 1)
{
mSlicerManagers[i]->GetSlicer(1)->SetSlice(value);
+ mSlicerManagers[i]->VerticalSliderHasChanged(1, value);
+ mSlicerManagers[i]->GetSlicer(1)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
break;
}
}
if (DataTree->topLevelItem(i)->data(COLUMN_DL_VIEW,Qt::CheckStateRole).toInt() > 1)
{
mSlicerManagers[i]->GetSlicer(2)->SetSlice(value);
+ mSlicerManagers[i]->VerticalSliderHasChanged(2, value);
+ mSlicerManagers[i]->GetSlicer(2)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
break;
}
}
if (DataTree->topLevelItem(i)->data(COLUMN_DR_VIEW,Qt::CheckStateRole).toInt() > 1)
{
mSlicerManagers[i]->GetSlicer(3)->SetSlice(value);
+ mSlicerManagers[i]->VerticalSliderHasChanged(3, value);
+ mSlicerManagers[i]->GetSlicer(3)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
break;
}
}
#include <vtkImageActor.h>
#include <vtkCamera.h>
#include <vtkRenderer.h>
+//#include <vtkRenderWindow.h>
#include <vtkMarchingSquares.h>
#include <vtkImageClip.h>
#include <vtkImageData.h>
if (mROI->GetImage()) {
mImageContour.clear();
mOverlayActors.clear();
- DD(mSlicerManager->NumberOfSlicers());
for(int i=0;i<mSlicerManager->NumberOfSlicers(); i++) {
mImageContour.push_back(new vvImageContour);
mImageContour[i]->setSlicer(mSlicerManager->GetSlicer(i));
mImageContour[i]->setPreserveMemoryModeEnabled(false);
mOverlayActors.push_back(new vvBinaryImageOverlayActor);
- mOverlayActors[i]->setImage(mROI->GetImage());
+ mOverlayActors[i]->setImage(mROI->GetImage(), mROI->GetBackgroundValueLabelImage());
mOverlayActors[i]->setColor(mROI->GetDisplayColor()[0],
mROI->GetDisplayColor()[1],
mROI->GetDisplayColor()[2]);
//------------------------------------------------------------------------------
void vvROIActor::Update() {
- DD("vvROIActor::Update");
for(int i=0; i<mSlicerManager->NumberOfSlicers(); i++) {
UpdateSlice(i, mSlicerManager->GetSlicer(i)->GetSlice());
}
//------------------------------------------------------------------------------
void vvROIActor::UpdateSlice(int slicer, int slices) {
- // DD("UpdateSlice");
- // DD(slicer);
- // DD(slices);
if (!mROI->GetImage()) return;
if (!mSlicerManager) {
// CONTOUR HERE
// mImageContour[slicer]->update(1.0);
-
+ // Refresh overlays
mOverlayActors[slicer]->update(slicer, slices);
- // TOO SLOW !!!!!
- // mSlicerManager->GetSlicer(slicer)->Render();
+ // Do not used the following line : TOO SLOW.
+ // mSlicerManager->GetSlicer(slicer)->GetRenderWindow()->Render();
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+vvROIActor * vvStructureSetActor::GetROIActor(int n) {
+ if (mMapROIIndex.find(n) == mMapROIIndex.end()) {
+ std::cerr << "No ROI number " << n << std::endl;
+ return NULL;
+ }
+ return mROIActors[mMapROIIndex[n]];
+}
+//------------------------------------------------------------------------------
+
+
//------------------------------------------------------------------------------
void vvStructureSetActor::CreateNewROIActor(int n) {
DD("AddROIActor");
actor->SetROI(roi);
actor->SetSlicerManager(mSlicerManager);
actor->Initialize();
- //
+ mMapROIIndex[n] = mROIActors.size()-1;
- actor->Update();
+ // actor->Update();
}
//------------------------------------------------------------------------------
void SetStructureSet(clitk::DicomRT_StructureSet * s);
void SetSlicerManager(vvSlicerManager * s);
void CreateNewROIActor(int n);
+ vvROIActor* GetROIActor(int n);
protected:
clitk::DicomRT_StructureSet * mStructureSet;
vvSlicerManager * mSlicerManager;
std::vector<vvROIActor*> mROIActors;
+ std::map<int, int> mMapROIIndex;
}; // end class vvStructureSetActor
//------------------------------------------------------------------------------
#include "vvImageReader.h"
#include "vvStructureSetActor.h"
#include "vvSlicer.h"
+#include "vvROIActor.h"
#include <QFileDialog>
#include <QMessageBox>
#include <vtkLookupTable.h>
s.push_back(1);
splitter->setSizes(s);
// Connect open menus
- connect(mOpenComboBox, SIGNAL(activated(int)), this, SLOT(open(int)));
+ // connect(mOpenComboBox, SIGNAL(activated(int)), this, SLOT(open(int)));
+
+ connect(mOpenBinaryButton, SIGNAL(clicked()), this, SLOT(openBinaryImage()));
+
DD(mCurrentImage->GetNumberOfDimensions());
- // To trigger the Render ??
- // connect(m,SIGNAL(releasemouse()),this,SLOT(Render()));
-
- // connect(m, SIGNAL(UpdateSlice(int, int)), SLOT(UpdateSlice(int, int)));
- connect(m, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int)));
+ // Seems that the following is not needed to refresh ...
+ // connect(m, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int)));
+
+ connect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(selectedItemChangedInTree()));
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolStructureSetManager::selectedItemChangedInTree() {
+ DD("selectedItemChangedInTree");
+ QList<QTreeWidgetItem *> l = mTree->selectedItems();
+ DD(l.size());
+ QTreeWidgetItem * w = l[0];
+ if (mMapTreeWidgetToROI.find(w) == mMapTreeWidgetToROI.end()) return; // Search for SS (first)
+ clitk::DicomRT_ROI * roi = mMapTreeWidgetToROI[w];
+ DD(roi->GetName());
+ setCurrentSelectedROI(roi);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolStructureSetManager::setCurrentSelectedROI(clitk::DicomRT_ROI * roi) {
+ // mCheckBoxShow = // get roi actor .../
+
}
//------------------------------------------------------------------------------
for(int i=0; i<w->columnCount (); i++) {
w->setBackground(i, brush);
}
+ mMapROIToTreeWidget[roi] = w;
+ mMapTreeWidgetToROI[w] = roi;
+ // Connect ROI TreeWidget
+ // TODO
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvToolStructureSetManager::addStructureSetInTreeWidget(int index, clitk::DicomRT_StructureSet * s) {
- // Main row item
- QTreeWidgetItem * ss = new QTreeWidgetItem(mTree);
- // ss->setFlags(Qt::ItemIsSelectable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsTristate);
- ss->setText(0, QString("S%1").arg(index));
- ss->setText(1, QString("%1").arg(s->GetLabel().c_str()));
+void vvToolStructureSetManager::updateStructureSetInTreeWidget(int index, clitk::DicomRT_StructureSet * s) {
+ QTreeWidgetItem * ss;
+ if (mMapStructureSetIndexToTreeWidget.find(index) == mMapStructureSetIndexToTreeWidget.end()) {
+ // Main row item
+ ss = new QTreeWidgetItem(mTree);
+ // ss->setFlags(Qt::ItemIsSelectable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsTristate);
+ ss->setText(0, QString("S%1").arg(index));
+ ss->setText(1, QString("%1").arg(s->GetLabel().c_str()));
+ // Insert in list
+ mMapStructureSetIndexToTreeWidget[index] = ss;
+
+ // Connect Structure TreeWidget
+ // TODO
+ }
+ else ss = mMapStructureSetIndexToTreeWidget[index];
// Insert ROI
const std::vector<clitk::DicomRT_ROI*> & rois = s->GetListOfROI();
for(unsigned int i=0; i<rois.size(); i++) {
- DD(i);
- addRoiInTreeWidget(rois[i], ss);
+ if (mMapROIToTreeWidget.find(rois[i]) == mMapROIToTreeWidget.end())
+ addRoiInTreeWidget(rois[i], ss);
}
-
- // Insert in list
- mStructureSetItemsList[index] = ss;
-
- // Connect
- // TODO
}
//------------------------------------------------------------------------------
DD("openBinaryImage");
// Select current StructureSet (or create)
int index;
+ DD(mCurrentStructureSetIndex);
if (mCurrentStructureSet == NULL) {
if (mStructureSetsList.size() == 0) { // Create a default SS
clitk::DicomRT_StructureSet * mStructureSet = new clitk::DicomRT_StructureSet;
else { // Get first SS
index = 0;
}
- // TODO -> SET THIS SS AS CURRENT
- mCurrentStructureSet = mStructureSetsList[index];
- mCurrentStructureSetActor = mStructureSetActorsList[index];
}
else {
index = mCurrentStructureSetIndex;
}
+ DD(index);
+ // TODO -> SET THIS SS AS CURRENT
+ mCurrentStructureSet = mStructureSetsList[index];
+ mCurrentStructureSetActor = mStructureSetActorsList[index];
+ mCurrentStructureSetIndex = index;
DD(mCurrentStructureSet->GetName());
// Open images
mMainWindowBase->GetInputPathName(),Extensions);
if (filename.size() == 0) return;
+ std::vector<int> mLoadedROIIndex;
for(int i=0; i<filename.size(); i++) {
DD(filename[i].toStdString());
return;
}
vvImage::Pointer binaryImage = mReader->GetOutput();
- // delete mReader;
-
- // Check Dimension
- int dim = mCurrentImage->GetNumberOfDimensions();
- DD(dim);
- int bin_dim = binaryImage->GetNumberOfDimensions();
- DD(bin_dim);
- if (dim < bin_dim) { ////////// TO CHANGE FOR 3D/4D
- std::ostringstream os;
- os << "Error. Loaded binary image is " << bin_dim
- << "D while selected image is " << dim << "D" << std::endl;
- QMessageBox::information(this,tr("Reading problem"),os.str().c_str());
- return;
- }
+ // delete mReader;
+
+ // Check Dimension
+ int dim = mCurrentImage->GetNumberOfDimensions();
+ DD(dim);
+ int bin_dim = binaryImage->GetNumberOfDimensions();
+ DD(bin_dim);
+ if (dim < bin_dim) { ////////// TO CHANGE FOR 3D/4D
+ std::ostringstream os;
+ os << "Error. Loaded binary image is " << bin_dim
+ << "D while selected image is " << dim << "D" << std::endl;
+ QMessageBox::information(this,tr("Reading problem"),os.str().c_str());
+ return;
+ }
+
+ // Add a new roi to the structure
+ int n = mCurrentStructureSet->AddBinaryImageAsNewROI(binaryImage, filename[i].toStdString());
+ //DD(n);
+ mLoadedROIIndex.push_back(n);
+
+ mCurrentStructureSet->GetROI(n)->SetBackgroundValueLabelImage(mBackgroundValueSpinBox->value());
+
+ // Change color NEED DEFAULT COLOR LIST
+ DD(mDefaultLUTColor->GetNumberOfTableValues ());
+ if (n<mDefaultLUTColor->GetNumberOfTableValues ()) {
+ double * color = mDefaultLUTColor->GetTableValue(n % mDefaultLUTColor->GetNumberOfTableValues ());
+ DD(color[0]);
+ DD(color[1]);
+ DD(color[2]);
+ mCurrentStructureSet->GetROI(n)->SetDisplayColor(color[0], color[1], color[2]);
+ }
+
+ // Add a new roi actor
+ mCurrentStructureSetActor->CreateNewROIActor(n);
+ } // end loop on n selected filenames
- // Add a new roi to the structure
- int n = mCurrentStructureSet->AddBinaryImageAsNewROI(binaryImage, filename[i].toStdString());
- DD(n);
+ // Update the TreeWidget
+ updateStructureSetInTreeWidget(index, mCurrentStructureSet);
- // Change color NEED DEFAULT COLOR LIST
- DD(mDefaultLUTColor->GetNumberOfTableValues ());
- if (n<mDefaultLUTColor->GetNumberOfTableValues ()) {
- double * color = mDefaultLUTColor->GetTableValue(n % mDefaultLUTColor->GetNumberOfTableValues ());
- DD(color[0]);
- DD(color[1]);
- DD(color[2]);
- mCurrentStructureSet->GetROI(n)->SetDisplayColor(color[0], color[1], color[2]);
+ // Render loaded ROIs (the first is sufficient)
+ for(unsigned int i=0; i<mLoadedROIIndex.size(); i++) {
+ mCurrentStructureSetActor->GetROIActor(mLoadedROIIndex[i])->Update();
}
-
- // Add a new roi actor
- mCurrentStructureSetActor->CreateNewROIActor(n);
+ for(int i=0; i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
+ mCurrentSlicerManager->GetSlicer(i)->Render();
}
-
- // Update the TreeWidget
- addStructureSetInTreeWidget(index, mCurrentStructureSet);
}
//------------------------------------------------------------------------------
virtual void InputIsSelected(vvSlicerManager *m);
int addStructureSet(clitk::DicomRT_StructureSet * mStructureSet);
- void addStructureSetInTreeWidget(int index, clitk::DicomRT_StructureSet * s);
+ void updateStructureSetInTreeWidget(int index, clitk::DicomRT_StructureSet * s);
void addRoiInTreeWidget(clitk::DicomRT_ROI * roi, QTreeWidgetItem * w);
public slots:
virtual void apply();
void open(int type);
void LeftButtonReleaseEvent(int slicer);
+ void openBinaryImage();
+ void selectedItemChangedInTree();
protected:
Ui::vvToolStructureSetManager ui;
- void openBinaryImage();
clitk::DicomRT_StructureSet * mCurrentStructureSet;
vvStructureSetActor * mCurrentStructureSetActor;
int mCurrentStructureSetIndex;
vtkLookupTable * mDefaultLUTColor;
-
+
+ void setCurrentSelectedROI(clitk::DicomRT_ROI * roi);
+
std::vector<clitk::DicomRT_StructureSet*> mStructureSetsList;
std::vector<vvStructureSetActor *> mStructureSetActorsList;
- std::map<int, QTreeWidgetItem *> mStructureSetItemsList;
+ std::map<int, QTreeWidgetItem *> mMapStructureSetIndexToTreeWidget;
+ std::map<clitk::DicomRT_ROI*, QTreeWidgetItem *> mMapROIToTreeWidget;
+ std::map<QTreeWidgetItem *, clitk::DicomRT_ROI*> mMapTreeWidgetToROI;
}; // end class vvToolStructureSetManager
//------------------------------------------------------------------------------