]> 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 f7b95df3139c056667d8bb622df95263a4f25e05..7f640a52a0579d660b251643a0357c8a7ad42327 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 6ad544b17f990bb65d134ccc2c3af1ad30e5bcc0..83a7c5e17e4194e4c1474d519f5310da8db55969 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 f729d8c1b0dfd73e2c7cd756e2c57879a5933c34..8d6d5601e0cccd0727a858fd19d774effa83c6d5 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