X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2Fvv.cxx;h=59cacb58911b5bb3ba8d51c18a49d46ae0840fee;hb=ff1d5b8af965e75ecdbc1b0cbff0dad6f3b3c511;hp=71974f1e6124dea74f279b35825a76edf7b369c2;hpb=097d5fd525a35dd8fa4b847ca4f6e1c6541c122c;p=clitk.git diff --git a/vv/vv.cxx b/vv/vv.cxx index 71974f1..59cacb5 100644 --- a/vv/vv.cxx +++ b/vv/vv.cxx @@ -17,22 +17,51 @@ ======================================================================-====*/ #include #include +#include +#include +#include +#include #include #include #include #include #include +#include #include "clitkIO.h" #include "vvMainWindow.h" #include "vvConstants.h" +#include +#include +#include +#include +#include + +#include +#include +#include + void load_image_first_error() { std::cerr << "You need to load an image before adding an overlay!" << std::endl; exit(1); } +std::string create_timed_string() +{ + time_t t; + time(&t); + + struct tm* pt = localtime(&t); + + const int size = 64; + char st[size]; + strftime(st, size, "%Y%m%d-%H%M%S", pt); + + return st; +} + //------------------------------------------------------------------------------ int main( int argc, char** argv ) { @@ -60,9 +89,10 @@ int main( int argc, char** argv ) window.show(); std::vector sequence_filenames; - enum {P_NORMAL,P_SEQUENCE}; + enum {P_NORMAL,P_SEQUENCE,P_WINDOW,P_LEVEL}; int parse_mode=P_NORMAL; int n_image_loaded=0; + std::string win(""), lev(""); if (argc >1) { for (int i = 1; i < argc; i++) { @@ -77,41 +107,74 @@ int main( int argc, char** argv ) if (!n_image_loaded) load_image_first_error(); window.AddField(argv[i+1],n_image_loaded-1); i++; //skip vf name - } - else if (current=="--overlay") { - if (!n_image_loaded) load_image_first_error(); - window.AddOverlayImage(n_image_loaded-1,argv[i+1]); - i++; //skip overlay name - } - else if (current=="--roi") { - if (!n_image_loaded) load_image_first_error(); - window.AddROI(n_image_loaded-1,argv[i+1]); - i++; //skip roi name - } - else if (current=="--fusion") { - if (!n_image_loaded) load_image_first_error(); - window.AddFusionImage(n_image_loaded-1,argv[i+1]); - i++; //skip fusion name - } - else if (current == "--sequence") { + } else if (current=="--overlay") { + if (!n_image_loaded) load_image_first_error(); + window.AddOverlayImage(n_image_loaded-1,argv[i+1]); + i++; //skip overlay name + } else if (current=="--roi") { + if (!n_image_loaded) load_image_first_error(); + window.AddROI(n_image_loaded-1,argv[i+1]); + i++; //skip roi name + } else if (current=="--fusion") { + if (!n_image_loaded) load_image_first_error(); + window.AddFusionImage(n_image_loaded-1,argv[i+1]); + i++; //skip fusion name + } else if (current == "--sequence") { n_image_loaded++; //count only one for the sequence - parse_mode=P_SEQUENCE; } - } - else if (parse_mode == P_SEQUENCE) + parse_mode=P_SEQUENCE; + } else if (current == "--window") { + parse_mode=P_WINDOW; + } else if (current == "--level") { + parse_mode=P_LEVEL; + } else if (current == "--log") { + std::string log_dir = QDir::tempPath().toStdString() + std::string("/vv-log"); + + if(itksys::SystemTools::FileExists(log_dir.c_str()) && + !itksys::SystemTools::FileIsDirectory(log_dir.c_str())) { + itkGenericExceptionMacro(<< "Error creating log directory, file exists and is not a directory."); + } else if(!itksys::SystemTools::MakeDirectory(log_dir.c_str())) { + itkGenericExceptionMacro(<< "Error creating log directory."); + } + + std::string log_file = log_dir + "/" + create_timed_string() + ".log"; + + itk::SmartPointer itk_log = itk::FileOutputWindow::New(); + itk_log->SetFileName(log_file.c_str()); + itk_log->FlushOn(); + itk_log->AppendOn(); + itk::OutputWindow::SetInstance(itk_log); + + vtkSmartPointer vtk_log = vtkFileOutputWindow::New(); + vtk_log->SetFileName(log_file.c_str()); + vtk_log->FlushOn(); + vtk_log->AppendOn(); + vtkOutputWindow::SetInstance(vtk_log); + } + } else if (parse_mode == P_SEQUENCE) { sequence_filenames.push_back(current); - else { - DD(current); - std::vector image; image.push_back(current); + } else if (parse_mode == P_WINDOW) { + win=current; + parse_mode=P_NORMAL; + } else if (parse_mode == P_LEVEL) { + lev=current; + parse_mode=P_NORMAL; + } else { + std::vector image; + image.push_back(current); window.LoadImages(image,IMAGE); n_image_loaded++; } } - if (parse_mode == P_SEQUENCE) {//Finish any current sequence + if (parse_mode == P_SEQUENCE) { //Finish any current sequence window.LoadImages(sequence_filenames,MERGEDWITHTIME); sequence_filenames.clear(); parse_mode=P_NORMAL; } + } + if(win!="" && lev!="") { + window.WindowLevelChanged(atof(win.c_str()), atof(lev.c_str()), 6, 0); + window.ApplyWindowLevelToAllImages(); } return app.exec();