Skip to content
Snippets Groups Projects
Commit 0232d611 authored by Julien Malik's avatar Julien Malik
Browse files

BUG: Corrected the segfault when specifying wrong channel number in viewer

parent 9ecfac01
No related branches found
No related tags found
No related merge requests found
...@@ -759,36 +759,20 @@ ImageViewerManagerViewGUI ...@@ -759,36 +759,20 @@ ImageViewerManagerViewGUI
ImageViewerManagerViewGUI ImageViewerManagerViewGUI
::UpdateViewerSetupWindow(unsigned int selectedItem) ::UpdateViewerSetupWindow(unsigned int selectedItem)
{ {
ImageViewerManagerModelType::ReaderPointerType reader = m_ImageViewerManagerModel->GetObjectList().at(selectedItem-1).pReader; ImageViewerManagerModelType::ReaderPointerType reader = m_ImageViewerManagerModel->GetObjectList().at(selectedItem-1).pReader;
unsigned int nbComponent = reader->GetOutput()->GetNumberOfComponentsPerPixel(); unsigned int nbComponent = reader->GetOutput()->GetNumberOfComponentsPerPixel();
itk::OStringStream oss; // Constrain min and max
oss.str(""); guiGrayscaleChannelChoice->range(1, nbComponent);
//Clear all the choices guiRedChannelChoice->range(1, nbComponent);
guiGrayscaleChannelChoice->clear(); guiGreenChannelChoice->range(1, nbComponent);
guiRedChannelChoice->clear(); guiBlueChannelChoice->range(1, nbComponent);
guiGreenChannelChoice->clear();
guiBlueChannelChoice->clear(); guiRealChannelChoice->range(1, nbComponent);
//guiGrayscaleChannelChoice->clear(); guiImaginaryChannelChoice->range(1, nbComponent);
guiRealChannelChoice->clear();
guiImaginaryChannelChoice->clear();
for (unsigned int i = 0;i<nbComponent;++i)
{
oss.str("");
oss<<i+1;
guiGrayscaleChannelChoice->add(oss.str().c_str());
guiRedChannelChoice->add(oss.str().c_str());
guiGreenChannelChoice->add(oss.str().c_str());
guiBlueChannelChoice->add(oss.str().c_str());
guiGrayscaleChannelChoice->add(oss.str().c_str());
guiRealChannelChoice->add(oss.str().c_str());
guiImaginaryChannelChoice->add(oss.str().c_str());
}
guiViewerSetupWindow->redraw(); guiViewerSetupWindow->redraw();
//guiGrayscaleChannelChoice->redraw();
switch(nbComponent){ switch(nbComponent){
case 1 : case 1 :
...@@ -818,6 +802,8 @@ ImageViewerManagerViewGUI ...@@ -818,6 +802,8 @@ ImageViewerManagerViewGUI
ImageViewerManagerViewGUI ImageViewerManagerViewGUI
::RGBSet() ::RGBSet()
{ {
std::cout << "RGBSet" << std::endl;
unsigned int selectedItem = guiImageList->value(); unsigned int selectedItem = guiImageList->value();
if (selectedItem == 0) if (selectedItem == 0)
{ {
...@@ -845,18 +831,19 @@ ImageViewerManagerViewGUI ...@@ -845,18 +831,19 @@ ImageViewerManagerViewGUI
RenderingFunctionType::Pointer renderingFunction = m_ImageViewerManagerModel->GetObjectList().at(selectedItem-1).pRenderFunction; RenderingFunctionType::Pointer renderingFunction = m_ImageViewerManagerModel->GetObjectList().at(selectedItem-1).pRenderFunction;
// Get the current channel list (may have been already set by the user in case of a re-opening of the viewer)
ChannelListType channels = renderingFunction->GetChannelList(); ChannelListType channels = renderingFunction->GetChannelList();
unsigned int i=0;
unsigned int i = 0;
while (channels.size() < 3) while (channels.size() < 3)
{ {
channels.push_back(i); channels.push_back(i);
++i; ++i;
} }
guiRedChannelChoice->value(std::min(channels[0] + 1,nbComponent));
guiRedChannelChoice->value(std::min(channels[0],nbComponent-1)); guiGreenChannelChoice->value(std::min(channels[1] + 1,nbComponent));
guiGreenChannelChoice->value(std::min(channels[1],nbComponent-1)); guiBlueChannelChoice->value(std::min(channels[2] + 1,nbComponent));
guiBlueChannelChoice->value(std::min(channels[2],nbComponent-1));
} }
...@@ -900,7 +887,7 @@ ImageViewerManagerViewGUI ...@@ -900,7 +887,7 @@ ImageViewerManagerViewGUI
channels.push_back(0); channels.push_back(0);
} }
guiGrayscaleChannelChoice->value(std::min(channels[0],nbComponent-1)); guiGrayscaleChannelChoice->value(std::min(channels[0] + 1,nbComponent));
} }
...@@ -941,8 +928,8 @@ ImageViewerManagerViewGUI ...@@ -941,8 +928,8 @@ ImageViewerManagerViewGUI
++i; ++i;
} }
guiRealChannelChoice->value(std::min(channels[0],nbComponent-1)); guiRealChannelChoice->value(std::min(channels[0] + 1,nbComponent));
guiImaginaryChannelChoice->value(std::min(channels[1],nbComponent-1)); guiImaginaryChannelChoice->value(std::min(channels[1] + 1,nbComponent));
} }
...@@ -968,37 +955,35 @@ ImageViewerManagerViewGUI ...@@ -968,37 +955,35 @@ ImageViewerManagerViewGUI
{ {
unsigned int selectedItem = guiImageList->value(); unsigned int selectedItem = guiImageList->value();
if (selectedItem == 0) if (selectedItem == 0)
{ {
// no image selected, return // no image selected, return
return; return;
} }
if (guiViewerSetupColorMode->value()) if (guiViewerSetupColorMode->value())
{ {
m_ImageViewerManagerController->UpdateRGBChannelOrder(atoi(guiRedChannelChoice->value())-1, int redChoice = static_cast<int>(guiRedChannelChoice->value() - 1);
atoi(guiGreenChannelChoice->value())-1, int greenChoice = static_cast<int>(guiGreenChannelChoice->value() - 1);
atoi(guiBlueChannelChoice->value())-1, int blueChoice = static_cast<int>(guiBlueChannelChoice->value() - 1);
selectedItem); m_ImageViewerManagerController->UpdateRGBChannelOrder(redChoice, greenChoice, blueChoice, selectedItem);
} }
else if (guiViewerSetupGrayscaleMode->value()) else if (guiViewerSetupGrayscaleMode->value())
{ {
m_ImageViewerManagerController->UpdateGrayScaleChannelOrder(atoi(guiGrayscaleChannelChoice->value())-1, int choice = static_cast<int>(guiGrayscaleChannelChoice->value() - 1);
selectedItem); m_ImageViewerManagerController->UpdateGrayScaleChannelOrder(choice, selectedItem);
} }
else if (guiViewerSetupComplexMode->value()) else if (guiViewerSetupComplexMode->value())
{ {
if (bAmplitude->value()) int realChoice = static_cast<int>(guiRealChannelChoice->value() - 1);
{ int imagChoice = static_cast<int>(guiImaginaryChannelChoice->value() - 1);
m_ImageViewerManagerController->UpdateAmplitudeChannelOrder(atoi(guiRealChannelChoice->value())-1, if (bAmplitude->value())
atoi(guiImaginaryChannelChoice->value())-1, {
selectedItem); m_ImageViewerManagerController->UpdateAmplitudeChannelOrder(realChoice, imagChoice, selectedItem);
} }
else else
{ {
m_ImageViewerManagerController->UpdatePhaseChannelOrder(atoi(guiRealChannelChoice->value())-1, m_ImageViewerManagerController->UpdatePhaseChannelOrder(realChoice, imagChoice, selectedItem);
atoi(guiImaginaryChannelChoice->value())-1, }
selectedItem);
}
} }
} }
......
# data file for the Fltk User Interface Designer (fluid) # data file for the Fltk User Interface Designer (fluid)
version 1.0107 version 1.0109
i18n_type 1 i18n_type 1
i18n_include "otbI18n.h" i18n_include "otbI18n.h"
i18n_function otbGetTextMacro i18n_function otbGetTextMacro
header_name {.h} header_name {.h}
code_name {.cxx} code_name {.cxx}
class ImageViewerManagerViewGroup {open class ImageViewerManagerViewGroup {open
} { } {
...@@ -11,8 +11,8 @@ class ImageViewerManagerViewGroup {open ...@@ -11,8 +11,8 @@ class ImageViewerManagerViewGroup {open
} { } {
Fl_Window guiMainWindow { Fl_Window guiMainWindow {
label otbImageViewerManagerView label otbImageViewerManagerView
callback {this->Quit()} open selected callback {this->Quit()} open
xywh {160 106 610 460} type Double box UP_BOX color 52 selection_color 7 labelcolor 187 resizable visible xywh {366 65 610 460} type Double box UP_BOX color 52 selection_color 7 labelcolor 187 resizable visible
} { } {
Fl_Text_Display guiViewerInformation { Fl_Text_Display guiViewerInformation {
label Information label Information
...@@ -102,8 +102,8 @@ class ImageViewerManagerViewGroup {open ...@@ -102,8 +102,8 @@ class ImageViewerManagerViewGroup {open
} }
} }
Fl_Window guiViewerSetupWindow { Fl_Window guiViewerSetupWindow {
label {Viewer setup} label {Viewer setup} open
xywh {885 215 705 230} type Double box UP_BOX color 52 selection_color 7 labelcolor 187 hide xywh {885 215 705 230} type Double box UP_BOX color 52 selection_color 7 labelcolor 187 visible
} { } {
Fl_Round_Button guiViewerSetupGrayscaleMode { Fl_Round_Button guiViewerSetupGrayscaleMode {
label {Grayscale mode} label {Grayscale mode}
...@@ -115,22 +115,22 @@ class ImageViewerManagerViewGroup {open ...@@ -115,22 +115,22 @@ class ImageViewerManagerViewGroup {open
callback {RGBSet();} callback {RGBSet();}
tooltip {Switch the image viewer mode to RGB composition} xywh {460 17 184 24} box ROUND_UP_BOX down_box ROUND_DOWN_BOX color 23 selection_color 22 labelcolor 186 tooltip {Switch the image viewer mode to RGB composition} xywh {460 17 184 24} box ROUND_UP_BOX down_box ROUND_DOWN_BOX color 23 selection_color 22 labelcolor 186
} }
Fl_Input_Choice guiGrayscaleChannelChoice { Fl_Spinner guiGrayscaleChannelChoice {
label {Channel index} open label {Channel index}
tooltip {Select the band to view in grayscale mode} xywh {118 73 57 24} box EMBOSSED_BOX color 7 selection_color 55 labelcolor 187 tooltip {Select the band to view in grayscale mode} xywh {118 73 57 24} box EMBOSSED_BOX color 7 selection_color 55 labelcolor 187 value 1
} {} }
Fl_Input_Choice guiRedChannelChoice { Fl_Spinner guiRedChannelChoice {
label {Red channel} open label {Red channel}
tooltip {Select band for red channel in RGB composition} xywh {602 51 57 24} box EMBOSSED_BOX color 7 selection_color 55 labelcolor 187 deactivate tooltip {Select band for red channel in RGB composition} xywh {602 51 57 24} box EMBOSSED_BOX color 7 selection_color 55 labelcolor 187 value 1 deactivate
} {} }
Fl_Input_Choice guiGreenChannelChoice { Fl_Spinner guiGreenChannelChoice {
label {Green channel} open label {Green channel}
tooltip {Select band for green channel in RGB composition} xywh {602 73 57 24} box EMBOSSED_BOX color 7 selection_color 55 labelcolor 187 deactivate tooltip {Select band for green channel in RGB composition} xywh {602 73 57 24} box EMBOSSED_BOX color 7 selection_color 55 labelcolor 187 value 1 deactivate
} {} }
Fl_Input_Choice guiBlueChannelChoice { Fl_Spinner guiBlueChannelChoice {
label {Blue channel} open label {Blue channel}
tooltip {Select band for blue channel in RGB composition} xywh {602 95 57 24} box EMBOSSED_BOX color 7 selection_color 55 labelcolor 187 deactivate tooltip {Select band for blue channel in RGB composition} xywh {602 95 57 24} box EMBOSSED_BOX color 7 selection_color 55 labelcolor 187 value 1 deactivate
} {} }
Fl_Return_Button guiViewerSetupOk { Fl_Return_Button guiViewerSetupOk {
label Ok label Ok
callback {ViewerSetupOk();} callback {ViewerSetupOk();}
...@@ -150,14 +150,14 @@ class ImageViewerManagerViewGroup {open ...@@ -150,14 +150,14 @@ class ImageViewerManagerViewGroup {open
callback {ComplexSet();} callback {ComplexSet();}
tooltip {Switch the image viewer mode to complex composition} xywh {215 17 210 26} box ROUND_UP_BOX down_box ROUND_DOWN_BOX color 23 selection_color 22 labelcolor 186 tooltip {Switch the image viewer mode to complex composition} xywh {215 17 210 26} box ROUND_UP_BOX down_box ROUND_DOWN_BOX color 23 selection_color 22 labelcolor 186
} }
Fl_Input_Choice guiRealChannelChoice { Fl_Spinner guiRealChannelChoice {
label {Real channel index} open label {Real channel index}
tooltip {Select band for real channel in complex composition} xywh {375 74 57 24} box EMBOSSED_BOX color 7 selection_color 55 labelcolor 187 deactivate tooltip {Select band for real channel in complex composition} xywh {375 74 57 24} box EMBOSSED_BOX color 7 selection_color 55 labelcolor 187 value 1 deactivate
} {} }
Fl_Input_Choice guiImaginaryChannelChoice { Fl_Spinner guiImaginaryChannelChoice {
label {Imaginary channel index} open label {Imaginary channel index}
tooltip {Select band for imaginary channel in complex composition} xywh {375 96 57 24} box EMBOSSED_BOX color 7 selection_color 55 labelcolor 187 deactivate tooltip {Select band for imaginary channel in complex composition} xywh {375 96 57 24} box EMBOSSED_BOX color 7 selection_color 55 labelcolor 187 value 1 deactivate
} {} }
Fl_Round_Button bAmplitude { Fl_Round_Button bAmplitude {
label Amplitude label Amplitude
callback {bPhase->clear();} callback {bPhase->clear();}
...@@ -229,7 +229,7 @@ class ImageViewerManagerViewGroup {open ...@@ -229,7 +229,7 @@ class ImageViewerManagerViewGroup {open
tooltip {Next image in diaporama} xywh {140 55 105 25} box ROUND_UP_BOX down_box ROUND_DOWN_BOX shortcut 0xff56 color 23 selection_color 23 labelcolor 186 tooltip {Next image in diaporama} xywh {140 55 105 25} box ROUND_UP_BOX down_box ROUND_DOWN_BOX shortcut 0xff56 color 23 selection_color 23 labelcolor 186
} }
Fl_Return_Button {} { Fl_Return_Button {} {
label {Quit} label Quit
callback {DiaporamaQuit();} callback {DiaporamaQuit();}
tooltip {Leave diaporama mode} xywh {262 55 105 25} box ROUND_UP_BOX down_box ROUND_DOWN_BOX shortcut 0xff1b color 23 selection_color 23 labelcolor 186 tooltip {Leave diaporama mode} xywh {262 55 105 25} box ROUND_UP_BOX down_box ROUND_DOWN_BOX shortcut 0xff1b color 23 selection_color 23 labelcolor 186
} }
...@@ -286,4 +286,4 @@ class ImageViewerManagerViewGroup {open ...@@ -286,4 +286,4 @@ class ImageViewerManagerViewGroup {open
} {} } {}
Function {PackedViewMode()} {open return_type {virtual void} Function {PackedViewMode()} {open return_type {virtual void}
} {} } {}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment