25 #include <Base/Common/W32Compat.hh>
26 #include "ImageLegendFrame.hh"
27 #include <Gui/ImageCanvas.hh>
28 #include <Base/Image/ImageConvert.hh>
29 #include <Base/Image/ImageIO.hh>
30 #include <Gui/StringConv.hh>
31 #include <Base/Common/FileHandling.hh>
39 #if !defined(__WXPM__)
40 # include <img/biasviewwx.xpm>
46 wxPoint pos, wxSize size)
47 : wxFrame(parent, -1, title, pos, size,
48 wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN | wxFULL_REPAINT_ON_RESIZE)
50 SetIcon(wxIcon(biasviewwx_xpm));
70 wxToolBar* toolBar =
new wxToolBar(
this, -1);
72 wxSize ticksSize(40,25);
76 wxDefaultPosition, ticksSize,
77 wxSP_ARROW_KEYS, 1, 2000);
78 wxStaticText *tx=
new wxStaticText(toolBar, ID_Static,
AsciiToWx(
"# Ticks: "),wxDefaultPosition);
79 toolBar->AddControl(tx);
84 wxSize sizeSize(60,25);
85 toolBar->AddSeparator();
86 xSpin_=
new wxSpinCtrl(toolBar,ID_X,
AsciiToWx(wi.str()),wxDefaultPosition, sizeSize,
87 wxSP_ARROW_KEYS, 1, 2000);
88 ySpin_=
new wxSpinCtrl(toolBar,ID_Y,
AsciiToWx(he.str()),wxDefaultPosition, sizeSize,
89 wxSP_ARROW_KEYS, 1, 2000);
91 toolBar->AddControl(
new wxStaticText(toolBar, ID_Static,
AsciiToWx(
" Size:" ),wxDefaultPosition));
92 toolBar->AddControl(
xSpin_);
93 toolBar->AddControl(
new wxStaticText(toolBar, ID_Static,
AsciiToWx(
" X "),wxDefaultPosition));
94 toolBar->AddControl(
ySpin_);
95 toolBar->AddControl(
new wxStaticText(toolBar, ID_Static,
AsciiToWx(
" Y" ),wxDefaultPosition));
96 toolBar->AddSeparator();
97 wxButton *saveButton =
new wxButton(toolBar, ID_Save, wxT(
"Save"),wxDefaultPosition,sizeSize);
98 toolBar->AddControl(saveButton);
104 int widths[] = {100, -1};
106 GetStatusBar()->SetStatusWidths(2, widths);
107 GetStatusBar()->SetStatusText(wxT(
"Legend"), 0);
108 GetStatusBar()->Show();
109 SetMinSize(wxSize(400, 470));
110 GetStatusBar()->SetStatusStyles(2, wxSB_NORMAL);
111 GetStatusBar()->SetMinHeight(30);
113 wxBoxSizer *box =
new wxBoxSizer(wxVERTICAL);
115 wxSize size_canvas = wxSize(size.GetWidth()-6,
116 size.GetHeight()-61);
118 wxDefaultPosition, size_canvas);
119 box->Add(window_, 1, wxALL | wxGROW, 3);
142 SetLegendSize(
unsigned width,
unsigned height){
143 vbWidth_ = width; vbHeight_=height;
144 xSpin_->SetValue(vbWidth_);
145 ySpin_->SetValue(vbHeight_);
169 unsigned char min,max;
193 unsigned char minUC,maxUC;
206 wxString message = _T(
"Save legend to");
207 wxString wildcard = _T(
"*.*");
209 wxFileDialog wd(
this,
214 wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
216 if (wxID_OK == wd.ShowModal()) {
241 window_->SetSize(this->GetSize().GetWidth(), this->GetSize().GetHeight()-61);
246 OnTicks(wxSpinEvent& WXUNUSED(event))
260 int x =
xSpin_->GetValue();
261 int y =
ySpin_->GetValue();
void SetValueRange(double min, double max)
void OnClose(wxCloseEvent &event)
void SetDisplayRange(double min, double max)
void OnSize(wxSizeEvent &event)
ImageValueBar< unsigned char > vbUC_
wxString AsciiToWx(const char *thestring)
Converts a C string to a wxString.
bool IsEmpty() const
check if ImageData_ points to allocated image buffer or not
int ScaleShiftBetween(double Min, double Max)
scales and shifts image so afterwards every pixel has a value between Min and Max ...
display image in wx application, provides zoom and investigation functionality
void OnQuit(wxCommandEvent &event)
void OnSave(wxCommandEvent &event)
void GetMinMaxPixelValue(StorageType &min, StorageType &max, unsigned short int channel=0, unsigned int *mincoo=NULL, unsigned int *maxcoo=NULL) const
returns the minimal and maximal pixel value in channel only Finds minimum and maximum pixel value in ...
void SetImage(BIAS::Image< unsigned char > &im)
ImageLegendFrame(wxWindow *parent, const wxString &title, wxPoint pos=wxPoint(10, 10), wxSize size=wxSize(300, 250))
Frame to display a Image legend, for example in biasviewwx.
void SetUnit(std::string unit)
void Clear(const StorageType value=0)
sets all pixels to zero/value
void ReInit(const unsigned int &width, const unsigned int &height, const unsigned int nChannels=1, const enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true, const EColorModel colormodel=CM_Grey)
(Re-)Initialize Image data if required.
static int ConvertST(const BIAS::ImageBase &source, BIAS::ImageBase &dest, ImageBase::EStorageType targetST)
Function to convert the storage type of images e.g.
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
color values, 3 channels, order: red,green,blue
void Setup(wxSize size=wxSize(300, 250))
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
void OnLegendSize(wxSpinEvent &event)
BIAS::ImageCanvas * window_
void SetTicks(int num_ticks)
enum EStorageType GetStorageType() const
(8bit) unsigned char image storage type
virtual void Show(BIAS::Image< unsigned char > &im, std::string name="")
BIAS::Image< unsigned char > * GetImageShown()
void SetColorModel(ImageBase::EColorModel model)
This is the base class for images in BIAS.
void OnTicks(wxSpinEvent &event)