From b2a15c048423c022085de60356f15ab014f75522 Mon Sep 17 00:00:00 2001 From: Romulo Pinho Date: Thu, 6 Dec 2012 14:01:31 +0100 Subject: [PATCH] added new cmd line option: --landmarks - guess what it does... --- vv/vv.cxx | 7 ++++++- vv/vvLandmarksPanel.cxx | 7 ++++++- vv/vvLandmarksPanel.h | 1 + vv/vvMainWindow.cxx | 13 ++++++++++++- vv/vvMainWindow.h | 3 ++- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/vv/vv.cxx b/vv/vv.cxx index 47057e4..d4ef1ea 100644 --- a/vv/vv.cxx +++ b/vv/vv.cxx @@ -45,7 +45,7 @@ #include #include -typedef enum {O_BASE,O_OVERLAY,O_FUSION,O_VF,O_CONTOUR} OpenModeType; +typedef enum {O_BASE,O_OVERLAY,O_FUSION,O_VF,O_CONTOUR,O_LANDMARKS} OpenModeType; typedef enum {P_NORMAL,P_SEQUENCE,P_WINDOW,P_LEVEL} ParseModeType; void load_image_first_error() @@ -195,6 +195,9 @@ int main( int argc, char** argv ) } else if (current=="--fusion") { if (!n_image_loaded) load_image_first_error(); open_mode = O_FUSION; + } else if (current=="--landmarks") { + if (!n_image_loaded) load_image_first_error(); + open_mode = O_LANDMARKS; } else if (current == "--sequence") { if(open_mode==O_BASE) n_image_loaded++; //count only one for the whole sequence parse_mode=P_SEQUENCE; @@ -273,6 +276,8 @@ int main( int argc, char** argv ) window.AddDCStructContour(n_image_loaded-1,current.c_str()); else if (open_mode==O_FUSION) window.AddFusionImage(n_image_loaded-1,current.c_str()); + else if (open_mode==O_LANDMARKS) + window.AddLandmarks(n_image_loaded-1,current.c_str()); open_mode = O_BASE; } } diff --git a/vv/vvLandmarksPanel.cxx b/vv/vvLandmarksPanel.cxx index 83296ec..46c7c0e 100644 --- a/vv/vvLandmarksPanel.cxx +++ b/vv/vvLandmarksPanel.cxx @@ -48,7 +48,12 @@ void vvLandmarksPanel::Load() QString file = QFileDialog::getOpenFileName(this,tr("Load Landmarks"), mCurrentPath.c_str(),tr("Landmarks ( *.txt *.pts)")); if (!file.isEmpty()) - mCurrentLandmarks->LoadFile(file.toStdString()); + LoadFromFile(file.toStdString()); +} + +void vvLandmarksPanel::LoadFromFile(std::string file) +{ + mCurrentLandmarks->LoadFile(file); SetCurrentLandmarks(mCurrentLandmarks,2); emit UpdateRenderWindows(); } diff --git a/vv/vvLandmarksPanel.h b/vv/vvLandmarksPanel.h index 9966d88..d352a9a 100644 --- a/vv/vvLandmarksPanel.h +++ b/vv/vvLandmarksPanel.h @@ -41,6 +41,7 @@ public: public slots: void Load(); + void LoadFromFile(std::string file); void Save(); void RemoveSelectedPoints(); void AddPoint(); diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 1964b7e..3980ef6 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -2159,7 +2159,18 @@ void vvMainWindow::AddFusionImage(int index, QString file) QMessageBox::information(this,tr("Problem reading Fusion !"),"File doesn't exist!"); } //------------------------------------------------------------------------------ - +//------------------------------------------------------------------------------ +void vvMainWindow::AddLandmarks(int index, QString file) +{ + if (QFile::exists(file)) + { + landmarksPanel->LoadFromFile(file.toStdString()); + landmarksPanel->SetCurrentPath(mInputPathName.toStdString()); + landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str()); + } + else + QMessageBox::information(this,tr("Problem reading Landmarks !"),"File doesn't exist!"); +} //------------------------------------------------------------------------------ void vvMainWindow::OpenField() diff --git a/vv/vvMainWindow.h b/vv/vvMainWindow.h index e308314..efcd6a2 100644 --- a/vv/vvMainWindow.h +++ b/vv/vvMainWindow.h @@ -57,7 +57,8 @@ class vvMainWindow: public vvMainWindowBase, void AddOverlayImage(int index, std::vector fileNames, vvImageReader::LoadedImageType type); void AddFusionImage(int index, QString filename); void AddROI(int index, QString filename); - ///Adds a mesh to a SlicerManager, with optional warping by vector field + void AddLandmarks(int index, QString file); +///Adds a mesh to a SlicerManager, with optional warping by vector field void AddContour(int image_index, vvMesh::Pointer contour, bool propagation); ///This is used to show an image when opened or computed void ShowLastImage(); -- 2.47.1