]> Creatis software - clitk.git/blobdiff - vv/vvMainWindow.cxx
bad fix for vvToolCropImage. The seg occurs (also) on the mReducedExtent array
[clitk.git] / vv / vvMainWindow.cxx
index d4c2976dc801beef46843fbf3f1217af8a7c01fa..882e8f121402576e49d4fb52e6df56333dbae0c4 100644 (file)
@@ -22,6 +22,7 @@
 #include <QTimer>
 #include "QTreePushButton.h"
 #include <QUrl>
+#include <QSettings>
 
 // VV include
 #include "vvMainWindow.h"
@@ -251,6 +252,7 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
   connect(actionAdd_VF_to_current_Image,SIGNAL(triggered()),this,SLOT(OpenField()));
   connect(actionNavigation_Help,SIGNAL(triggered()),this,SLOT(ShowHelpDialog()));
   connect(actionDocumentation,SIGNAL(triggered()),this,SLOT(ShowDocumentation()));
+  connect(actionRegister_vv,SIGNAL(triggered()),this,SLOT(PopupRegisterForm()));
 
   ///////////////////////////////////////////////
   connect(actionSegmentation,SIGNAL(triggered()),this,SLOT(SegmentationOnCurrentImage()));
@@ -316,6 +318,7 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
 
   // Adding all new tools (insertion in the menu)
   vvToolManager::GetInstance()->InsertToolsInMenu(this);
+  vvToolManager::GetInstance()->EnableToolsInMenu(this, false);
 
   if (!CLITK_EXPERIMENTAL)
     menuExperimental->menuAction()->setVisible(false);
@@ -327,14 +330,9 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
   timerMemory->start(2000);
 }
 //------------------------------------------------------------------------------
-
 void vvMainWindow::show(){
- vvMainWindowBase::show();
-  vvRegisterForm* registerForm = new vvRegisterForm(QUrl("http://localhost/vvregister/write.php"));
-  if(registerForm->canPush()){
-      registerForm->show();
-      registerForm->acquitPushed();//too bad if there is not internet connection anymore.
-  }
+  vvMainWindowBase::show();
+  PopupRegisterForm(true);
 }
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateMemoryUsage()
@@ -1020,6 +1018,7 @@ void vvMainWindow::ImageInfoChanged()
   actionNorth_West_Window->setEnabled(1);
   actionSouth_East_Window->setEnabled(1);
   actionSouth_West_Window->setEnabled(1);
+  vvToolManager::GetInstance()->EnableToolsInMenu(this, true);
   inverseButton->setEnabled(1);
 
   goToCursorPushButton->setEnabled(1);
@@ -1216,6 +1215,23 @@ void vvMainWindow::ShowDocumentation()
 {
   documentation->show();
 }
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvMainWindow::PopupRegisterForm(bool checkCanPush)
+{
+  vvRegisterForm* registerForm = new vvRegisterForm(QUrl("http://www.creatis.insa-lyon.fr/~dsarrut/vvregister/write.php"), getVVSettingsPath(), getSettingsOptionFormat());
+  if(!checkCanPush){
+    registerForm->show();
+  }else{
+    if(registerForm->canPush()){
+      registerForm->show();
+      registerForm->acquitPushed();//too bad if there is not internet connection anymore.
+    }
+  }
+}
+//------------------------------------------------------------------------------
+
 //------------------------------------------------------------------------------
 void vvMainWindow::ShowHelpDialog()
 {
@@ -1226,41 +1242,38 @@ void vvMainWindow::ShowHelpDialog()
 //------------------------------------------------------------------------------
 void vvMainWindow::ChangeViewMode()
 {
-  QListIterator<int> it0(splitter_3->sizes());
-  QListIterator<int> it1(splitter_3->sizes());
-  int max0 = 0;
-  int max1 = 1;
-  while (it0.hasNext()) {
-    max0 += it0.next();
-  }
-  while (it1.hasNext()) {
-    max1 += it1.next();
-  }
-  QList<int> size0;
-  QList<int> size1;
+  QList<int> size;
   if (viewMode == 1) {
     viewMode = 0;
-    size0.push_back(max0);
-    size0.push_back(0);
-    size1.push_back(max1);
-    size1.push_back(0);
-    splitter_3->setSizes(size0);
-    OSplitter->setSizes(size1);
+    size.push_back(1);
+    size.push_back(0);
+    splitter_3->setSizes(size);
+    OSplitter->setSizes(size);
     DataTree->setColumnHidden(2,1);
     DataTree->setColumnHidden(3,1);
     DataTree->setColumnHidden(4,1);
   } else {
     viewMode = 1;
-    size0.push_back(int(max0/2));
-    size0.push_back(int(max0/2));
-    size1.push_back(int(max1/2));
-    size1.push_back(int(max1/2));
-    splitter_3->setSizes(size0);
-    OSplitter->setSizes(size1);
+    size.push_back(1);
+    size.push_back(1);
+    splitter_3->setSizes(size);
+    OSplitter->setSizes(size);
     DataTree->setColumnHidden(2,0);
     DataTree->setColumnHidden(3,0);
     DataTree->setColumnHidden(4,0);
   }
+  UpdateRenderWindows();
+  /*
+  ** I don't know why but for both resized QVTKWidget we also need to render
+  ** the associated Slicer to redraw crosses.
+  */
+  for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
+  {
+    if (DataTree->topLevelItem(i)->data(COLUMN_UL_VIEW,Qt::CheckStateRole).toInt() > 1)
+      mSlicerManagers[i]->GetSlicer(0)->Render();
+    if (DataTree->topLevelItem(i)->data(COLUMN_DL_VIEW,Qt::CheckStateRole).toInt() > 1)
+      mSlicerManagers[i]->GetSlicer(2)->Render();
+  }
 }
 //------------------------------------------------------------------------------