#include "vvImageWriter.h"
#include "vvROIActor.h"
#include "vvSlicer.h"
-#include "vvROIActor.h"
#include "vvMeshReader.h"
#include "vvStructSelector.h"
#include "vvToolManager.h"
QWidget(parent->GetTab()),
vvToolBase<vvToolROIManager>(parent),
Ui::vvToolROIManager()
-{
+{
// Store parent
mMainWindow = parent;
//------------------------------------------------------------------------------
vvToolROIManager::~vvToolROIManager()
-{
+{
mROIActorsList.clear();
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// STATIC
-void vvToolROIManager::Initialize() {
+void vvToolROIManager::Initialize()
+{
SetToolName("ROIManager");
SetToolMenuName("Open ROI (binary image or RT-STRUCT)");
SetToolIconFilename(":/common/icons/tool-roi.png");
//------------------------------------------------------------------------------
void vvToolROIManager::InitializeNewTool(bool ReadStateFlag)
-{
+{
// Check if we need to start a new tool or read in the state file to load
if (ReadStateFlag == false) {
// Select the current image as the target
//------------------------------------------------------------------------------
void vvToolROIManager::InputIsSelected(vvSlicerManager *m)
-{
+{
// Initialization
mCurrentSlicerManager = m;
mCurrentImage = mCurrentSlicerManager->GetImage();
- // Refuse if non 3D image
- if (mCurrentImage->GetNumberOfDimensions() != 3) {
- QMessageBox::information(this,tr("Warning"), tr("Warning 3D ROI on a 4D image will results in some display bugs"));
- //close();
- //return;
- }
-
// Change gui
mLabelInputInfo->setText(QString("%1").arg(m->GetFileName().c_str()));
//------------------------------------------------------------------------------
void vvToolROIManager::AnImageIsBeingClosed(vvSlicerManager * m)
-{
+{
if (m == mCurrentSlicerManager) {
close();
return;
//------------------------------------------------------------------------------
void vvToolROIManager::close()
-{
+{
disconnect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree()));
disconnect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
disconnect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
//------------------------------------------------------------------------------
-void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m) {
-
+void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m)
+{
if (mCurrentSlicerManager == NULL) return;
if (m == NULL) return;
if (m != mCurrentSlicerManager) hide();
//------------------------------------------------------------------------------
void vvToolROIManager::Open()
-{
+{
// Open images
QString Extensions = "Images or Dicom-Struct files ( *.mha *.mhd *.hdr *.his *.dcm RS*)";
Extensions += ";;All Files (*)";
//------------------------------------------------------------------------------
void vvToolROIManager::OpenBinaryImage(QStringList & filename)
-{
+{
if (filename.size() == 0) return;
vvProgressDialog p("Reading ROI ...", true);
//------------------------------------------------------------------------------
void vvToolROIManager::OpenDicomImage(std::string filename)
-{
+{
// GUI selector of roi
vvMeshReader reader;
reader.SetFilename(filename);
std::string name,
std::string filename,
double BG, bool modeBG)
-{
+{
// Check Dimension
int dim = mCurrentImage->GetNumberOfDimensions();
int bin_dim = binaryImage->GetNumberOfDimensions();
// CheckBox for "All"
if (actor->IsVisible()) mNumberOfVisibleROI++;
if (actor->IsContourVisible()) mNumberOfVisibleContourROI++;
-
+ AllVisibleContourROIToggled(true);
+
// Add ROI in tree
mTreeWidgetList.push_back(QSharedPointer<QTreeWidgetItem>(new QTreeWidgetItem(mTree)));
QTreeWidgetItem * w = mTreeWidgetList.back().data();
// Update
UpdateAllROIStatus();
+
+ if (mCurrentImage->GetNumberOfDimensions() != 3) {
+
+ //Modifications to avoid display bug with a 4D image
+ QSharedPointer<vvROIActor> CurrentROIActorTemp;
+ CurrentROIActorTemp = mCurrentROIActor;
+ mCurrentROIActor = actor;
+
+ int VisibleInWindow(0);
+ mCurrentSlicerManager->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,mCurrentSlicerManager->GetSlicer(VisibleInWindow)->GetMaxCurrentTSlice());
+ mCurrentSlicerManager->GetSlicer(VisibleInWindow)->Render();
+
+ VisibleROIToggled(false);
+ VisibleROIToggled(true);
+
+ mCurrentROIActor = CurrentROIActorTemp;
+
+ }
+
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvToolROIManager::UpdateAllContours()
-{
+{
if (mCurrentSlicerManager == NULL) return;
// Render loaded ROIs (the first is sufficient)
for(unsigned int i=0; i<mROIList.size(); i++) {
//------------------------------------------------------------------------------
-void vvToolROIManager::UpdateAllROIStatus() {
+void vvToolROIManager::UpdateAllROIStatus()
+{
int nbVisible = 0;
int nb = mROIList.size();
for(int i=0; i<nb; i++) {
//------------------------------------------------------------------------------
-void vvToolROIManager::SelectedItemChangedInTree() {
+void vvToolROIManager::SelectedItemChangedInTree()
+{
// Search which roi is selected
QList<QTreeWidgetItem *> l = mTree->selectedItems();
if (l.size() == 0) {
//------------------------------------------------------------------------------
-void vvToolROIManager::VisibleROIToggled(bool b) {
+void vvToolROIManager::VisibleROIToggled(bool b)
+{
if (mCurrentROIActor == NULL) return;
if (b == mCurrentROIActor->IsVisible()) return; // nothing to do
mCurrentROIActor->SetVisible(b);
//------------------------------------------------------------------------------
-void vvToolROIManager::VisibleContourROIToggled(bool b) {
+void vvToolROIManager::VisibleContourROIToggled(bool b)
+{
if (mCurrentROIActor == NULL) return;
if (mCurrentROIActor->IsContourVisible() == b) return; // nothing to do
mCurrentROIActor->SetContourVisible(b);
//------------------------------------------------------------------------------
-void vvToolROIManager::OpacityChanged(int v) {
+void vvToolROIManager::OpacityChanged(int v)
+{
if (mCurrentROIActor == NULL) return;
mCurrentROIActor->SetOpacity((double)v/100.0);
mCurrentROIActor->UpdateColor();
//------------------------------------------------------------------------------
-void vvToolROIManager::AllVisibleROIToggled(int b) {
+void vvToolROIManager::AllVisibleROIToggled(int b)
+{
bool status = false;
if ((mCheckBoxShowAll->checkState() == Qt::Checked) ||
(mCheckBoxShowAll->checkState() == Qt::PartiallyChecked)) status = true;
//------------------------------------------------------------------------------
-void vvToolROIManager::AllVisibleContourROIToggled(bool b) {
+void vvToolROIManager::AllVisibleContourROIToggled(bool b)
+{
bool status = false;
if ((mContourCheckBoxShowAll->checkState() == Qt::Checked) ||
(mContourCheckBoxShowAll->checkState() == Qt::PartiallyChecked)) status = true;
//------------------------------------------------------------------------------
-void vvToolROIManager::ChangeColor() {
+void vvToolROIManager::ChangeColor()
+{
if (mCurrentROIActor == NULL) return;
QColor color;
color.setRgbF(mCurrentROIActor->GetROI()->GetDisplayColor()[0],
//------------------------------------------------------------------------------
-void vvToolROIManager::ChangeContourColor() {
+void vvToolROIManager::ChangeContourColor()
+{
if (mCurrentROIActor == NULL) return;
QColor color;
color.setRgbF(mCurrentROIActor->GetContourColor()[0],
//------------------------------------------------------------------------------
-void vvToolROIManager::ChangeContourWidth(int n) {
+void vvToolROIManager::ChangeContourWidth(int n)
+{
if (mCurrentROIActor == NULL) return;
mCurrentROIActor->SetContourWidth(n);
mCurrentROIActor->UpdateColor();
//------------------------------------------------------------------------------
-void vvToolROIManager::ChangeDepth(int n) {
+void vvToolROIManager::ChangeDepth(int n)
+{
if (mCurrentROIActor == NULL) return;
mCurrentROIActor->SetDepth(n);
// mCurrentROIActor->UpdateImage(); // FIXME
//------------------------------------------------------------------------------
-void vvToolROIManager::ReloadCurrentROI() {
+void vvToolROIManager::ReloadCurrentROI()
+{
if (mCurrentROI->GetFilename() == "") {
return; // do nothing (contour from rt struct do not reload)
}
//------------------------------------------------------------------------------
void vvToolROIManager::SaveState(std::auto_ptr<QXmlStreamWriter> & m_XmlWriter)
-{
+{
// Get index of the image
int n = mMainWindow->GetSlicerManagers().size();
int index=-1;
//------------------------------------------------------------------------------
void vvToolROIManager::ReadXMLInformation()
-{
+{
std::string value="";
mInitialImageIndex = -1;
while (!(m_XmlReader->isEndElement() && value == GetToolName().toStdString())) {
//------------------------------------------------------------------------------
void vvToolROIManager::ReadXMLInformation_ROI()
-{
+{
QString s;
std::string value="";
QSharedPointer<vvROIActor> param = QSharedPointer<vvROIActor>(new vvROIActor);