- BSD See included LICENSE.txt file
- CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-======================================================================-====*/
+ ======================================================================-====*/
+
#ifndef _vvLinkPanel_CXX
#define _vvLinkPanel_CXX
+
#include "vvLinkPanel.h"
#include "clitkCommon.h"
#include <Qt>
#include "QTreePushButton.h"
-//====================================================================
+//------------------------------------------------------------------------------
vvLinkPanel::vvLinkPanel(QWidget * parent):QWidget(parent)
{
- setupUi(this);
- imageNames.resize(0);
- image1Ids.resize(0);
- image2Ids.resize(0);
-
- linkTableWidget->resizeColumnsToContents();
- linkTableWidget->verticalHeader()->hide();
- linkTableWidget->horizontalHeader()->hide();
- linkTableWidget->hideColumn(4);
- linkTableWidget->hideColumn(5);
-
- connect(image1ComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateComboBox2(int)));
- connect(linkButton,SIGNAL(clicked()),this,SLOT(addLink()));
- connect(linkAllButton,SIGNAL(clicked()),this,SLOT(linkAll()));
+ setupUi(this);
+ imageNames.resize(0);
+ image1Ids.resize(0);
+ image2Ids.resize(0);
+
+ linkTableWidget->resizeColumnsToContents();
+ linkTableWidget->verticalHeader()->hide();
+ linkTableWidget->horizontalHeader()->hide();
+ linkTableWidget->hideColumn(4);
+ linkTableWidget->hideColumn(5);
+
+ connect(image1ComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateComboBox2(int)));
+ connect(linkButton,SIGNAL(clicked()),this,SLOT(addLink()));
+ connect(linkAllButton,SIGNAL(clicked()),this,SLOT(linkAll()));
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvLinkPanel::addImage(std::string name, std::string id)
{
- imageNames.push_back(name);
- image1Ids.push_back(id);
- UpdateComboBox1();
+ imageNames.push_back(name);
+ image1Ids.push_back(id);
+ UpdateComboBox1();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvLinkPanel::removeImage(int index)
{
- std::string idRemoved = image1Ids[index];
- std::vector<std::string>::iterator Nameiter = imageNames.begin();
- std::vector<std::string>::iterator Iditer = image1Ids.begin();
- for (int i = 0; i < index; i++)
+ std::string idRemoved = image1Ids[index];
+ std::vector<std::string>::iterator Nameiter = imageNames.begin();
+ std::vector<std::string>::iterator Iditer = image1Ids.begin();
+ for (int i = 0; i < index; i++)
{
- Nameiter++;
- Iditer++;
+ Nameiter++;
+ Iditer++;
}
- imageNames.erase(Nameiter);
- image1Ids.erase(Iditer);
- UpdateComboBox1();
- for (int i = linkTableWidget->rowCount() - 1; i >= 0 ;i--)
+ imageNames.erase(Nameiter);
+ image1Ids.erase(Iditer);
+ UpdateComboBox1();
+ for (int i = linkTableWidget->rowCount() - 1; i >= 0 ;i--)
{
- if (linkTableWidget->item(i,4)->text().toStdString() == idRemoved ||
- linkTableWidget->item(i,5)->text().toStdString() == idRemoved)
+ if (linkTableWidget->item(i,4)->text().toStdString() == idRemoved ||
+ linkTableWidget->item(i,5)->text().toStdString() == idRemoved)
{
- emit removeLink(linkTableWidget->item(i,4)->text(),linkTableWidget->item(i,5)->text());
- linkTableWidget->removeRow(i);
- UpdateComboBox2(image1ComboBox->currentIndex());
+ emit removeLink(linkTableWidget->item(i,4)->text(),linkTableWidget->item(i,5)->text());
+ linkTableWidget->removeRow(i);
+ UpdateComboBox2(image1ComboBox->currentIndex());
}
}
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvLinkPanel::UpdateComboBox1()
{
- image1ComboBox->clear();
- for (unsigned int i = 0; i < imageNames.size();i++)
+ image1ComboBox->clear();
+ for (unsigned int i = 0; i < imageNames.size();i++)
{
- image1ComboBox->addItem(imageNames[i].c_str());
+ image1ComboBox->addItem(imageNames[i].c_str());
}
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvLinkPanel::UpdateComboBox2(int index)
{
- image2ComboBox->clear();
- image2Ids.resize(0);
- if (imageNames.size() > 1 && index >= 0)
+ image2ComboBox->clear();
+ image2Ids.resize(0);
+ if (imageNames.size() > 1 && index >= 0)
{
- for (unsigned int i = 0; i < imageNames.size();i++)
+ for (unsigned int i = 0; i < imageNames.size();i++)
{
- if ((int)i != index)
+ if ((int)i != index)
{
- bool AlreadyLinked = false;
- for (int row = 0; row < linkTableWidget->rowCount();row++)
+ bool AlreadyLinked = false;
+ for (int row = 0; row < linkTableWidget->rowCount();row++)
{
- if ((linkTableWidget->item(row,1)->text().toStdString() == imageNames[index] &&
- linkTableWidget->item(row,3)->text().toStdString() == imageNames[i]) ||
- (linkTableWidget->item(row,3)->text().toStdString() == imageNames[index] &&
- linkTableWidget->item(row,1)->text().toStdString() == imageNames[i]))
+ if ((linkTableWidget->item(row,1)->text().toStdString() == imageNames[index] &&
+ linkTableWidget->item(row,3)->text().toStdString() == imageNames[i]) ||
+ (linkTableWidget->item(row,3)->text().toStdString() == imageNames[index] &&
+ linkTableWidget->item(row,1)->text().toStdString() == imageNames[i]))
{
- AlreadyLinked = true;
- break;
+ AlreadyLinked = true;
+ break;
}
}
- if (!AlreadyLinked)
+ if (!AlreadyLinked)
{
- image2ComboBox->addItem(imageNames[i].c_str());
- image2Ids.push_back(image1Ids[i]);
+ image2ComboBox->addItem(imageNames[i].c_str());
+ image2Ids.push_back(image1Ids[i]);
}
}
}
}
- if (image2ComboBox->count() == 0)
- linkButton->setEnabled(0);
- else
- linkButton->setEnabled(1);
+ if (image2ComboBox->count() == 0)
+ linkButton->setEnabled(0);
+ else
+ linkButton->setEnabled(1);
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvLinkPanel::linkAll()
{
- //First remove all links
- while (linkTableWidget->rowCount())
- removeLink(1,1);
- //Now create all possible links
- int count=image2ComboBox->count();
- for (int j=0;j<count;j++)
+ //First remove all links
+ while (linkTableWidget->rowCount())
+ removeLink(1,1);
+ //Now create all possible links
+ int count=image2ComboBox->count();
+ for (int j=0;j<count;j++)
{
- image1ComboBox->setCurrentIndex(j);
- image2ComboBox->setCurrentIndex(0);
- for (int i=0;i< count-j;i++)
- addLink();
+ image1ComboBox->setCurrentIndex(j);
+ image2ComboBox->setCurrentIndex(0);
+ for (int i=0;i< count-j;i++)
+ addLink();
}
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvLinkPanel::addLink()
{
- if (!image1ComboBox->currentText().isEmpty()
- && !image2ComboBox->currentText().isEmpty())
+ if (!image1ComboBox->currentText().isEmpty()
+ && !image2ComboBox->currentText().isEmpty())
{
- int row = linkTableWidget->rowCount();
- linkTableWidget->insertRow(row);
-
- linkTableWidget->setItem(row,1,new QTableWidgetItem(image1ComboBox->currentText()));
- linkTableWidget->setItem(row,2,new QTableWidgetItem("&"));
- linkTableWidget->setItem(row,3,new QTableWidgetItem(image2ComboBox->currentText()));
- linkTableWidget->setItem(row,4,new QTableWidgetItem(image1Ids[image1ComboBox->currentIndex()].c_str()));
- linkTableWidget->setItem(row,5,new QTableWidgetItem(image2Ids[image2ComboBox->currentIndex()].c_str()));
- QTreePushButton* cButton = new QTreePushButton;
- cButton->setIndex(linkTableWidget->rowCount());
- cButton->setColumn(0);
- cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png")));
- connect(cButton,SIGNAL(clickedInto(int, int)),
- this,SLOT(removeLink(int, int)));
- cButton->setToolTip(tr("remove link"));
- linkTableWidget->setCellWidget(row,0,cButton);
-
- linkTableWidget->resizeColumnToContents(0);
- linkTableWidget->resizeColumnToContents(1);
- linkTableWidget->resizeColumnToContents(2);
- linkTableWidget->resizeColumnToContents(3);
- linkTableWidget->setRowHeight(row,17);
-
- emit addLink(image1Ids[image1ComboBox->currentIndex()].c_str(),
- image2Ids[image2ComboBox->currentIndex()].c_str());
- UpdateComboBox2(image1ComboBox->currentIndex());
+ int row = linkTableWidget->rowCount();
+ linkTableWidget->insertRow(row);
+
+ linkTableWidget->setItem(row,1,new QTableWidgetItem(image1ComboBox->currentText()));
+ linkTableWidget->setItem(row,2,new QTableWidgetItem("&"));
+ linkTableWidget->setItem(row,3,new QTableWidgetItem(image2ComboBox->currentText()));
+ linkTableWidget->setItem(row,4,new QTableWidgetItem(image1Ids[image1ComboBox->currentIndex()].c_str()));
+ linkTableWidget->setItem(row,5,new QTableWidgetItem(image2Ids[image2ComboBox->currentIndex()].c_str()));
+ QTreePushButton* cButton = new QTreePushButton;
+ cButton->setIndex(linkTableWidget->rowCount());
+ cButton->setColumn(0);
+ cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png")));
+ connect(cButton,SIGNAL(clickedInto(int, int)),
+ this,SLOT(removeLink(int, int)));
+ cButton->setToolTip(tr("remove link"));
+ linkTableWidget->setCellWidget(row,0,cButton);
+
+ linkTableWidget->resizeColumnToContents(0);
+ linkTableWidget->resizeColumnToContents(1);
+ linkTableWidget->resizeColumnToContents(2);
+ linkTableWidget->resizeColumnToContents(3);
+ linkTableWidget->setRowHeight(row,17);
+
+ emit addLink(image1Ids[image1ComboBox->currentIndex()].c_str(),
+ image2Ids[image2ComboBox->currentIndex()].c_str());
+ UpdateComboBox2(image1ComboBox->currentIndex());
}
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvLinkPanel::removeLink(int row, int column)
{
- emit removeLink(linkTableWidget->item(row-1,4)->text(),linkTableWidget->item(row-1,5)->text());
- linkTableWidget->removeRow(row-1);
- UpdateComboBox2(image1ComboBox->currentIndex());
+ // DD(row);
+// DD(column);
+ while (linkTableWidget->item(row-1,4) == NULL) {
+ --row;
+ // DD(linkTableWidget->rowCount());
+// DD(row);
+ // return;
+ }
+ if (linkTableWidget->item(row-1,5) == NULL) {
+ return; // should not happend ...
+ }
+
+ emit removeLink(linkTableWidget->item(row-1,4)->text(),linkTableWidget->item(row-1,5)->text());
+ // DD("after emit");
+ linkTableWidget->removeRow(row-1);
+ // DD("after removeRow");
+ UpdateComboBox2(image1ComboBox->currentIndex());
+ // DD("end");
}
+//------------------------------------------------------------------------------
#endif /* end #define _vvLinkPanel_CXX */
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::AddLink(QString image1,QString image2) {
for (unsigned int i = 0; i < mSlicerManagers.size();i++)
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::RemoveLink(QString image1,QString image2) {
+ // DD("vvMainWindow:RemoveLink");
for (unsigned int i = 0; i < mSlicerManagers.size();i++)
{
if (image1.toStdString() == mSlicerManagers[i]->GetId())
//------------------------------------------------------------------------------
void vvMainWindow::NOVerticalSliderChanged() {
- int value = NOVerticalSlider->value();
+ static int value=-1;
+ if (value == NOVerticalSlider->value()) return;
+ else value = NOVerticalSlider->value();
+ // int value = NOVerticalSlider->value();
for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
{
if (DataTree->topLevelItem(i)->data(COLUMN_UL_VIEW,Qt::CheckStateRole).toInt() > 1)
{
- mSlicerManagers[i]->GetSlicer(0)->SetSlice(value);
- mSlicerManagers[i]->VerticalSliderHasChanged(0, value);
- mSlicerManagers[i]->UpdateSlice(0); // <-- DS add this. Not too much update ? YES. but needed for ImageContour ...
- mSlicerManagers[i]->GetSlicer(0)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
+ if (mSlicerManagers[i]->GetSlicer(0)->GetSlice() != value) {
+ mSlicerManagers[i]->GetSlicer(0)->SetSlice(value);
+ mSlicerManagers[i]->VerticalSliderHasChanged(0, value);
+ mSlicerManagers[i]->UpdateSlice(0); // <-- DS add this. Not too much update ? YES. but needed for ImageContour ...
+ //mSlicerManagers[i]->GetSlicer(0)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
+ }
break;
}
}
//------------------------------------------------------------------------------
void vvMainWindow::NEVerticalSliderChanged() {
- int value = NEVerticalSlider->value();
+ static int value=-1;
+ if (value == NEVerticalSlider->value()) return;
+ else value = NEVerticalSlider->value();
+ // int value = NEVerticalSlider->value();
for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
{
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]->UpdateSlice(1);
- mSlicerManagers[i]->GetSlicer(1)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
+ if (mSlicerManagers[i]->GetSlicer(1)->GetSlice() != value) {
+ mSlicerManagers[i]->GetSlicer(1)->SetSlice(value);
+ mSlicerManagers[i]->VerticalSliderHasChanged(1, value);
+ mSlicerManagers[i]->UpdateSlice(1);
+ //mSlicerManagers[i]->GetSlicer(1)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
+ }
break;
}
}
//------------------------------------------------------------------------------
void vvMainWindow::SOVerticalSliderChanged() {
- int value = SOVerticalSlider->value();
+ // DD("SOVerticalSliderChanged");
+ static int value=-1;
+ // DD(value);
+// DD(SOVerticalSlider->value());
+ if (value == SOVerticalSlider->value()) return;
+ else value = SOVerticalSlider->value();
+ //int value = SOVerticalSlider->value();
for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
{
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]->UpdateSlice(2);
- mSlicerManagers[i]->GetSlicer(2)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
+ if (mSlicerManagers[i]->GetSlicer(2)->GetSlice() != value) {
+ mSlicerManagers[i]->GetSlicer(2)->SetSlice(value);
+ mSlicerManagers[i]->VerticalSliderHasChanged(2, value);
+ mSlicerManagers[i]->UpdateSlice(2);
+ //mSlicerManagers[i]->GetSlicer(2)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
+ }
+ // else { DD("avoid SOVerticalSlider slicer update"); }
break;
}
}
//------------------------------------------------------------------------------
void vvMainWindow::SEVerticalSliderChanged() {
- int value = SEVerticalSlider->value();
+ static int value=-1;
+ if (value == SEVerticalSlider->value()) return;
+ else value = SEVerticalSlider->value();
+ // int value = SEVerticalSlider->value();
for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
{
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]->UpdateSlice(3);
- mSlicerManagers[i]->GetSlicer(3)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
+ if (mSlicerManagers[i]->GetSlicer(3)->GetSlice() != value) {
+ mSlicerManagers[i]->GetSlicer(3)->SetSlice(value);
+ mSlicerManagers[i]->VerticalSliderHasChanged(3, value);
+ mSlicerManagers[i]->UpdateSlice(3);
+ //mSlicerManagers[i]->GetSlicer(3)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
+ }
break;
}
}
//------------------------------------------------------------------------------
void vvMainWindow::UpdateSlice(int slicer, int slice) {
+ // DD("vvMainWindow::UpdateSlice");
+// DD(slicer);
+// DD(slice);
if (slicer == 0) {
- if (slice != NOVerticalSlider->value())
- NOVerticalSlider->setValue(slice);
+ // if (slice != NOVerticalSlider->value())
+ NOVerticalSlider->setValue(slice);
}
- else if (slicer == 1)
+ else {
+ if (slicer == 1)
NEVerticalSlider->setValue(slice);
- else if (slicer == 2)
- SOVerticalSlider->setValue(slice);
- else if (slicer == 3)
- SEVerticalSlider->setValue(slice);
+ else {
+ if (slicer == 2)
+ SOVerticalSlider->setValue(slice);
+ else {
+ if (slicer == 3)
+ SEVerticalSlider->setValue(slice);
+ }
+ }
+ }
+ // DD("vvMainWindow:UpdateSlice END");
}
//------------------------------------------------------------------------------