From: Romulo Pinho Date: Wed, 26 Oct 2011 07:28:10 +0000 (+0200) Subject: basic GUI state reading/saving X-Git-Tag: v1.3.0~177 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=0d8fa5142465b40d3796e4347f8411fcbe374d4a;p=clitk.git basic GUI state reading/saving - read/save only images and overlays for now - menu option to read/save state - "--state XMLFILE" to read state from cmd line --- diff --git a/vv/vv.cxx b/vv/vv.cxx index f7b95df..7f640a5 100644 --- a/vv/vv.cxx +++ b/vv/vv.cxx @@ -30,6 +30,7 @@ #include "clitkIO.h" #include "vvMainWindow.h" +#include "vvReadState.h" #include "vvToolsList.h" #include #include @@ -169,7 +170,10 @@ int main( int argc, char** argv ) vtk_log->AppendOn(); vtkOutputWindow::SetInstance(vtk_log); } else if (current == "--state") { - window.ReadSavedStateFile(argv[i+1]); + //window.ReadSavedStateFile(argv[i+1]); + vvReadState read_state; + read_state.Run(&window, argv[i+1]); + n_image_loaded += read_state.GetNumberOfImages(); i++; } diff --git a/vv/vvReadState.cxx b/vv/vvReadState.cxx index 6ad544b..83a7c5e 100644 --- a/vv/vvReadState.cxx +++ b/vv/vvReadState.cxx @@ -11,6 +11,7 @@ vvReadState::vvReadState() : m_XmlReader(new QXmlStreamReader), m_File(new QFile) { + m_NumImages = 0; } vvReadState::~vvReadState() @@ -21,6 +22,7 @@ void vvReadState::Run(vvMainWindow* vvWindow, const std::string& file) { assert(vvWindow); + m_NumImages = 0; m_File->setFileName(file.c_str()); m_File->open(QIODevice::ReadOnly); m_XmlReader->setDevice(m_File.get()); @@ -82,6 +84,9 @@ std::string vvReadState::ReadImage() } } } + + if (!m_XmlReader->hasError()) + m_NumImages++; return value; } diff --git a/vv/vvReadState.h b/vv/vvReadState.h index f729d8c..8d6d560 100644 --- a/vv/vvReadState.h +++ b/vv/vvReadState.h @@ -15,6 +15,7 @@ public: virtual ~vvReadState(); virtual void Run(vvMainWindow* vvWindow, const std::string& file); + int GetNumberOfImages() { return m_NumImages; } protected: @@ -29,6 +30,7 @@ protected: std::auto_ptr m_File; vvMainWindow* m_Window; int m_TreeItemCount; + int m_NumImages; }; #endif // VVREADSTATE_H