From: donadio Date: Thu, 7 May 2009 16:58:03 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: EED.02Oct2009~69 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=152f8d6556de5c935404953ad95e392ae148374d;p=creaImageIO.git *** empty log message *** --- diff --git a/src2/creaImageIOWxGimmickTools.cpp b/src2/creaImageIOWxGimmickTools.cpp new file mode 100644 index 0000000..aebfbbc --- /dev/null +++ b/src2/creaImageIOWxGimmickTools.cpp @@ -0,0 +1,124 @@ +#include + +namespace creaImageIO +{ + /** + ** Begin of the threshold panel + **/ + WxGimmickTools::WxGimmickTools(wxWindow* parent) + : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, 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 ); + this->SetAutoLayout( true ); + this->Layout(); + } + + WxGimmickTools::~WxGimmickTools(){ + } + + + + void WxGimmickTools::onThresholdChange(wxCommandEvent& event) + { + if (_thresholdGo) + { + //interfMainPanel::getInstance()->onThresholdChange(); + } + } + + void WxGimmickTools::onThresholdGo(wxCommandEvent& event) + { + if (!_thresholdGo) + { + //interfMainPanel::getInstance()->onThreshold(); + _thresholdGo=true; + } + } + + void WxGimmickTools::onThresholdRemove(wxCommandEvent& event) + { + if (_thresholdGo) + { + //interfMainPanel::getInstance()->onThresholdRemove( ); + _thresholdGo=false; + } + } + + void WxGimmickTools::onThresholdStop() + { + if (_thresholdGo) + { + //interfMainPanel::getInstance()->onThresholdRemove( ); + _thresholdGo=false; + } + } + + void WxGimmickTools::onThresholdInstantChange(double range[]) + { + range[0] = _mBarThreshold->GetStart(); + range[1] = _mBarThreshold->GetEnd(); + } + + void WxGimmickTools::onThresholdInterpolation(wxCommandEvent& event) + { + //interfMainPanel::getInstance()->onThresholdInterpolation(_interpolationCheckBox->GetValue()); + } + + void WxGimmickTools::onChangeOpacity(wxScrollEvent& event) + { + int opacity = _opacity->GetValue(); + //interfMainPanel::getInstance()->onThresholdChangeOpacity(opacity); + } + + 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 + + diff --git a/src2/creaImageIOWxGimmickTools.h b/src2/creaImageIOWxGimmickTools.h new file mode 100644 index 0000000..0cc976a --- /dev/null +++ b/src2/creaImageIOWxGimmickTools.h @@ -0,0 +1,51 @@ +#ifndef __creaImageIOWxGimmickTools_h_INCLUDED__ +#define __creaImageIOWxGimmickTools_h_INCLUDED__ + +#ifdef USE_WXWIDGETS + +#include + +namespace creaImageIO +{ + /** + * \ingroup Tools + */ + //===================================================================== + + //===================================================================== + + class WxGimmickTools : public wxPanel + { + public: + WxGimmickTools(wxWindow * parent); + ~WxGimmickTools(); + + void onThresholdStop(); + void onThresholdInstantChange(double range[]); + + private: + + mBarRange* _mBarThreshold; + wxSlider* _opacity; + bool _thresholdGo; + wxCheckBox* _interpolationCheckBox; + + void onThresholdChange(wxCommandEvent& event); + + void onThresholdGo(wxCommandEvent& event); + + void onThresholdRemove(wxCommandEvent& event); + + void onThresholdInterpolation(wxCommandEvent& event); + + void onChangeOpacity(wxScrollEvent& event); + + DECLARE_EVENT_TABLE() + + }; + +} // EO namespace creaImageIO + +#endif // USE_WIDGETS +// EOF +#endif diff --git a/src2/creaImageIOWxGimmickView.cpp b/src2/creaImageIOWxGimmickView.cpp index 9ece06d..3bae7d8 100644 --- a/src2/creaImageIOWxGimmickView.cpp +++ b/src2/creaImageIOWxGimmickView.cpp @@ -690,10 +690,61 @@ namespace creaImageIO //AndresDonadio void WxGimmickView::OnTools(wxCommandEvent& event) { - wxDialog* dial= new wxDialog (this,-1,"Tools",wxDefaultPosition, wxDefaultSize); - wxBoxSizer *siz = new wxBoxSizer(wxVERTICAL); - dial->SetSizer(siz); - dial->ShowModal(); + wxDialog* dial= new wxDialog (this,-1,"Tools",wxDefaultPosition, wxDefaultSize); + wxBoxSizer *siz = new wxBoxSizer(wxVERTICAL); + + wxButton *inBtn = new wxButton(dial,-1,_T("Input Directory"), wxDefaultPosition, wxSize(200,30) ); + wxButton *outBtn = new wxButton(dial,-1,_T("Output Directory"), wxDefaultPosition, wxSize(200,30) ); + + dial->SetSizer(siz); + dial->ShowModal(); + + /* + mViewer->StopPlayer(); + std::string name = crea::wx2std(mNotebook->GetCurrentPage()->GetName()); + long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST; + wxDirDialog* FD = + new wxDirDialog( 0, + _T("Select directory"), + mCurrentDirectory, + style); + + if (FD->ShowModal()==wxID_OK) + { + + + std::string dirname = wx2std (FD->GetPath()); + bool recurse = isNeedRecursive(dirname); + if (recurse) + { + recurse = wxMessageBox(_T("Recurse into sub-directories ?"), _T("Scan directory"), wxYES_NO,this ) == wxYES ? true : false; + } + + wxBusyCursor busy; + wxString title(_T("Adding directory")); + if (recurse) + title = _T("Adding directory (recursive)"); + mProgressDialog = + new wxProgressDialog(_T("Adding directory"), + _T(""), + 1000, + this, + wxPD_ELAPSED_TIME | + // wxPD_ESTIMATED_TIME | + // wxPD_REMAINING_TIME | + wxPD_CAN_ABORT ); + + mCurrentDirectory = FD->GetPath(); + mGimmick->AddDir(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),dirname,recurse); + mProgressDialog->Pulse(_T("Updating view...")); + + UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1); + delete mProgressDialog; + DisplayAddSummary(); + + } + mViewer->StartPlayer(); + */ } //=================================================