X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src2%2FcreaImageIOWxGimmickTools.cpp;h=fc978c76c28b9028f54b52c10be9f467ef3b0db3;hb=a67d921cdc10d438852b48c2985f14d91320e016;hp=aebfbbc7104a3bcc76cfe31c26484b2fa0ad5d5e;hpb=152f8d6556de5c935404953ad95e392ae148374d;p=creaImageIO.git diff --git a/src2/creaImageIOWxGimmickTools.cpp b/src2/creaImageIOWxGimmickTools.cpp index aebfbbc..fc978c7 100644 --- a/src2/creaImageIOWxGimmickTools.cpp +++ b/src2/creaImageIOWxGimmickTools.cpp @@ -1,124 +1,99 @@ #include + namespace creaImageIO { /** ** Begin of the threshold panel **/ - WxGimmickTools::WxGimmickTools(wxWindow* parent) - : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN) + WxGimmickTools::WxGimmickTools(wxWindow* parent, wxString mCurrentDirectory) + : wxPanel(parent, -1, wxDefaultPosition, wxSize(300,250), wxBORDER_SUNKEN) { - wxButton *thresholdGoBtn = new wxButton(this,wxID_ANY,_T("Add Fake Color"), wxDefaultPosition, wxSize(200,30) ); - wxButton *thresholdRemoveBtn = new wxButton(this,wxID_ANY,_T("Remove Fake Color"), wxDefaultPosition, wxSize(200,30) ); - _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") ); - _interpolationCheckBox->SetValue(true); - _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); - _thresholdGo = false; - - double range[2]; - interfMainPanel::getInstance()->getImageRange(range); - - int min = (int)floor (range[0]); - int max = (int)ceil (range[1]); - - _mBarThreshold = new mBarRange(this,70,65); - _mBarThreshold->SetMin(0); - _mBarThreshold->SetStart(0); - _mBarThreshold-> SetOrientation( true ); - _mBarThreshold-> setActiveStateTo(true); - _mBarThreshold-> setVisibleLabels( true ); - _mBarThreshold-> setDeviceEndMargin(10); - _mBarThreshold-> setRepresentedValues( min , max ); - _mBarThreshold-> setDeviceBlitStart(10,10); - _mBarThreshold-> setIfWithActualDrawed( false ); - _mBarThreshold-> SetStart( min ); - _mBarThreshold-> SetEnd( max ); - - Connect( thresholdGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxGimmickTools::onThresholdGo ); - Connect( thresholdRemoveBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxGimmickTools::onThresholdRemove ); - Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WxGimmickTools::onThresholdInterpolation ); - - wxFlexGridSizer * sizer = new wxFlexGridSizer(1); - sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold")) , 1, wxGROW ); - sizer -> Add( _mBarThreshold, 1, wxGROW ); - sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); - sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level")) , 1, wxGROW ); - sizer -> Add( _opacity, 1, wxGROW ); - sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); - sizer -> Add( thresholdGoBtn, 1, wxGROW ); - sizer -> Add( thresholdRemoveBtn, 1, wxGROW ); - sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); - sizer -> Add( _interpolationCheckBox, 1, wxGROW ); - - this->SetSizer( sizer ); + _currentDir = mCurrentDirectory; + _addFiles = true; + + _inputPath = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxSize(400,30)); + _outputPath = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxSize(400,30)); + _addCheckBox = new wxCheckBox(this, -1, _T("Add Images to Database?") ); + _addCheckBox->SetValue(_addFiles); + + wxButton *inputDir = new wxButton(this,wxID_ANY,_T("Input Directory"), wxDefaultPosition, wxSize(140,30) ); + wxButton *outputDir = new wxButton(this,wxID_ANY,_T("Output Directory"), wxDefaultPosition, wxSize(140,30) ); + + Connect( inputDir->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxGimmickTools::onInputDir ); + Connect( outputDir->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxGimmickTools::onOutputDir ); + Connect( _addCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WxGimmickTools::onAddToDatabase ); + + wxFlexGridSizer *textSizer = new wxFlexGridSizer(1,2); + textSizer->Add( new wxStaticText(this, -1, _T("Transform a Bruker image into Dicom format.")), 1, wxGROW ); + textSizer->Add( new wxStaticText(this, -1, _T("If checkbox is selected images will be loaded into the DB.")), 1, wxGROW ); + + wxFlexGridSizer *sizer = new wxFlexGridSizer(2,5); + sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW ); + sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW ); + sizer->Add( _inputPath, 1, wxGROW ); + sizer->Add( inputDir, 1, wxGROW ); + sizer->Add( _outputPath, 1, wxGROW ); + sizer->Add( outputDir, 1, wxGROW ); + sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW ); + sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW ); + sizer->Add( _addCheckBox, 1, wxGROW ); + + wxFlexGridSizer *topSizer = new wxFlexGridSizer(1, 2); + topSizer->Add( textSizer, 1, wxGROW ); + topSizer->Add( sizer, 1, wxGROW ); + this->SetSizer( topSizer ); this->SetAutoLayout( true ); this->Layout(); } - WxGimmickTools::~WxGimmickTools(){ - } - - - - void WxGimmickTools::onThresholdChange(wxCommandEvent& event) + WxGimmickTools::~WxGimmickTools() { - if (_thresholdGo) - { - //interfMainPanel::getInstance()->onThresholdChange(); - } + } - void WxGimmickTools::onThresholdGo(wxCommandEvent& event) + wxString WxGimmickTools::getInputDir() { - if (!_thresholdGo) - { - //interfMainPanel::getInstance()->onThreshold(); - _thresholdGo=true; - } + return _inputPath->GetValue(); } - void WxGimmickTools::onThresholdRemove(wxCommandEvent& event) + wxString WxGimmickTools::getOutputDir() { - if (_thresholdGo) - { - //interfMainPanel::getInstance()->onThresholdRemove( ); - _thresholdGo=false; - } + return _outputPath->GetValue(); } - void WxGimmickTools::onThresholdStop() + bool WxGimmickTools::getCheckBoxValue() { - if (_thresholdGo) - { - //interfMainPanel::getInstance()->onThresholdRemove( ); - _thresholdGo=false; - } + return _addCheckBox->GetValue(); } - void WxGimmickTools::onThresholdInstantChange(double range[]) + void WxGimmickTools::onInputDir(wxCommandEvent& event) { - range[0] = _mBarThreshold->GetStart(); - range[1] = _mBarThreshold->GetEnd(); + long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST; + wxDirDialog* FD = new wxDirDialog( 0, _T("Select the Input Directory"), _currentDir, style); + + if (FD->ShowModal()==wxID_OK) + { + _inputPath->SetValue(FD->GetPath()); + } } - void WxGimmickTools::onThresholdInterpolation(wxCommandEvent& event) + void WxGimmickTools::onOutputDir(wxCommandEvent& event) { - //interfMainPanel::getInstance()->onThresholdInterpolation(_interpolationCheckBox->GetValue()); + long style = wxDD_DEFAULT_STYLE; + wxDirDialog* FD = new wxDirDialog( 0, _T("Select the Output Directory"), _currentDir, style); + + if (FD->ShowModal()==wxID_OK) + { + _outputPath->SetValue(FD->GetPath()); + } } - void WxGimmickTools::onChangeOpacity(wxScrollEvent& event) + void WxGimmickTools::onAddToDatabase(wxCommandEvent& event) { - int opacity = _opacity->GetValue(); - //interfMainPanel::getInstance()->onThresholdChangeOpacity(opacity); + _addFiles = _addCheckBox->GetValue(); } - BEGIN_EVENT_TABLE(WxGimmickTools, wxPanel) - EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, WxGimmickTools :: onThresholdChange) - EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_END, WxGimmickTools :: onThresholdChange) - EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_MOVED, WxGimmickTools :: onThresholdChange) - EVT_SCROLL(WxGimmickTools :: onChangeOpacity) - END_EVENT_TABLE() - } // EO namespace creaImageIO