]> Creatis software - clitk.git/commitdiff
basic GUI state reading/saving
authorRomulo Pinho <pinho@lyon.fnclcc.fr>
Wed, 26 Oct 2011 07:28:10 +0000 (09:28 +0200)
committerRomulo Pinho <pinho@lyon.fnclcc.fr>
Wed, 26 Oct 2011 07:28:10 +0000 (09:28 +0200)
- read/save only images and overlays for now
- menu option to read/save state
- "--state XMLFILE" to read state from cmd line

vv/vv.cxx
vv/vvReadState.cxx
vv/vvReadState.h

index f7b95df..7f640a5 100644 (file)
--- 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 <vtkFileOutputWindow.h>
 #include <vtkSmartPointer.h>
@@ -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++;
         }
         
index 6ad544b..83a7c5e 100644 (file)
@@ -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;
 }
index f729d8c..8d6d560 100644 (file)
@@ -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<QFile> m_File;
   vvMainWindow* m_Window;
   int m_TreeItemCount;
+  int m_NumImages;
 };
 
 #endif // VVREADSTATE_H