/** * \file * \brief ClassThresholdImageViewPanel . */ #include "ColorLayerImageViewPanel.h" #include "OpenImageDialog.h" /** ** Begin of the threshold panel **/ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, int max, int type) : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN) { _colorLayerImageView = new ColorLayerImageView(); _btn_ReadImage = new wxButton(this, wxID_ANY, _T("Read Image") ); _thresholdGo = true; _cb_ShowHide = new wxCheckBox(this, wxID_ANY, _T("Show/Hide layer") ); _cb_ShowHide->SetValue(_thresholdGo); _cb_SliceFixDinamic = new wxCheckBox(this, wxID_ANY, _T("Slice Fix/Dinamic") ); _cb_SliceFixDinamic->SetValue(true); _sl_SliceImage = new wxSlider(this, wxID_ANY, 0, 1000, 1000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); _sl_SliceImage->Enable(false); _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); if (type==0) { } if (type==1) { } Connect( _btn_ReadImage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &ColorLayerImageViewPanel::onReadImage ); Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdShow ); Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdInterpolation ); Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ColorLayerImageViewPanel::onChangeOpacity ); Connect( _cb_SliceFixDinamic->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceFixDinamic ); Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_LINEUP , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_LINEDOWN , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_PAGEUP , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_PAGEDOWN , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); wxFlexGridSizer * sizer = new wxFlexGridSizer(1); if (type==1) { sizer -> Add( new wxStaticText(this,-1,_T("Color Image Layer")) , 1, wxGROW ); sizer -> Add( _btn_ReadImage, 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( _cb_ShowHide, 1, wxGROW ); sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); sizer -> Add( _interpolationCheckBox, 1, wxGROW ); sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); sizer -> Add( new wxStaticText(this,-1,_T("Slice ")) , 1, wxGROW ); sizer -> Add( _sl_SliceImage, 1, wxGROW ); sizer -> Add( _cb_SliceFixDinamic, 1, wxGROW ); this->SetSizer( sizer ); this->SetAutoLayout( true ); this->Layout(); } //---------------------------------------------------------------------------- ColorLayerImageViewPanel::~ColorLayerImageViewPanel() { } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::SetColorLayerImageView(ColorLayerImageView* colorLayerImageView) { _colorLayerImageView = colorLayerImageView; } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event) { // EED ??? // creaImageIO::WxSimpleDlg w(0,_T("Select your image"),"creaContours_Descriptor.dscp","creatisContours DB"); // w.ShowModal(); creaMaracasVisuKernel::OpenImageDialog diag = creaMaracasVisuKernel::OpenImageDialog(); _colorLayerImageView->SetImage( diag.getImageData() ); int ext[6]; diag.getImageData()->GetWholeExtent(ext); _sl_SliceImage->SetRange( 0 , ext[5]-ext[4] ); _colorLayerImageView->onThreshold(); _colorLayerImageView->GetwxVtkBaseView()->Refresh(); } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onThresholdChange(wxCommandEvent& event) { if (_thresholdGo) { _colorLayerImageView->onThresholdChange(); _colorLayerImageView->GetwxVtkBaseView()->Refresh(); //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl; } } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onThresholdShow(wxCommandEvent& event) { _thresholdGo = _cb_ShowHide->GetValue(); if (_thresholdGo) { _colorLayerImageView->onThreshold(); } else { _colorLayerImageView->onThresholdRemove( ); } _colorLayerImageView->GetwxVtkBaseView()->Refresh(); } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onThresholdStop() { if (_thresholdGo) { _colorLayerImageView->onThresholdRemove( ); _thresholdGo=false; } } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onThresholdInterpolation(wxCommandEvent& event) { _colorLayerImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue()); _colorLayerImageView->GetwxVtkBaseView()->Refresh(); } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onSliceFixDinamic(wxCommandEvent& event) { bool fixdin = _cb_SliceFixDinamic->GetValue(); _colorLayerImageView->SetSliceFixDinamic( fixdin ); if (fixdin==false) { _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() ); } _sl_SliceImage->Enable(!fixdin); _colorLayerImageView->onThreshold(); _colorLayerImageView->GetwxVtkBaseView()->Refresh(); } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onSliceImage(wxScrollEvent& event) { _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() ); _colorLayerImageView->onThreshold(); _colorLayerImageView->GetwxVtkBaseView()->Refresh(); } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onChangeOpacity(wxScrollEvent& event) { int opacity = _opacity->GetValue(); _colorLayerImageView->onThresholdChangeOpacity(opacity); _colorLayerImageView->GetwxVtkBaseView()->Refresh(); } //---------------------------------------------------------------------------- bool ColorLayerImageViewPanel::IsVisible() { return _thresholdGo; } // EOF