}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+void vvLinkPanel::addLinkFromIds(QString id1, QString id2)
+{
+ int index1 = -1, index2 = -1;
+ size_t s1 = image1Ids.size();
+ size_t s2 = image2Ids.size();
+ for (size_t i = 0; i < s1 && index1 == -1; i++)
+ if (image1Ids[i] == id1.toStdString())
+ index1 = i;
+
+ if (index1 >= 0)
+ image1ComboBox->setCurrentIndex(index1);
+
+ for (size_t i = 0; i < s2 && index2 == -1; i++)
+ if (image2Ids[i] == id2.toStdString())
+ index2 = i;
+
+ if (index1 >= 0 && index2 >= 0) {
+ image2ComboBox->setCurrentIndex(index2);
+ addLink();
+ }
+}
+//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvLinkPanel::addLink()
linkTableWidget->setRowHeight(row,17);
emit addLink(image1Ids[image1ComboBox->currentIndex()].c_str(),
- image2Ids[image2ComboBox->currentIndex()].c_str());
+ image2Ids[image2ComboBox->currentIndex()].c_str(),
+ true
+ );
UpdateComboBox2(image1ComboBox->currentIndex());
}
~vvLinkPanel() {}
void addImage(std::string name, std::string id);
+ void addLinkFromIds(QString id1, QString id2);
void removeImage(int i);
bool isLinkAll();
void linkAll();
signals:
- void addLink(QString image1,QString image2);
+ void addLink(QString image1,QString image2,bool);
void removeLink(QString image1,QString image2);
private:
connect(this,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(ShowContextMenu(QPoint)));
- connect(linkPanel,SIGNAL(addLink(QString,QString)),this,SLOT(AddLink(QString,QString)));
+ connect(linkPanel,SIGNAL(addLink(QString,QString,bool)),this,SLOT(AddLink(QString,QString,bool)));
connect(linkPanel,SIGNAL(removeLink(QString,QString)),this,SLOT(RemoveLink(QString,QString)));
connect(overlayPanel,SIGNAL(VFPropertyUpdated(int,int,int,int,double,double,double)),this,SLOT(SetVFProperty(int,int,int,int,double,double,double)));
connect(overlayPanel,SIGNAL(OverlayPropertyUpdated(int,int,double,double)),
DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
//set the id of the image
- QString id = files[i].c_str() + QString::number(mSlicerManagers.size()-1);
+ QString id = QDir::current().absoluteFilePath(files[i].c_str()) + QString::number(mSlicerManagers.size()-1);
item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
mSlicerManagers.back()->SetId(id.toStdString());
}
//------------------------------------------------------------------------------
-void vvMainWindow::AddLink(QString image1,QString image2)
+void vvMainWindow::AddLink(QString image1,QString image2,bool fromPanel)
{
+ if (!fromPanel) {
+ // delegate to linkPanel if call came from elsewhere...
+ linkPanel->addLinkFromIds(image1, image2);
+ return;
+ }
+
unsigned int sm1 = 0;
unsigned int sm2 = 0;
DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
//set the id of the image
- QString id = slicer_manager->GetFileName().c_str() + QString::number(mSlicerManagers.size()-1);
+ QString id = QDir::current().absoluteFilePath(slicer_manager->GetFileName().c_str()) + QString::number(mSlicerManagers.size()-1);
item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
mSlicerManagers.back()->SetId(id.toStdString());
void ApplyLevelToSetOfImages(double level, unsigned int indexMin, unsigned int indexMax);
void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
void UpdateLinkedNavigation(std::string id, vvSlicerManager *sm, vvSlicer* refSlicer);
- void AddLink(QString image1,QString image2);
+ void AddLink(QString image1,QString image2,bool fromPanel = true);
void RemoveLink(QString image1,QString image2);
void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
{
std::string value;
+ // read images
while (!m_XmlReader->isEndElement() || value != "Images") {
m_XmlReader->readNext();
value = m_XmlReader->qualifiedName().toString().toStdString();
}
}
+ // read links
+ while (!m_XmlReader->isEndElement() || value != "Links") {
+ m_XmlReader->readNext();
+ value = m_XmlReader->qualifiedName().toString().toStdString();
+ if (m_XmlReader->isStartElement()) {
+ if (value == "LinkedFrom") value = ReadLink();
+ }
+ }
+
if (m_XmlReader->hasError())
std::cout << "Error " << m_XmlReader->error() << " XML " << std::endl;
}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+std::string vvReadState::ReadLink()
+{
+ std::string id_from, id_to, value;
+
+ QXmlStreamAttributes attributes = m_XmlReader->attributes();
+ if (!m_XmlReader->hasError()) {
+ id_from = attributes.value("Id").toString().toStdString();
+ }
+
+ while (!m_XmlReader->isEndElement() || value != "LinkedFrom") {
+ m_XmlReader->readNext();
+ value = m_XmlReader->qualifiedName().toString().toStdString();
+ if (m_XmlReader->isStartElement()) {
+ if (value == "LinkedTo") {
+ id_to = m_XmlReader->readElementText().toStdString();
+ if (!m_XmlReader->hasError()) {
+ m_Window->AddLink(id_from.c_str(), id_to.c_str(), false);
+ }
+ }
+ }
+ }
+
+ return value;
+}
+//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvReadState::ReadGUI()
{
std::string ReadFusion(int index);
std::string ReadOverlay(int index);
std::string ReadVector(int index);
+ std::string ReadLink();
std::auto_ptr<QXmlStreamReader> m_XmlReader;
std::auto_ptr<QFile> m_File;
SaveImage(item, i);
}
m_XmlWriter->writeEndElement();
+
+ m_XmlWriter->writeStartElement("Links");
+ for (int i = 0; i < tree->topLevelItemCount(); i++) {
+ const vvSlicerManager * slicerManager = m_Window->GetSlicerManagers()[i];
+ SaveLink(slicerManager);
+ }
+ m_XmlWriter->writeEndElement();
}
//------------------------------------------------------------------------------
}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+void vvSaveState::SaveLink(const vvSlicerManager* vvManager)
+{
+ typedef std::list<std::string> LinkListType;
+ LinkListType links = vvManager->GetLinks();
+ if (!links.empty()) {
+ std::string my_id = vvManager->GetId();
+ m_XmlWriter->writeStartElement("LinkedFrom");
+ m_XmlWriter->writeAttribute("Id", my_id.c_str());
+ typename LinkListType::iterator i;
+ for (i = links.begin(); i != links.end(); i++) {
+ std::string link_id = *i;
+ m_XmlWriter->writeTextElement("LinkedTo", link_id.c_str());
+ }
+ m_XmlWriter->writeEndElement();
+ }
+}
+//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvSaveState::SaveGUI()
void SaveFusion(const QTreeWidgetItem* item, const vvSlicerManager* slicerManager);
void SaveOverlay(const QTreeWidgetItem* item, const vvSlicerManager* slicerManager);
void SaveVector(const QTreeWidgetItem* item);
+ void SaveLink(const vvSlicerManager* slicerManager);
std::auto_ptr<QXmlStreamWriter> m_XmlWriter;
std::auto_ptr<QFile> m_File;
vvImage::Pointer GetVF() { return mVF; }
int GetType() { return mType; }
void SetId(std::string id) { mId = id; }
- std::string GetId() { return mId; }
+ std::string GetId() const { return mId; }
int GetDimension() {
if (mImage) return mImage->GetNumberOfDimensions();
else return -1;
mLinkedId.remove(oldId);
}
+ std::list<std::string> GetLinks() const {
+ return mLinkedId;
+ }
+
bool IsLinked() {
return mLinkedId.size() > 0;
}