]> Creatis software - clitk.git/blob - vv/vvToolRigidReg.cxx
remove unused file
[clitk.git] / vv / vvToolRigidReg.cxx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18
19 // vv
20 #include "vvToolRigidReg.h"
21 #include "vvImageReader.h"
22 #include "vvSlicer.h"
23
24 // vtk
25 #include <vtkImageData.h>
26 #include <vtkSmartPointer.h>
27 #include <vtkTransform.h>
28
29 // clitk
30 #include "clitkTransformUtilities.h"
31 #include "clitkAffineRegistrationGenericFilter.h"       
32 // qt
33 #include <QMessageBox>
34 #include <QFileDialog>
35 #include <QTextStream>
36 #include <QComboBox>
37 #include <QCursor>
38
39
40 //------------------------------------------------------------------------------
41 // Create the tool and automagically (I like this word) insert it in
42 // the main window menu.
43 ADD_TOOL(vvToolRigidReg);
44 //------------------------------------------------------------------------------
45
46 //------------------------------------------------------------------------------
47 vvToolRigidReg::vvToolRigidReg(vvMainWindowBase * parent, Qt::WindowFlags f):
48     vvToolWidgetBase(parent, f),
49     vvToolBase<vvToolRigidReg>(parent),
50     Ui::vvToolRigidReg()
51 {
52   // GUI Initialization
53   Ui_vvToolRigidReg::setupUi(mToolWidget);
54    // QSize qsize;
55 //    qsize.setHeight(470);
56 //    qsize.setWidth(850);
57 //    mToolWidget->setFixedSize(qsize);
58   // Set how many inputs are needed for this tool
59   mFilter = new clitk::AffineRegistrationGenericFilter;
60   cb_transform->hide();
61   cb_interpolator->hide();
62   cb_optimizer->hide();
63   cb_metric->hide();
64   cb_selectoutput->hide();
65   cb_presets->hide();
66   translabel->hide();
67   metriclabel->hide();
68   outputlabel->hide();
69   optimlabel->hide();
70   interpollabel->hide();
71   presetlabel->hide();
72   
73   
74   // Set how many inputs are needed for this tool
75  AddInputSelector("Select moving image",mFilter);
76  AddInputSelector("Select fixed image",mFilter);
77 }
78 //------------------------------------------------------------------------------
79
80 //------------------------------------------------------------------------------
81 vvToolRigidReg::~vvToolRigidReg()
82 {
83 }
84 //------------------------------------------------------------------------------
85
86 //------------------------------------------------------------------------------
87 bool vvToolRigidReg::close()
88 {
89   ResetTransform();
90   RemoveOverlay();
91   return vvToolWidgetBase::close();
92 }
93 //------------------------------------------------------------------------------
94
95 //------------------------------------------------------------------------------
96 void vvToolRigidReg::reject()
97 {
98
99   return vvToolWidgetBase::reject();
100 }
101 //------------------------------------------------------------------------------
102
103 //------------------------------------------------------------------------------
104 void vvToolRigidReg::GetArgsInfoFromGUI()
105 {   
106   QFont font=QFont("Courier",10);
107   tab2textedit->setTextColor(QColor(255,0,0));
108   tab2textedit->setCurrentFont(font);
109   tab2textedit->update();
110    
111   QString file = QFileDialog::getOpenFileName(
112                     this,
113                     "Locate the Config File",
114                     mMainWindow->GetInputPathName(),
115                     "Text (*.conf *.txt *.rtf *.doc)");
116   
117   if (file.isEmpty())
118   return;
119   
120   QFile Qfile1(file);
121   mConfigFile= file.toStdString();
122   CmdlineParser(1, 1);//1,1 - override, initialize
123   cb_transform->setCurrentIndex(mArgsInfo.transform_arg);
124   cb_interpolator->setCurrentIndex(mArgsInfo.interp_arg);
125   cb_optimizer->setCurrentIndex(mArgsInfo.optimizer_arg);
126   cb_metric->setCurrentIndex(mArgsInfo.metric_arg);
127 }
128 //------------------------------------------------------------------------------
129
130 //------------------------------------------------------------------------------
131 void vvToolRigidReg::Presets()
132 {
133   mConfigFile="Presets";
134   std::string matrixfilename;
135 if(cb_presets->currentIndex()==0)
136 {
137     mArgsInfo.reference_arg=new char;   
138     mArgsInfo.reference_given=0;
139     mArgsInfo.target_arg=new char;       
140     mArgsInfo.target_given=0;
141     mArgsInfo.output_arg=new char;       
142     mArgsInfo.referenceMask_arg=new char;        
143     mArgsInfo.targetMask_arg=new char;   
144     mArgsInfo.initMatrix_arg=new char;   
145     mArgsInfo.matrix_arg=new char;
146     mArgsInfo.referenceMask_given=0;     
147     mArgsInfo.reference_given=0;         
148     mArgsInfo.reference_arg=new char;    
149     mArgsInfo.target_given=0;    
150     mArgsInfo.target_arg=new char;       
151     mArgsInfo.output_given=0;    
152     mArgsInfo.output_arg=new char;       
153     mArgsInfo.checker_after_given=0;     
154     mArgsInfo.checker_before_given=0;    
155     mArgsInfo.after_given=0;     
156     mArgsInfo.before_given=0;    
157     mArgsInfo.threads_given=1;   
158     mArgsInfo.threads_arg=3;     
159     mArgsInfo.normalize_flag=0;          
160     mArgsInfo.blur_arg=0.0;      
161     mArgsInfo.referenceMask_arg=new char;        
162     mArgsInfo.targetMask_arg=new char;   
163     mArgsInfo.targetMask_given=0;        
164     mArgsInfo.levels_given=1;    
165     mArgsInfo.levels_arg=2;      
166     mArgsInfo.moment_flag=1;     
167     mArgsInfo.intThreshold_given=0;      
168     mArgsInfo.intThreshold_arg=0.0;      
169     mArgsInfo.transX_arg=0.0;    
170     mArgsInfo.transY_arg=0.0;    
171     mArgsInfo.transZ_arg=0.0;    
172     mArgsInfo.transform_arg=2;   
173     mArgsInfo.gradient_flag=1;   
174     mArgsInfo.interp_given=1;    
175     mArgsInfo.interp_arg=1;      
176     mArgsInfo.interpOrder_given=1;       
177     mArgsInfo.interpOrder_arg=3;         
178     mArgsInfo.interpSF_given=1;          
179     mArgsInfo.interpSF_arg=20;//default          
180     mArgsInfo.metric_given=1;    
181     mArgsInfo.metric_arg=0;      
182     mArgsInfo.samples_arg=1;//default    
183     mArgsInfo.stdDev_arg=0.4;    
184     mArgsInfo.step_arg=2.0;      
185     mArgsInfo.relax_arg=0.7;     
186     mArgsInfo.valueTol_arg=0.01;         
187     mArgsInfo.stepTol_arg=0.1;   
188     mArgsInfo.gradTol_arg=1e-5;          
189     mArgsInfo.lineAcc_arg=0.9;   
190     mArgsInfo.convFactor_arg=1e+12;      
191     mArgsInfo.maxIt_arg=500;     
192     mArgsInfo.maxLineIt_arg=50;          
193     mArgsInfo.maxEval_arg=500;   
194     mArgsInfo.maxCorr_arg=5;     
195     mArgsInfo.selectBound_arg=0;         
196     mArgsInfo.inc_arg=1.2;       
197     mArgsInfo.dec_arg=4;         
198     mArgsInfo.optimizer_arg=1;   
199     mArgsInfo.initMatrix_given=0;        
200     mArgsInfo.initMatrix_arg=new char;   
201     mArgsInfo.tWeight_given=1;   
202     mArgsInfo.tWeight_arg=1.0;   
203     mArgsInfo.rWeight_given=1.0;         
204     mArgsInfo.rWeight_arg=50.0;          
205     mArgsInfo.matrix_given=1;
206     matrixfilename="/home/bharath/bin/writematrix.txt";//put ur path here for retreiving your matrix
207     mArgsInfo.matrix_arg=const_cast<char*>(matrixfilename.c_str()); 
208     UpdateTextEditor2();
209 }
210 else {
211   QMessageBox::information(this,"Sorry", "Other Presets are not available for the moment!");
212   return;
213  }
214 }
215 //------------------------------------------------------------------------------
216
217 //------------------------------------------------------------------------------
218 void vvToolRigidReg::UpdateTextEditor2()
219 {
220   
221     QString str1,str2,str3;
222     QColor color;
223     tab2textedit->clear();
224     tab2textedit->setAcceptRichText(true);
225     str2=tab2textedit->toPlainText();
226     tab2textedit->setTextColor(QColor(255,0,0));
227     str2.append(str3.append("threads="+str1.setNum(mArgsInfo.threads_arg)));
228     tab2textedit->setText(str2);
229     str3.clear();
230     str1.clear();
231
232     str2=tab2textedit->toPlainText();
233     str2.append("\n");
234     tab2textedit->setText(str2);
235
236     str2=tab2textedit->toPlainText();
237     str2.append(str3.append("reference="+str1.append(mArgsInfo.reference_arg)));
238     tab2textedit->setText(str2);
239     str3.clear();
240     str1.clear();
241
242     str2=tab2textedit->toPlainText();
243     str2.append("\n");
244     tab2textedit->setText(str2);
245     
246     str2=tab2textedit->toPlainText();
247     str2.append(str3.append("target="+str1.append(mArgsInfo.target_arg)));
248     tab2textedit->setText(str2);
249     str3.clear();
250     str1.clear();
251
252     str2=tab2textedit->toPlainText();
253     str2.append("\n");
254     tab2textedit->setText(str2);
255     
256     str2=tab2textedit->toPlainText();
257     str2.append(str3.append("matrix="+str1.append(mArgsInfo.matrix_arg)));
258     tab2textedit->setText(str2);
259     str3.clear();
260     str1.clear();
261
262     str2=tab2textedit->toPlainText();
263     str2.append("\n");
264     tab2textedit->setText(str2);
265     
266     str2=tab2textedit->toPlainText();
267     str2.append(str3.append("interp="+str1.setNum(mArgsInfo.interp_arg)));
268     tab2textedit->setText(str2);
269     str3.clear();
270     str1.clear();
271
272     str2=tab2textedit->toPlainText();
273     str2.append("\n");
274     tab2textedit->setText(str2);
275     
276     str2=tab2textedit->toPlainText();
277     str2.append(str3.append("transform="+str1.setNum(mArgsInfo.transform_arg)));
278     tab2textedit->setText(str2);
279     str3.clear();
280     str1.clear();
281
282     str2=tab2textedit->toPlainText();
283     str2.append("\n");
284     tab2textedit->setText(str2);
285     
286     str2=tab2textedit->toPlainText();
287     str2.append(str3.append("transX="+str1.setNum(mArgsInfo.transX_arg)));
288     tab2textedit->setText(str2);
289     str3.clear();
290     str1.clear();
291
292     str2=tab2textedit->toPlainText();
293     str2.append("\n");
294     tab2textedit->setText(str2);
295     
296     str2=tab2textedit->toPlainText();
297     str2.append(str3.append("transY="+str1.setNum(mArgsInfo.transY_arg)));
298     tab2textedit->setText(str2);
299     str3.clear();
300     str1.clear();
301
302     str2=tab2textedit->toPlainText();
303     str2.append("\n");
304     tab2textedit->setText(str2);
305     
306     str2=tab2textedit->toPlainText();
307     str2.append(str3.append("transZ="+str1.setNum(mArgsInfo.transZ_arg)));
308     tab2textedit->setText(str2);
309     str3.clear();
310     str1.clear();
311
312     str2=tab2textedit->toPlainText();
313     str2.append("\n");
314     tab2textedit->setText(str2);
315     
316     str2=tab2textedit->toPlainText();
317     str2.append(str3.append("metric="+str1.setNum(mArgsInfo.metric_arg)));
318     tab2textedit->setText(str2);
319     str3.clear();
320     str1.clear();
321
322     str2=tab2textedit->toPlainText();
323     str2.append("\n");
324     tab2textedit->setText(str2);
325     
326     str2=tab2textedit->toPlainText();
327     str2.append(str3.append("samples="+str1.setNum(mArgsInfo.samples_arg)));
328     tab2textedit->setText(str2);
329     str3.clear();
330     str1.clear();
331
332     str2=tab2textedit->toPlainText();
333     str2.append("\n");
334     tab2textedit->setText(str2);
335     
336     str2=tab2textedit->toPlainText();
337     str2.append(str3.append("intThreshold="+str1.setNum(mArgsInfo.intThreshold_arg)));
338     tab2textedit->setText(str2);
339     str3.clear();
340     str1.clear();
341
342     str2=tab2textedit->toPlainText();
343     str2.append("\n");
344     tab2textedit->setText(str2);
345     
346     str2=tab2textedit->toPlainText();
347     str2.append(str3.append("stdDev="+str1.setNum(mArgsInfo.stdDev_arg)));
348     tab2textedit->setText(str2);
349     str3.clear();
350     str1.clear();
351
352     str2=tab2textedit->toPlainText();
353     str2.append("\n");
354     tab2textedit->setText(str2);
355     
356     
357     str2=tab2textedit->toPlainText();
358     str2.append(str3.append("blur="+str1.setNum(mArgsInfo.blur_arg)));
359     tab2textedit->setText(str2);
360     str3.clear();
361     str1.clear();
362
363     str2=tab2textedit->toPlainText();
364     str2.append("\n");
365     tab2textedit->setText(str2);
366     
367     
368     str2=tab2textedit->toPlainText();
369     str2.append(str3.append("optimizer="+str1.setNum(mArgsInfo.optimizer_arg)));
370     tab2textedit->setText(str2);
371     str3.clear();
372     str1.clear();
373
374     str2=tab2textedit->toPlainText();
375     str2.append("\n");
376     tab2textedit->setText(str2);
377     
378     
379     str2=tab2textedit->toPlainText();
380     str2.append(str3.append("step="+str1.setNum(mArgsInfo.step_arg)));
381     tab2textedit->setText(str2);
382     str3.clear();
383     str1.clear();
384
385     str2=tab2textedit->toPlainText();
386     str2.append("\n");
387     tab2textedit->setText(str2);
388     
389     
390     str2=tab2textedit->toPlainText();
391     str2.append(str3.append("relax="+str1.setNum(mArgsInfo.relax_arg)));
392     tab2textedit->setText(str2);
393     str3.clear();
394     str1.clear();
395
396     str2=tab2textedit->toPlainText();
397     str2.append("\n");
398     tab2textedit->setText(str2);
399     
400     str2=tab2textedit->toPlainText();
401     str2.append(str3.append("valueTol="+str1.setNum(mArgsInfo.valueTol_arg)));
402     tab2textedit->setText(str2);
403     str3.clear();
404     str1.clear();
405     
406     str2=tab2textedit->toPlainText();
407     str2.append("\n");
408     tab2textedit->setText(str2);
409     
410     str2=tab2textedit->toPlainText();
411     str2.append(str3.append("stepTol="+str1.setNum(mArgsInfo.stepTol_arg)));
412     tab2textedit->setText(str2);
413     str3.clear();
414     str1.clear();
415
416     str2=tab2textedit->toPlainText();
417     str2.append("\n");
418     tab2textedit->setText(str2);
419     
420     
421     str2=tab2textedit->toPlainText();
422     str2.append(str3.append("gradTol="+str1.setNum(mArgsInfo.gradTol_arg)));
423     tab2textedit->setText(str2);
424     str3.clear();
425     str1.clear();
426
427     str2=tab2textedit->toPlainText();
428     str2.append("\n");
429     tab2textedit->setText(str2);
430     
431     str2=tab2textedit->toPlainText();
432     str2.append(str3.append("lineAcc="+str1.setNum(mArgsInfo.lineAcc_arg)));
433     tab2textedit->setText(str2);
434     str3.clear();
435     str1.clear();
436
437     str2=tab2textedit->toPlainText();
438     str2.append("\n");
439     tab2textedit->setText(str2);
440     str2=tab2textedit->toPlainText();
441     str2.append(str3.append("convFactor="+str1.setNum(mArgsInfo.convFactor_arg)));
442     tab2textedit->setText(str2);
443     str3.clear();
444     str1.clear();
445
446     str2=tab2textedit->toPlainText();
447     str2.append("\n");
448     tab2textedit->setText(str2);
449     
450     str2=tab2textedit->toPlainText();
451     str2.append(str3.append("maxIt="+str1.setNum(mArgsInfo.maxIt_arg)));
452     tab2textedit->setText(str2);
453     str3.clear();
454     str1.clear();
455  
456     str2=tab2textedit->toPlainText();
457     str2.append("\n");
458     tab2textedit->setText(str2);
459     
460     str2=tab2textedit->toPlainText();
461     str2.append(str3.append("maxLineIt="+str1.setNum(mArgsInfo.maxLineIt_arg)));
462     tab2textedit->setText(str2);
463     str3.clear();
464     str1.clear();
465
466     str2=tab2textedit->toPlainText();
467     str2.append("\n");
468     tab2textedit->setText(str2);
469     
470     str2=tab2textedit->toPlainText();
471     str2.append(str3.append("maxEval="+str1.setNum(mArgsInfo.maxEval_arg)));
472     tab2textedit->setText(str2);
473     str3.clear();
474     str1.clear();
475
476     str2=tab2textedit->toPlainText();
477     str2.append("\n");
478     tab2textedit->setText(str2);
479     
480       str2=tab2textedit->toPlainText();
481     str2.append(str3.append("maxCorr="+str1.setNum(mArgsInfo.maxCorr_arg)));
482     tab2textedit->setText(str2);
483     str3.clear();
484     str1.clear();
485
486     str2=tab2textedit->toPlainText();
487     str2.append("\n");
488     tab2textedit->setText(str2);
489     
490       str2=tab2textedit->toPlainText();
491     str2.append(str3.append("selectBound="+str1.setNum(mArgsInfo.selectBound_arg)));
492     tab2textedit->setText(str2);
493     str3.clear();
494     str1.clear();
495
496     str2=tab2textedit->toPlainText();
497     str2.append("\n");
498     tab2textedit->setText(str2);
499     
500       str2=tab2textedit->toPlainText();
501     str2.append(str3.append("rWeight="+str1.setNum(mArgsInfo.rWeight_arg)));
502     tab2textedit->setText(str2);
503     str3.clear();
504     str1.clear();
505
506     str2=tab2textedit->toPlainText();
507     str2.append("\n");
508     tab2textedit->setText(str2);
509     
510       str2=tab2textedit->toPlainText();
511     str2.append(str3.append("tWeight="+str1.setNum(mArgsInfo.tWeight_arg)));
512     tab2textedit->setText(str2);
513     str3.clear();
514     str1.clear();
515
516     str2=tab2textedit->toPlainText();
517     str2.append("\n");
518     tab2textedit->setText(str2);
519     
520       str2=tab2textedit->toPlainText();
521     str2.append(str3.append("levels="+str1.setNum(mArgsInfo.levels_arg)));
522     tab2textedit->setText(str2);
523     str3.clear();
524     str1.clear();
525
526     str2=tab2textedit->toPlainText();
527     str2.append("\n");
528     tab2textedit->setText(str2);
529     
530       str2=tab2textedit->toPlainText();
531     str2.append(str3.append("inc="+str1.setNum(mArgsInfo.inc_arg)));
532     tab2textedit->setText(str2);
533     str3.clear();
534     str1.clear();
535
536     str2=tab2textedit->toPlainText();
537     str2.append("\n");
538     tab2textedit->setText(str2);
539     
540       str2=tab2textedit->toPlainText();
541     str2.append(str3.append("dec="+str1.setNum(mArgsInfo.dec_arg)));
542     tab2textedit->setText(str2);
543     str3.clear();
544     str1.clear();
545
546     str2=tab2textedit->toPlainText();
547     str2.append("\n");
548     tab2textedit->setText(str2);
549 }
550 //------------------------------------------------------------------------------
551
552 //------------------------------------------------------------------------------
553 void vvToolRigidReg::TransformSelect()
554 {
555   if(!mConfigFile.empty()){
556    mArgsInfo.transform_arg=cb_transform->currentIndex();
557    UpdateTextEditor2();
558   }
559   else{
560     QMessageBox::information(this,"Warning","Load the Config File First!..");
561   }
562 }
563 //------------------------------------------------------------------------------
564   
565 //------------------------------------------------------------------------------
566 void vvToolRigidReg::CmdlineParser(int override, int initialize)
567 {
568    //0 opened, 1 not opened fine
569    int opened=cmdline_parser_clitkAffineRegistration_configfile(const_cast<char*>(mConfigFile.c_str()),&mArgsInfo,override,initialize,1);
570    DD(opened);
571    mArgsInfo.gradient_flag=1;
572    QString str;
573    //Read the transformation parameters from the  path in the config file(mArgsInfo.matrix_arg) and display it on the TextBox 2
574    ifstream readfile;
575    std::vector<QString> Qstr;
576    
577    if(!opened){
578    readfile.open(mConfigFile.c_str());
579    }
580    else{
581    QMessageBox::information(this,"Warning","Load the Config File First..");
582    }
583    if (readfile.is_open()) 
584    { 
585     while (!readfile.eof())
586       {
587       readfile >> mConfigFile;
588       Qstr.push_back(QString(mConfigFile.c_str()));
589       }
590       readfile.close();
591    }
592     else {
593       QMessageBox::information(this,"Warning","Cannot Open File!");
594       return;
595     }
596      for(unsigned int i=0;i<Qstr.size()-1;i++)
597       {
598     str=tab2textedit->toPlainText();
599     str.append(Qstr.at(i));
600     tab2textedit->setText(str);
601     str.append("\n");
602     tab2textedit->setText(str);
603       }
604 }
605 //------------------------------------------------------------------------------
606
607 //------------------------------------------------------------------------------
608 void vvToolRigidReg::OptimizerSelect()
609 {
610   if(!mConfigFile.empty()){
611   mArgsInfo.optimizer_arg=cb_optimizer->currentIndex();
612   UpdateTextEditor2();
613    }
614   else{
615     QMessageBox::information(this,"Warning","Load the Config File First!..");
616   }
617 }
618 //------------------------------------------------------------------------------
619
620 //------------------------------------------------------------------------------
621 void vvToolRigidReg::InterpolatorSelect()
622 {
623   if(!mConfigFile.empty()){
624   mArgsInfo.interp_arg=cb_interpolator->currentIndex();
625   UpdateTextEditor2();
626    }
627   else{
628     QMessageBox::information(this,"Warning","Load the Config File First!..");
629   }
630 }
631 //------------------------------------------------------------------------------
632
633 //------------------------------------------------------------------------------
634 void vvToolRigidReg::MetricSelect()
635 {
636   if(!mConfigFile.empty()){
637  mArgsInfo.metric_arg=cb_metric->currentIndex();
638  UpdateTextEditor2();
639    }
640   else{
641     QMessageBox::information(this,"Warning","Load the Config File First!..");
642   }
643 }
644 //------------------------------------------------------------------------------
645
646 //------------------------------------------------------------------------------
647 void vvToolRigidReg::OutputSelect()
648 {
649   std::ostringstream osstream;
650   if(!mConfigFile.empty()){
651     if(cb_selectoutput->currentIndex()==0){
652       mArgsInfo.output_given=0;
653       mArgsInfo.checker_after_given=0;
654       mArgsInfo.checker_before_given=0;
655       mArgsInfo.after_given=0;
656       mArgsInfo.before_given=0;
657     }//get transformed output image
658     if(cb_selectoutput->currentIndex()==1){ 
659       mArgsInfo.output_given=0;
660       mArgsInfo.checker_after_given=1;
661       mArgsInfo.checker_before_given=0;
662       mArgsInfo.after_given=0;
663       mArgsInfo.before_given=0;
664     }//get checkered image after reg
665     if(cb_selectoutput->currentIndex()==2){  
666       mArgsInfo.output_given=0;
667       mArgsInfo.checker_after_given=0;
668       mArgsInfo.checker_before_given=1;
669       mArgsInfo.after_given=0;
670       mArgsInfo.before_given=0;
671     }//get checkered  image before reg
672     if(cb_selectoutput->currentIndex()==3){
673       mArgsInfo.output_given=0;
674       mArgsInfo.checker_after_given=0;
675       mArgsInfo.checker_before_given=0;
676       mArgsInfo.after_given=1;
677       mArgsInfo.before_given=0;
678     }//get difference image after reg
679     if(cb_selectoutput->currentIndex()==4){  
680       mArgsInfo.output_given=0;
681       mArgsInfo.checker_after_given=0;
682       mArgsInfo.checker_before_given=0;
683       mArgsInfo.after_given=0;
684       mArgsInfo.before_given=1;
685     }//get difference image before reg
686   }
687   else{
688     QMessageBox::information(this,"Warning","Load the Config File First!..");
689   }
690 }
691 //------------------------------------------------------------------------------
692
693 //------------------------------------------------------------------------------
694 void vvToolRigidReg::SaveTextEdit()
695 {
696      DD(mArgsInfo.transform_arg);
697    QString f1 = QFileDialog::getSaveFileName(this, tr("Save Config File"),
698                                               mMainWindow->GetInputPathName(),
699                                               tr("Text (*.mat *.txt *.doc *.rtf)"));
700    QFile file(f1);                                    
701    if(file.open(QFile::WriteOnly | QFile::Truncate) & !mConfigFile.empty() ){
702    QTextStream stream( &file );
703    stream << tab2textedit->toPlainText();
704      }
705     else
706      {
707       QMessageBox::information(this,"Warning","Nothing to Save!");
708       return;
709      }
710    tab2textedit->clear();
711    DD(mArgsInfo.transform_arg);
712 }
713 //------------------------------------------------------------------------------
714
715 //------------------------------------------------------------------------------
716 void vvToolRigidReg::InputIsSelected(std::vector<vvSlicerManager *> & l)
717 {
718   //inputs
719   mInput1 = l[0];
720   mInput2 = l[1];
721   UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),textEdit_2);
722
723   for(int i =0;i<4;i++)
724   {
725     for(int j=0;j<4;j++)
726     {
727       mInitialMatrix[i*4+j]=mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()->GetElement(i,j);
728     }
729   }
730
731   if(mInput1->GetFileName()==mInput2->GetFileName())
732   {
733     QMessageBox::information(this, "Warning","Your Reference and Target Images are the same");
734   }
735   mTwoInputs = true;
736   SetOverlay(mInput2->GetImage());
737   mImageSize=mInput1->GetImage()->GetSize();
738   SetRotationCenter();
739   SetSliderRanges();
740
741     //connect all sigs to slots
742    connect(resetbutton, SIGNAL(pressed()), this, SLOT(ResetTransform()));
743    connect(tab2loadbutton, SIGNAL(pressed()), this, SLOT(GetArgsInfoFromGUI()));
744    connect(tab2applybutton, SIGNAL(pressed()), this, SLOT(AutoRegister()));
745
746
747    connect(Xval, SIGNAL(editingFinished()), this, SLOT(SetXvalue()));
748    connect(Yval, SIGNAL(editingFinished()), this, SLOT(SetYvalue()));
749    connect(Zval, SIGNAL(editingFinished()), this, SLOT(SetZvalue()));
750
751    connect(xtrans_slider, SIGNAL(valueChanged(int)), this, SLOT(UpdateTransform_sliders()));
752    connect(ytrans_slider, SIGNAL(valueChanged(int)), this, SLOT(UpdateTransform_sliders()));
753    connect(ztrans_slider, SIGNAL(valueChanged(int)), this, SLOT(UpdateTransform_sliders()));
754
755
756    connect(xrot_slider, SIGNAL(valueChanged(int)), this, SLOT(UpdateTransform_sliders()));
757    connect(yrot_slider, SIGNAL(valueChanged(int)), this, SLOT(UpdateTransform_sliders()));
758    connect(zrot_slider, SIGNAL(valueChanged(int)), this, SLOT(UpdateTransform_sliders()));
759
760    connect(xtrans_sb, SIGNAL(valueChanged(double)), this, SLOT(UpdateTransform_sb()));
761    connect(ytrans_sb, SIGNAL(valueChanged(double)), this, SLOT(UpdateTransform_sb()));
762    connect(ztrans_sb, SIGNAL(valueChanged(double)), this, SLOT(UpdateTransform_sb()));
763    connect(xrot_sb, SIGNAL(valueChanged(double)), this, SLOT(UpdateTransform_sb()));
764    connect(yrot_sb, SIGNAL(valueChanged(double)), this, SLOT(UpdateTransform_sb()));
765    connect(zrot_sb, SIGNAL(valueChanged(double)), this, SLOT(UpdateTransform_sb()));
766    
767    connect(loadbutton, SIGNAL(pressed()), this, SLOT(LoadFile()));
768    connect(savebutton, SIGNAL(pressed()), this, SLOT(SaveFile()));
769    
770    connect(checkBox_rigid, SIGNAL(clicked(bool)), this, SLOT(CheckRigidReg()));
771    connect(checkBox_deformable, SIGNAL(clicked(bool)), this, SLOT(CheckDeformableReg()));
772    
773    connect(cb_presets, SIGNAL(activated(int)), this, SLOT(Presets()));
774    connect(cb_transform, SIGNAL(activated(int)), this, SLOT(TransformSelect()));
775    connect(cb_optimizer, SIGNAL(activated(int)), this, SLOT(OptimizerSelect()));
776    connect(cb_interpolator, SIGNAL(activated(int)), this, SLOT(InterpolatorSelect()));
777    connect(cb_metric, SIGNAL(activated(int)), this, SLOT(MetricSelect()));
778    connect(cb_selectoutput, SIGNAL(activated(int)), this, SLOT(OutputSelect()));
779    connect(tab2savebutton, SIGNAL(pressed()), this, SLOT(SaveTextEdit()));
780    
781 }
782 //------------------------------------------------------------------------------
783
784 //------------------------------------------------------------------------------
785 void vvToolRigidReg::apply()
786 {
787   RemoveOverlay();
788 }
789 //------------------------------------------------------------------------------
790
791 //------------------------------------------------------------------------------
792 void vvToolRigidReg::CheckRigidReg()
793 {
794   checkBox_deformable->setChecked(false);
795   cb_transform->show();
796   cb_presets->show();
797   cb_metric->show();
798   cb_interpolator->show();
799   cb_optimizer->show();
800   cb_selectoutput->show();
801   translabel->show();
802   metriclabel->show();
803   outputlabel->show();
804   optimlabel->show();
805   interpollabel->show();
806   presetlabel->show();
807   
808 }
809 //------------------------------------------------------------------------------
810
811 //------------------------------------------------------------------------------
812 void vvToolRigidReg::CheckDeformableReg()
813 {
814   checkBox_rigid->setChecked(false);
815   presetlabel->hide();
816   cb_transform->show();
817   cb_metric->show();
818   cb_interpolator->show();
819   cb_optimizer->show();
820   cb_selectoutput->show();
821   cb_presets->hide();
822   translabel->show();
823   metriclabel->show();
824   outputlabel->show();
825   optimlabel->show();
826   interpollabel->show();
827 }
828 //------------------------------------------------------------------------------
829
830 //------------------------------------------------------------------------------
831 void vvToolRigidReg::SetOverlay(vvImage::Pointer Image)
832 {
833     for (int i =0; i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
834    mCurrentSlicerManager->GetSlicer(i)->SetOverlay(Image);
835    mCurrentSlicerManager->GetSlicer(i)->SetActorVisibility("overlay",0,true);
836    mCurrentSlicerManager->SetColorMap();
837    mCurrentSlicerManager->Render();
838    }
839   }
840 //------------------------------------------------------------------------------
841
842 //------------------------------------------------------------------------------
843 void vvToolRigidReg::RemoveOverlay()
844 {
845    for(int i=0;i<mCurrentSlicerManager->NumberOfSlicers();i++)
846   {
847      mInput1->RemoveActor("overlay",0);
848      mInput1->SetColorMap(0);
849      mInput1->Render();
850      hide();
851   }
852 }
853 //------------------------------------------------------------------------------
854
855 //------------------------------------------------------------------------------
856 void vvToolRigidReg::SetXvalue()
857 {
858   QString xstr = Xval->text();
859 }
860 //------------------------------------------------------------------------------
861
862 //------------------------------------------------------------------------------
863 void vvToolRigidReg::SetYvalue()
864 {
865   QString ystr = Yval->text();
866 }
867 //------------------------------------------------------------------------------
868
869 //------------------------------------------------------------------------------
870 void vvToolRigidReg::SetZvalue()
871 {
872   QString zstr = Zval->text();
873 }
874 //------------------------------------------------------------------------------
875
876 //------------------------------------------------------------------------------
877 void vvToolRigidReg::SetTransform(double tX, double tY, double tZ, double aX, double aY, double aZ,bool update)
878 {
879   vtkSmartPointer<vtkTransform> transform = mInput1->GetImage()->GetTransform();
880   transform->PostMultiply();
881   //Rotations
882   if (aX!=0 || aY!=0 || aZ!=0) {
883     double x, y ,z;
884     x= Xval->text().toDouble();
885     y= Yval->text().toDouble();
886     z= Zval->text().toDouble();
887     transform->Translate(-x,-y,-z);
888     if (aX!=0) transform->RotateX(aX);
889     if (aY!=0) transform->RotateY(aY);
890     if (aZ!=0) transform->RotateZ(aZ);
891     transform->Translate(x,y,z);
892   }
893   //Translations
894   if (tX!=0||tY!=0||tZ!=0)
895     transform->Translate(tX*mInput1->GetImage()->GetSpacing()[0],tY*mInput1->GetImage()->GetSpacing()[1],tZ*mInput1->GetImage()->GetSpacing()[2]);
896 }
897 //------------------------------------------------------------------------------
898
899 //------------------------------------------------------------------------------
900 void vvToolRigidReg::SetTransform(vtkMatrix4x4 *matrix)
901 {
902    vtkSmartPointer<vtkTransform> transform=vtkSmartPointer<vtkTransform>::New();
903     for(int i=0; i<4;i++)
904       for(int j=0;j<4;j++)
905     mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()->SetElement(i,j,matrix->GetElement(i,j));
906     
907     Render();
908 }
909 //------------------------------------------------------------------------------
910
911 //------------------------------------------------------------------------------
912 void vvToolRigidReg::LoadFile()
913 {
914   ReadFile(false);
915 }
916 //------------------------------------------------------------------------------
917   
918 //------------------------------------------------------------------------------
919 void vvToolRigidReg::Render()
920 {
921   for (int i=0; i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
922        mCurrentSlicerManager->GetSlicer(i)->ForceUpdateDisplayExtent();
923        mCurrentSlicerManager->GetSlicer(i)->Render();
924       }
925 }
926 //------------------------------------------------------------------------------
927
928 //------------------------------------------------------------------------------
929   void vvToolRigidReg::UpdateTextEditor(vtkMatrix4x4 *matrix,QTextEdit* textEdit)
930 {
931     QFont font=QFont("Courier",11);
932     textEdit->setCurrentFont(font);
933     textEdit->update();
934
935     QString str1,str2,str3;
936     QColor color;
937     textEdit->clear();
938     textEdit->setAcceptRichText(true);
939     str2=textEdit->toPlainText();
940     str2.append("#Rotation Center(mm): \n#");
941     textEdit->setText(str2);
942
943     str2=textEdit->toPlainText();
944     textEdit->setTextColor(QColor(255,0,0));
945     str2.append(str3.append(Xval->text()));
946     textEdit->setText(str2);
947     str3.clear();
948
949     str2=textEdit->toPlainText();
950     str2.append("\t");
951     textEdit->setText(str2);
952
953     str2=textEdit->toPlainText();
954     str2.append(str3.append(Yval->text()));
955     textEdit->setText(str2);
956     str3.clear();
957
958     str2=textEdit->toPlainText();
959     str2.append("\t");
960     textEdit->setText(str2);
961
962
963     str2=textEdit->toPlainText();
964     str2.append(str3.append(Zval->text()));
965     textEdit->setText(str2);
966
967
968     str2=textEdit->toPlainText();
969     str2.append("\n");
970     textEdit->setText(str2);
971
972
973     str2=textEdit->toPlainText();
974     str2.append("#Transformation Matrix(mm):\n");
975     textEdit->setText(str2);
976     for(int i=0;i<4;i++)
977     {
978     for(int j=0;j<4;j++)
979       {
980     str2=textEdit->toPlainText();
981    // str2.append("\t"+str1.setNum(matrix->Element[i][j]));
982     str2.append(QString("%1\t").arg(str1.setNum(matrix->Element[i][j]),2));
983     textEdit->setText(str2);
984       }
985     str2=textEdit->toPlainText();
986     str2.append("\n");
987     textEdit->setText(str2);
988     }
989     //QString str = QFileDialog::getOpenFileName();
990     textEdit->setTextColor(QColor(255,0,0));
991     textEdit->setFont(QFont("courrier new",12,4,true));
992     textEdit->toPlainText().toAscii();
993
994     str2=textEdit->toPlainText();
995     textEdit->setText(str2);
996 }
997 //------------------------------------------------------------------------------
998
999 //------------------------------------------------------------------------------
1000 void vvToolRigidReg::UpdateTransform_sliders()
1001 {
1002        InitializeSliders(xtrans_slider->value()*mInput1->GetImage()->GetSpacing()[0],
1003                          ytrans_slider->value()*mInput1->GetImage()->GetSpacing()[1],
1004                          ztrans_slider->value()*mInput1->GetImage()->GetSpacing()[2],
1005                         xrot_slider->value(),yrot_slider->value(),zrot_slider->value(),false);
1006         UpdateTransform(true);
1007         Render();
1008 }
1009 //------------------------------------------------------------------------------
1010
1011 //------------------------------------------------------------------------------
1012 void vvToolRigidReg::UpdateTransform_sb()
1013 {
1014    InitializeSliders(xtrans_sb->value(),
1015       ytrans_sb->value(),
1016       ztrans_sb->value(),
1017                         xrot_sb->value(),yrot_sb->value(),zrot_sb->value(),false);
1018       UpdateTransform(false);
1019       Render();
1020 }
1021 //------------------------------------------------------------------------------
1022
1023 //------------------------------------------------------------------------------
1024 void vvToolRigidReg::AutoRegister()
1025
1026     if (!mCurrentSlicerManager) close();
1027     
1028     if(!mConfigFile.empty()){
1029     std::vector<vvImage::Pointer> inputs;
1030     // Input
1031     inputs.push_back(mInput1->GetImage());
1032     inputs.push_back(mInput2->GetImage());
1033     // Check input type
1034     // Main filter
1035     clitk::AffineRegistrationGenericFilter::Pointer filter =
1036     clitk::AffineRegistrationGenericFilter::New();
1037     filter->SetInputVVImages(inputs);
1038     filter->SetArgsInfo(mArgsInfo);
1039     filter->EnableReadOnDisk(false);
1040     filter->Update();
1041     std::ostringstream osstream;
1042     vvImage::Pointer output;
1043     output = filter->GetOutputVVImage();
1044     SetOverlay(output);
1045     
1046     if(!cb_selectoutput->currentIndex()==0){
1047      std::string outputstring;
1048      output = filter->GetOutputVVImages()[1];
1049      if(cb_selectoutput->currentIndex()==1){outputstring="Checkered_after_reg";}
1050      if(cb_selectoutput->currentIndex()==2){outputstring="Checkered_before_reg";}
1051      if(cb_selectoutput->currentIndex()==3){outputstring="Diff_after_reg";}
1052      if(cb_selectoutput->currentIndex()==4){outputstring="Diff_before_reg";}
1053     osstream << outputstring << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd";
1054     AddImage(output,osstream.str());
1055     filter->DeleteLastOutputImage();
1056     }
1057     DD(filter->GetOutputVVImages().capacity());
1058     QApplication::restoreOverrideCursor();
1059     ReadFile(true);
1060     }
1061     else
1062     {
1063       QMessageBox::information(this, "Warning","Load the Config File First!...");
1064       return;
1065     }
1066 }
1067 //------------------------------------------------------------------------------
1068
1069 //------------------------------------------------------------------------------
1070 void vvToolRigidReg::UpdateTransform(bool slider_enabled)
1071 {
1072      vtkSmartPointer<vtkTransform> transform_final=mInput1->GetImage()->GetTransform();
1073      transform_final->SetMatrix(mInitialMatrix);
1074      transform_final->PostMultiply();
1075   //Rotations
1076     double x=0, y=0 ,z=0;
1077     x= Xval->text().toDouble();
1078     y= Yval->text().toDouble();
1079     z= Zval->text().toDouble();
1080     transform_final->Translate(-x,-y,-z);
1081     if(slider_enabled){
1082     transform_final->RotateY(yrot_slider->value());
1083     transform_final->RotateX(xrot_slider->value());
1084     transform_final->RotateZ(zrot_slider->value());
1085     }
1086     else{
1087     transform_final->RotateY(yrot_sb->value());
1088     transform_final->RotateX(xrot_sb->value());
1089     transform_final->RotateZ(zrot_sb->value());
1090     }
1091     transform_final->Translate(x,y,z);
1092     transform_final->PreMultiply();
1093     if(slider_enabled){
1094     transform_final->Translate(xtrans_slider->value()*mInput1->GetImage()->GetSpacing()[0],0,0);
1095     transform_final->Translate(0,ytrans_slider->value()*mInput1->GetImage()->GetSpacing()[1],0);
1096     transform_final->Translate(0,0,ztrans_slider->value()*mInput1->GetImage()->GetSpacing()[2]);
1097     }
1098     else{
1099     transform_final->Translate(xtrans_sb->value(),0,0);
1100     transform_final->Translate(0,ytrans_sb->value(),0);
1101     transform_final->Translate(0,0,ztrans_sb->value());
1102     }
1103     transform_final->Update();
1104     Render();
1105     UpdateTextEditor(transform_final->GetMatrix(),textEdit);
1106 }
1107 //------------------------------------------------------------------------------
1108
1109
1110 //------------------------------------------------------------------------------
1111 void vvToolRigidReg::SaveFile()
1112 {
1113   //Write the Transformation Matrix
1114     QString f1 = QFileDialog::getSaveFileName(this, tr("Save Transformation Matrix File"),
1115                                               mMainWindow->GetInputPathName(),
1116                                               tr("Text (*.mat *.txt *.doc *.rtf)"));
1117     QFile file1(f1);
1118     std::vector<QString> transparameters;
1119     QString line1;
1120
1121     for(int i =0;i<4;i++)
1122       for(int j=0;j<4;j++)
1123     transparameters.push_back(line1.setNum(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()->Element[i][j]));
1124
1125     if (file1.open(QFile::WriteOnly | QFile::Truncate)) {
1126     QTextStream out1(&file1);
1127      for(int i =0;i<4;i++){
1128       for(int j=0;j<4;j++) {
1129       out1<<transparameters[i*4+j]+"\t";
1130       }
1131       out1<<"\n";
1132      }
1133     }
1134      else
1135      {
1136       QMessageBox::information(this,"Warning","Error Reading Parameters");
1137      }
1138 }
1139 //------------------------------------------------------------------------------
1140
1141 //------------------------------------------------------------------------------
1142 void vvToolRigidReg::ReadFile(bool matrix_given)
1143 {
1144    std::string x;
1145    QString center;
1146    double * orientations=new double[3];
1147    double * translations=new double[3];
1148    vtkMatrix4x4 *matrix=vtkMatrix4x4::New();
1149    std::string transfile;
1150    vtkSmartPointer<vtkTransform> transform = mCurrentSlicerManager->GetImage()->GetTransform();
1151    if(!matrix_given)
1152    {
1153    //Open File to read the transformation parameters
1154    QString file1 = QFileDialog::getOpenFileName(
1155                     this,
1156                     "Choose the Transformation Parameters file",
1157                     mMainWindow->GetInputPathName(),
1158                     "Text (*.mat *.txt *.rtf *.doc)");
1159     if (file1.isEmpty())
1160     return;
1161    QFile Qfile1(file1);
1162   // ifstream readfile;
1163    transfile= file1.toStdString();
1164    }
1165    else
1166    {
1167     transfile=mArgsInfo.matrix_arg;
1168     DD(transfile);
1169    }
1170    std::string filename1(transfile);
1171    std::ifstream f1(filename1.c_str());
1172    if(f1.is_open())
1173    {
1174    f1.close();
1175    itk::Matrix<double, 4, 4> itkMat = clitk::ReadMatrix3D(transfile);
1176    for(int j=0; j<4; j++)
1177       for(int i=0; i<4; i++)
1178     matrix->SetElement(i,j,rint(itkMat[i][j]));
1179    }
1180     UpdateTextEditor(matrix,textEdit);
1181     transform->SetMatrix(matrix);
1182     transform->GetOrientation(orientations);
1183     transform->PostMultiply();
1184
1185      //Obtain the Rotation Center , set it to origin
1186     Xval->setText(center.setNum(0));
1187     Yval->setText(center.setNum(0));
1188     Zval->setText(center.setNum(0));
1189
1190     //In the Order or Y X Z //
1191     //now  postmultiply for the rotations
1192     SetTransform(0,0,0,0,0,-rint(orientations[2]),false);
1193     SetTransform(0,0,0,-rint(orientations[0]),0,0,false);
1194     SetTransform(0,0,0,0,-rint(orientations[1]),0,false);
1195
1196     transform->GetPosition(translations);
1197     transform->Identity();
1198
1199     DD(translations[0]/mInput1->GetImage()->GetSpacing()[0]);
1200     DD(translations[1]/mInput1->GetImage()->GetSpacing()[1]);
1201     DD(translations[2]/mInput1->GetImage()->GetSpacing()[2]);
1202     DD(mInput1->GetImage()->GetSpacing()[0]);
1203     DD(mInput1->GetImage()->GetSpacing()[1]);
1204     DD(mInput1->GetImage()->GetSpacing()[2]);
1205     DD(orientations[0]);
1206     DD(orientations[1]);
1207     DD(orientations[2]);
1208       //set the sliders  and spin box values
1209     InitializeSliders(rint(translations[0]),rint(translations[1])
1210     ,rint(translations[2]),rint(orientations[0]),rint(orientations[1]),rint(orientations[2]),true);
1211     SetTransform(matrix);
1212 }
1213 //------------------------------------------------------------------------------
1214
1215 //------------------------------------------------------------------------------
1216 void vvToolRigidReg::ResetTransform()
1217 {
1218   vtkSmartPointer<vtkTransform> transform = mCurrentSlicerManager->GetImage()->GetTransform();
1219   transform->SetMatrix(mInitialMatrix);
1220   transform->Update();
1221   
1222    Render();
1223    SetRotationCenter();
1224    SetSliderRanges();
1225    UpdateTextEditor(transform->GetMatrix(),textEdit);
1226 }
1227 //------------------------------------------------------------------------------
1228
1229 //------------------------------------------------------------------------------
1230 void vvToolRigidReg::SetRotationCenter()
1231 {
1232     //default image rotation center is the center of the image
1233     QString xcord,ycord,zcord;
1234     std::vector<double> imageorigin;
1235     imageorigin=mInput1->GetImage()->GetOrigin();
1236     DD("before bug");
1237     xcord=xcord.setNum(imageorigin[0]+mImageSize[0]*mInput1->GetImage()->GetSpacing()[0]/2, 'g', 3);
1238     ycord=ycord.setNum(imageorigin[1]+mImageSize[1]*mInput1->GetImage()->GetSpacing()[1]/2, 'g', 3);
1239     zcord=zcord.setNum(imageorigin[2]+mImageSize[2]*mInput1->GetImage()->GetSpacing()[2]/2, 'g', 3);
1240
1241     Xval->setText(xcord);
1242     Yval->setText(ycord);
1243     Zval->setText(zcord);
1244     InitializeSliders(0,0,0,0,0,0,true);
1245 }
1246 //------------------------------------------------------------------------------
1247
1248 //------------------------------------------------------------------------------
1249 void vvToolRigidReg::InitializeSliders(double xtrans,double ytrans, double ztrans, double xrot, double yrot, double zrot,bool sliders)
1250 {
1251
1252     xtrans_sb->blockSignals(true);
1253     xtrans_sb->setSingleStep(mInput1->GetImage()->GetSpacing()[0]);
1254     xtrans_sb->setValue(xtrans);
1255     xtrans_sb->blockSignals(false);
1256     ytrans_sb->blockSignals(true);
1257     ytrans_sb->setSingleStep(mInput1->GetImage()->GetSpacing()[1]);
1258     ytrans_sb->setValue(ytrans);
1259     ytrans_sb->blockSignals(false);
1260     ztrans_sb->blockSignals(true);
1261     ztrans_sb->setSingleStep(mInput1->GetImage()->GetSpacing()[2]);
1262     ztrans_sb->setValue(ztrans);
1263     ztrans_sb->blockSignals(false);
1264
1265     if(sliders){
1266     xtrans_slider->blockSignals(true);
1267     xtrans_slider->setValue(rint(xtrans/mInput1->GetImage()->GetSpacing()[0]));
1268     xtrans_slider->blockSignals(false);
1269     ytrans_slider->blockSignals(true);
1270     ytrans_slider->setValue(rint(ytrans/mInput1->GetImage()->GetSpacing()[1]));
1271     ytrans_slider->blockSignals(false);
1272     ztrans_slider->blockSignals(true);
1273     ztrans_slider->setValue(rint(ztrans/mInput1->GetImage()->GetSpacing()[2]));
1274     ztrans_slider->blockSignals(false);
1275     }
1276     xrot_sb->blockSignals(true);
1277     xrot_sb->setValue(xrot);                                                                    
1278     xrot_sb->blockSignals(false);
1279     yrot_sb->blockSignals(true);
1280     yrot_sb->setValue(yrot);
1281     yrot_sb->blockSignals(false);
1282     zrot_sb->blockSignals(true);
1283     zrot_sb->setValue(zrot);
1284     zrot_sb->blockSignals(false);
1285     xrot_slider->blockSignals(true);
1286     xrot_slider->setValue(xrot);
1287     xrot_slider->blockSignals(false);
1288     yrot_slider->blockSignals(true);
1289     yrot_slider->setValue(yrot);
1290     yrot_slider->blockSignals(false);
1291     zrot_slider->blockSignals(true);
1292     zrot_slider->setValue(zrot);
1293     zrot_slider->blockSignals(false);
1294 }
1295 //------------------------------------------------------------------------------
1296
1297 //------------------------------------------------------------------------------
1298 void vvToolRigidReg::SetSliderRanges()
1299 {
1300   xtrans_slider->blockSignals(true);
1301   xtrans_slider->setRange(-2000,2000);
1302   xtrans_slider->blockSignals(false);
1303
1304   ytrans_slider->blockSignals(true);
1305   ytrans_slider->setRange(-2000,2000);
1306   ytrans_slider->blockSignals(false);
1307
1308   ztrans_slider->blockSignals(true);
1309   ztrans_slider->setRange(-2000,2000);
1310   ztrans_slider->blockSignals(false);
1311
1312   xtrans_sb->blockSignals(true);
1313   xtrans_sb->setRange(-2000,2000);
1314   xtrans_sb->setDecimals(3);
1315   xtrans_sb->blockSignals(false);
1316
1317   ytrans_sb->blockSignals(true);
1318   ytrans_sb->setRange(-2000,2000);
1319   ytrans_sb->setDecimals(3);
1320   ytrans_sb->blockSignals(false);
1321
1322   ztrans_sb->blockSignals(true);
1323   ztrans_sb->setRange(-2000,2000);
1324   ztrans_sb->setDecimals(3);
1325   ztrans_sb->blockSignals(false);
1326
1327   xrot_slider->blockSignals(true);
1328   xrot_slider->setRange(-360,360);
1329   xrot_slider->blockSignals(false);
1330
1331   yrot_slider->blockSignals(true);
1332   yrot_slider->setRange(-360,360);
1333   yrot_slider->blockSignals(false);
1334
1335   zrot_slider->blockSignals(true);
1336   zrot_slider->setRange(-360,360);
1337   zrot_slider->blockSignals(false);
1338
1339   xrot_sb->blockSignals(true);
1340   xrot_sb->setRange(-360,360);
1341   xrot_sb->blockSignals(false);
1342
1343   yrot_sb->blockSignals(true);
1344   yrot_sb->setRange(-360,360);
1345   yrot_sb->blockSignals(false);
1346
1347   zrot_sb->blockSignals(true);
1348   zrot_sb->setRange(-360,360);
1349   zrot_sb->blockSignals(false);
1350 }