Structural deformable models
browser.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * *
3  * database browser *
4  * *
5  ******************************************************************************/
6 //-- fox system setup
7 #include <fx.h>
8 #include <fx3d.h>
9 #include <fxkeys.h>
10 #include <string>
11 #include <iostream>
12 #include <sstream>
13 #include <time.h>
14 #include "fxconfig.h"
15 
16 #include <list>
17 #include "Image.h"
18 #include "Data.h"
19 #include "SpeciesDB.h"
20 #include "Clusterer.h"
21 #include "SensorSet.h"
22 
23 using namespace std;
24 
25 // Patterns
26 const FXchar *patterns[]={
27  "Databases", "*.dat",
28  "All Files", "*",
29 #ifdef LOADIMAGES
30  "GIF Image", "*.gif",
31  "BMP Image", "*.bmp",
32  "XPM Image", "*.xpm",
33  "PCX Image", "*.pcx",
34  "RGB Image", "*.rgb",
35 //#ifdef HAVE_PNG_H
36  "PNG Image", "*.png",
37 //#endif
38 //#ifdef HAVE_JPEG_H
39  "JPEG Image", "*.jpg",
40 //#endif
41  "TARGA Image", "*.tga",
42 //#ifdef HAVE_JPEG_H
43  "TIFF Image", "*.tif",
44 //#endif
45 #endif
46  NULL
47 };
48 
49 /*******************************************************************************/
50 // Event Handler Object
51 class ImageWindow : public FXMainWindow {
52 
53  // Macro for class hierarchy declarations
54  FXDECLARE(ImageWindow)
55 
56  private:
57 
58  FXGLCanvas *glcanvas; // glcanvas
59  FXBMPImage *picture; // Complete picture
60  FXFont *font; // Font for text
61 
62  FXString filename; // File being viewed
63  FXString savefilename; // File for results
64  FXString directory; // Last visited directory
65 
66  Dataset m_Data;
67  Image<byte> m_ScreenImg;
68  SpeciesDB m_DB; // Database of species
69  Species m_CSpecies;
70  float m_Unit;
71  //list<string> m_Records;
72  //list<string>::iterator m_CRec;
73  DBSelector m_Selector;
74 
75  FXGLVisual *glvisual; // Visual for OpenGL
76 
77  float m_XYScale;
78  FXStatusLine *m_Statusline;
79 protected:
80  ImageWindow() : m_Selector(m_DB) {}
81 
82 public:
83 
84  // Message handler
85  long onCanvasRepaint(FXObject*,FXSelector,void*);
86  long onLeftMouseClick(FXObject*,FXSelector,void*);
87  long onRightMouseClick(FXObject*,FXSelector,void*);
88  long onKeyPress(FXObject*,FXSelector,void* ptr);
89  long onKeyRelease(FXObject*,FXSelector,void* ptr);
90  long onCmdRestore(FXObject*,FXSelector,void*);
91  long onLoadImage(FXObject*,FXSelector,void*);
92  long onMouseDown(FXObject*,FXSelector,void*);
93  long onMouseUp(FXObject*,FXSelector,void*);
94  long onMouseMove(FXObject*,FXSelector,void*);
95  long onExpose(FXObject*,FXSelector,void*);
96  long onConfigure(FXObject*,FXSelector,void*);
97  long onCmdOpenGL(FXObject*,FXSelector,void*);
98 
99  // Draw scene
100  void drawScene();
101  void changeSpecies(const Species &s);
102  void setStatusText(const char* msg, bool append=false);
103 
104 public:
105 
106  // Messages for our class
107  enum{
108  ID_CANVAS=FXMainWindow::ID_LAST,
112  ID_LAST
113  };
114 
115 public:
116 
117  // ImageWindow constructor
118  ImageWindow(FXApp* a);
119 
120  // Initialize
121  virtual void create();
122 
123  // Read command line
124  FXbool cmdline(int argc, char ** argv);
125 
126  // ImageWindow destructor
127  virtual ~ImageWindow();
128 
129 };
130 
131 
132 
133 // Message Map
134 FXDEFMAP(ImageWindow) ImageWindowMap[]={
135 
136  //____Message_Type______________ID_______________Message_Handler___
137  //FXMAPFUNC(SEL_PAINT, ImageWindow::ID_CANVAS, ImageWindow::onCanvasRepaint),
138  FXMAPFUNC(SEL_LEFTBUTTONPRESS, ImageWindow::ID_CANVAS, ImageWindow::onLeftMouseClick),
139  FXMAPFUNC(SEL_RIGHTBUTTONPRESS, ImageWindow::ID_CANVAS, ImageWindow::onRightMouseClick),
140  FXMAPFUNC(SEL_KEYPRESS,0,ImageWindow::onKeyPress),
141  //FXMAPFUNC(SEL_KEYRELEASE,0,ImageWindow::onKeyRelease),
142  FXMAPFUNC(SEL_COMMAND, ImageWindow::ID_LOAD, ImageWindow::onLoadImage),
143  FXMAPFUNC(SEL_PAINT, ImageWindow::ID_CANVAS, ImageWindow::onExpose),
144  FXMAPFUNC(SEL_CONFIGURE, ImageWindow::ID_CANVAS, ImageWindow::onConfigure),
145  FXMAPFUNC(SEL_COMMAND, ImageWindow::ID_OPENGL, ImageWindow::onCmdOpenGL),
146 };
147 
148 
149 
150 // Macro for the App class hierarchy implementation
151 FXIMPLEMENT(ImageWindow,FXMainWindow,ImageWindowMap,ARRAYNUMBER(ImageWindowMap))
152 
153 
154 bool setTitle(const char* title) {
155  return false;
156  ImageWindow *mw = dynamic_cast<ImageWindow*>
157  (FXApp::instance()->getMainWindow());
158  if(mw) {
159  mw->setTitle(title);
160  return true;
161  } else return false;
162 }
163 
164 bool setStatusText(const char* stext) {
165  return false;
166  ImageWindow *mw = dynamic_cast<ImageWindow*>
167  (FXApp::instance()->getMainWindow());
168  if(mw) {
169  mw->setStatusText(stext);
170  return true;
171  } else return false;
172 }
173 
174 // Construct ImageWindow
175 ImageWindow::ImageWindow(FXApp* a):FXMainWindow(a,"Deformable Model Segmentation",NULL,NULL,DECOR_ALL,0,0,800,600), m_Selector(m_DB) {
176  FXVerticalFrame *canvasFrame;
177  FXVerticalFrame *buttonFrame;
178  FXHorizontalFrame *contents;
179 
180  contents=new FXHorizontalFrame(this,LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0, 0,0,0,0);
181 
182  canvasFrame=new FXVerticalFrame(contents,FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT,0,0,0,0,10,10,10,10);
183 
184  // A Visual to drag OpenGL
185  glvisual=new FXGLVisual(getApp(),VISUAL_DOUBLEBUFFER);
186 
187  // Drawing glcanvas
188  glcanvas=new FXGLCanvas(canvasFrame,glvisual,this,ID_CANVAS,LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT);
189 
190  // RIGHT pane for the buttons
191  buttonFrame=new FXVerticalFrame(contents,FRAME_SUNKEN|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT,0,0,0,0,10,10,10,10);
192 
193  new FXButton(buttonFrame,"L&oad Image\tSelect Image to load",NULL, this, ID_LOAD,FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|LAYOUT_TOP|LAYOUT_LEFT,0,0,0,0,10,10,5,5);
194 // new FXButton(buttonFrame,"&Process\tPerform some wicked image processsing",NULL,
195 // this, ID_PROCESS,
196 // FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|LAYOUT_TOP|LAYOUT_LEFT,
197 // 0,0,0,0,10,10,5,5);
198 
199  // Exit button
200  new FXButton(buttonFrame,"E&xit\tQuit ImageApp",NULL,getApp(),FXApp::ID_QUIT,FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|LAYOUT_TOP|LAYOUT_LEFT,0,0,0,0,10,10,5,5);
201  FXStatusbar *sbar = new FXStatusbar(canvasFrame,LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X);
202  m_Statusline = sbar->getStatusline();
203 
204  // Result image*/
205  picture=new FXBMPImage(getApp(),"test.rgb",IMAGE_SHMI|IMAGE_SHMP,850,600);
206 
207  // Make font
208  font=new FXFont(getApp(),"times",36,FONTWEIGHT_BOLD);
209 
210  // Make a tip
211  /*new FXTooltip(getApp());*/
212 
213  filename = "untitled";
214  directory = ".";
215  m_Unit = 1;
216 }
217 
218 // Destroy ImageWindow
220 
221  if(picture) {
222  delete picture;
223  picture=NULL;
224  }
225  if(font) {
226  delete font;
227  font=NULL;
228  }
229 }
230 
231 
232 // Create and initialize
234 
235  // Create the windows
236  FXMainWindow::create();
237 
238  picture->create();
239 
240  // Font too
241  font->create();
242 
243 // ifstream rf("records.list");
244 // if(rf) {
245 // string rec;
246 // while(getline(rf, rec))
247 // m_Records.push_back(rec);
248 // cout << m_Records.size() << " records read from records.list" << endl;
249 // m_DB.load(m_Records.begin()->c_str());
250 // changeSpecies(m_DB.begin()->second);
251 // } else cout << "no records.list loaded" << endl;
252 // m_CRec = m_Records.begin();
253 
254  if(!m_Selector.load("kinds.list"))
255 // m_DB.load(m_Records.begin()->c_str());
256 // changeSpecies(m_DB.begin()->second);
257 // } else cout << "no records.list loaded" << endl;
258 // m_CRec = m_Records.begin();
259 
260  if(filename!="untitled"){
261  setStatusText((FXString("trying to load: ")+filename).text());
262  if(!m_DB.load(filename.text())) {
263  setStatusText((FXString("error loading ")+filename).text());
264  } else {
265  setStatusText("");
266  //m_Records.push_back(string(filename.text()));
267  cout << "dir: " << directory.text() << endl;
268  changeSpecies(m_DB.begin()->second);
269  }
270  }
271  // Make it appear
272  show(PLACEMENT_SCREEN);
273 }
274 
275 // Handle the clear message
276 long ImageWindow::onCanvasRepaint(FXObject*,FXSelector,void* ptr){
277 
278  //todo: take scroll bar offsets into account to position circle centers
279 
280  cerr << "onCanvasRepaint: ..."<<endl;
281 
282  FXDCWindow dc(glcanvas);
283 // Point pofs(glcanvas->getXPosition(), glcanvas->getYPosition());
284 
285  dc.setForeground(FXRGB(0,255,0));
286  dc.drawLine(10,10,100,100);
287  return 1;
288 }
289 
290 
291 // Widget has been resized
292 long ImageWindow::onConfigure(FXObject*,FXSelector,void*){
293  if(glcanvas->makeCurrent()){
294  glViewport(0,0,glcanvas->getWidth(),glcanvas->getHeight());
295  glcanvas->makeNonCurrent();
296  }
297  return 1;
298 }
299 
300 
301 
302 // Widget needs repainting
303 long ImageWindow::onExpose(FXObject*,FXSelector,void*){
304  drawScene();
305  return 1;
306 }
307 
308 // Draw the GL scene
310  GLdouble width = glcanvas->getWidth();
311  GLdouble height = glcanvas->getHeight();
312  //GLdouble aspect = height>0 ? width/height : 1.0;
313 
314  // Make context current
315  glcanvas->makeCurrent();
316 
317  glViewport(0,0,glcanvas->getWidth(),glcanvas->getHeight());
318 
319  glClearColor(0.0,0.0,0.0,1.0);
320  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
321  glEnable(GL_BLEND);
322  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
323  glEnable(GL_LINE_SMOOTH);
324  glDisable(GL_DITHER);
325 
326  glMatrixMode(GL_MODELVIEW);
327  glLoadIdentity();
328  glMatrixMode(GL_PROJECTION);
329  glLoadIdentity();
330  if(m_Data.initialized()) {
331  GLint datwidth = m_Data.getDim1Size();
332  GLint datheight = m_Data.getDim2Size();
333  glPixelStorei(GL_UNPACK_ROW_LENGTH, datwidth);
334  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
335  GLfloat xscale = ((float)width)/datwidth;
336  GLfloat yscale = ((float)height)/datheight;
337  m_XYScale = xscale<yscale?xscale:yscale;
338  GLfloat swidth = width/m_XYScale;
339  GLfloat sheight = height/m_XYScale;
340  glOrtho(0,swidth,
341  sheight,0,
342  -1000,1000);
343 // if(m_ScreenImg.getSize())
344 // Dataset::drawImage(m_ScreenImg,0,datheight,m_XYScale,m_XYScale);
345 // else
346  m_Data.draw(0,datheight,m_XYScale,m_XYScale);
347  }
348 
349  // Swap if it is double-buffered
350  if(glvisual->isDoubleBuffer()){
351  glcanvas->swapBuffers();
352  }
353 
354  // Make context non-current
355  glcanvas->makeNonCurrent();
356 
357 }
358 
359 
360 // Pop a dialog showing OpenGL properties
361 long ImageWindow::onCmdOpenGL(FXObject*,FXSelector,void*){
362  glcanvas->makeCurrent();
363 // SettingsDialog sd((FXWindow*)this,glvisual);
364  glcanvas->makeNonCurrent();
365  //sd.execute();
366  return 1;
367 }
368 
369 // Open image
370 long ImageWindow::onLoadImage(FXObject*,FXSelector,void*){
371  FXFileDialog open(this,"Load Database (DAT)");
372 
373  open.setDirectory(directory);
374  open.setFilename(filename);
375  open.setPatternList(patterns);
376  if(open.execute()){
377  filename = open.getFilename();
378  directory = open.getDirectory();
379  m_ScreenImg.setSize(0,0);
380  setStatusText((FXString("trying to load: ")+filename).text());
381  if(!m_DB.load(filename.text())) {
382  setStatusText("Error loading file.");
383  } else {
384  setStatusText("");
385  changeSpecies(m_DB.begin()->second);
386  }
387  }
388  return 0;
389 }
390 
392 {
393  m_CSpecies = s;
394  directory = m_DB.getDirectory().c_str();
395  if(!m_Data.load((directory+"\\"+m_CSpecies["image"].c_str()).text()))
396  {
397  cout << "Error loading image "
398  << (directory+"\\"+m_CSpecies["image"].c_str()).text() << endl;
399  }
400  string msg = "species_id: ";
401  stringstream sstrm;
402  sstrm << m_CSpecies.getScale();
403  string number;
404  sstrm >> number;
405  msg += m_CSpecies["species_id"] + " image: " + m_CSpecies["image"]
406  + " flags: " + m_CSpecies.getFlagString()
407  + " scale (pixels per mm): "+number;
408  setStatusText(msg.c_str());
409  setTitle(m_CSpecies["name"].c_str());
410  drawScene();
411  //cout << m_CSpecies;
412 }
413 
414 // Key Press
415 long ImageWindow::onKeyPress(FXObject* obj,FXSelector sel,void* ptr){
416  FXEvent* event=(FXEvent*)ptr;
417  if(target && target->handle(this,MKUINT(message,SEL_KEYPRESS),ptr)) return 1;
418  int _x,_y,mx,my;
419  _x=m_Data.getDim1Size();
420  _y=m_Data.getDim2Size();
421  mx=event->win_x;
422  my=event->win_y;
423 #ifdef WIN32
424  mx-=glcanvas->getX();
425  my-=glcanvas->getY();
426 #endif
427  mx=(int)(mx/m_XYScale);
428  my=(int)(my/m_XYScale);
429  int walkdir=0;
430  switch(event->code) {
431  case KEY_space:
432  changeSpecies(m_CSpecies);
433  break;
434  case KEY_Right:
435  {
436  if(m_Selector.nextSelection(1))
437  changeSpecies(m_Selector.getCurSpecies());
438  break;
439  }
440  case KEY_Left:
441  {
442  if(m_Selector.nextSelection(-1))
443  changeSpecies(m_Selector.getCurSpecies());
444  break;
445  }
446  case KEY_Up:
447  walkdir=-1;
448  case KEY_Down:
449  {
450  if(!walkdir) walkdir=1;
451  if(m_Selector.nextSelector(walkdir))
452  changeSpecies(m_Selector.getCurSpecies());
453 // if(m_DB.load(m_CRec->c_str())) {
454 // cout << *m_CRec << " loaded." << endl;
455 // FXString filename(m_CRec->c_str());
456 // int ps = filename.findb('\\');
457 // if(ps == -1) ps = filename.findb('/');
458 // if(ps == -1) directory = ".";
459 // else directory = filename.left(ps);
460 // changeSpecies(m_DB.begin()->second);
461 // } else cout << "error loading " << *m_CRec << endl;
462  break;
463  }
464  case KEY_F1: case KEY_F2: case KEY_F3: case KEY_F4: case KEY_F5:
465  case KEY_F6: case KEY_F7: case KEY_F8: case KEY_F9:
466  {
467  static const int nct[9] = {1,2,3,4,5,10,30,50,100};
468  int nc = nct[event->code-KEY_F1];
469  cout << "computing " << nc << " nearest colours." << endl;
470  Clusterer<3> clusterer(nc,0,255);
471  clusterer.m_Elements.reserve(m_Data.getDim2Size()
472  *m_Data.getDim1Size());
473  //add elements
474  int i,j;
475  int height = m_Data.getDim2Size();
476  for(j=0; j<m_Data.getDim2Size(); j++)
477  for(i=0; i<m_Data.getDim1Size(); i++)
478  {
479  CElement<3> col(m_Data.getMValue(i,height-j-1));
480  clusterer.m_Elements.push_back(col);
481  }
482  clusterer.iterateClassification(30);
483  //generate colour clustered Image
484  int size = int(m_Data.getDim1Size()*m_Data.getDim2Size());
485  for(i=0; i<size; i++)
486  {
487  const CElement<3> &pc=clusterer.m_Classes[
488  clusterer.m_Elements[i].getClassID()];
489  m_Data.getImage(0)[i] = (byte)pc.val[0];
490  m_Data.getImage(1)[i] = (byte)pc.val[1];
491  m_Data.getImage(2)[i] = (byte)pc.val[2];
492  }
493  drawScene();
494  break;
495  }
496  case KEY_c:
497  {
498  cout << "computing chrominance." << endl;
499  int i,j,ind=0;
500  int height = m_Data.getDim2Size();
501  for(j=0; j<m_Data.getDim2Size(); j++)
502  for(i=0; i<m_Data.getDim1Size(); i++,ind++)
503  {
504  vector<float> c(m_Data.getMValue(i,height-j-1));
505 #define SATURATION
506 //#define AGD
507 #ifdef AGD
508  float g = (c[0]+c[1]+c[2])/3.0f;
509  float R = fabs(g-c[1])+abs(g-c[2]);
510  float G = fabs(g-c[2])+abs(g-c[0]);
511  float B = fabs(g-c[0])+abs(g-c[1]);
512 #elif defined(SATURATION)
513  float v,m;
514  v = max(c[0],max(c[1],c[2]));
515  m = min(c[0],min(c[1],c[2]));
516  float G; // = v;
517  float R,B;
518  G = R = B = (v>0)?255*(v-m)/v : 0;
519  //G = R = B = v-m;
520 #endif
521  m_Data.getImage(0)[ind] = (byte)R;
522  m_Data.getImage(1)[ind] = (byte)G;
523  m_Data.getImage(2)[ind] = (byte)B;
524  }
525  drawScene();
526  break;
527  }
528  case KEY_W:
529  {
530  ofstream os((m_DB.getDirectory()+"//species-db.dat").c_str());
531  os << m_DB;
532  break;
533  }
534  case KEY_f:
535  m_DB[m_CSpecies.id].setFlag(Species::FLIPPED);
536  break;
537  case KEY_F:
538  m_DB[m_CSpecies.id].unsetFlag(Species::FLIPPED);
539  break;
540  case KEY_s:
541  m_DB[m_CSpecies.id].setFlag(Species::SCALE);
542  break;
543  case KEY_S:
544  m_DB[m_CSpecies.id].unsetFlag(Species::SCALE);
545  break;
546  case KEY_d:
547  m_DB[m_CSpecies.id].setFlag(Species::DEL);
548  break;
549  case KEY_D:
550  m_DB[m_CSpecies.id].unsetFlag(Species::DEL);
551  break;
552  case KEY_1:
553  m_DB[m_CSpecies.id].setFlag(Species::SEL1);
554  break;
555  case KEY_exclam:
556  m_DB[m_CSpecies.id].unsetFlag(Species::SEL1);
557  break;
558  case KEY_2:
559  m_DB[m_CSpecies.id].setFlag(Species::SEL2);
560  break;
561  case KEY_at:
562  m_DB[m_CSpecies.id].unsetFlag(Species::SEL2);
563  break;
564  case KEY_3:
565  m_DB[m_CSpecies.id].setFlag(Species::SEL3);
566  break;
567  case KEY_numbersign:
568  m_DB[m_CSpecies.id].unsetFlag(Species::SEL3);
569  break;
570  case KEY_4:
571  m_DB[m_CSpecies.id].setFlag(Species::SEL4);
572  break;
573  case KEY_dollar:
574  m_DB[m_CSpecies.id].unsetFlag(Species::SEL4);
575  break;
576  case KEY_5:
577  m_DB[m_CSpecies.id].setFlag(Species::SEL5);
578  break;
579  case KEY_percent:
580  m_DB[m_CSpecies.id].unsetFlag(Species::SEL5);
581  break;
582  case KEY_comma:
583  m_Unit *= 0.5;
584  cout << "unit is now " << m_Unit << " mm" << endl;
585  break;
586  case KEY_period:
587  m_Unit *= 2;
588  cout << "unit is now " << m_Unit << " mm" << endl;
589  break;
590  default:
591  return FXMainWindow::onKeyPress(obj,sel,ptr);
592  break;
593  }
594  return 1;
595 }
596 
597 // Key Release
598 long ImageWindow::onKeyRelease(FXObject*,FXSelector,void* ptr){
599 /*
600  FXEvent* event=(FXEvent*)ptr;
601  FXint index=current;
602  flags&=~FLAG_TIP;
603  if(!isEnabled()) return 0;
604  if(index<0) index=0;
605  switch(event->code){
606  case KEY_Space:
607  //blubb
608  }
609 */
610  return 0;
611 }
612 
613 long ImageWindow::onLeftMouseClick(FXObject*,FXSelector,void* ptr){
614 
615  FXEvent *event=(FXEvent*)ptr;
616  FXint _x, _y, mx, my;
617 
618  Point pofs(glcanvas->getX(), glcanvas->getY());
619  _x=m_Data.getDim1Size();
620  _y=m_Data.getDim2Size();
621  mx=event->win_x;
622  my=event->win_y;
623 #ifdef WIN32
624  mx-=glcanvas->getX();
625  my-=glcanvas->getY();
626 #endif
627  mx=(int)(mx/m_XYScale);
628  my=(int)(my/m_XYScale);
629  if( mx < _x && my < _y){
630  cout << "doing nothing at " << mx << " " << my << endl;
631  }
632  return 1;
633 }
634 
635 long ImageWindow::onRightMouseClick(FXObject*,FXSelector,void* ptr){
636 
637  FXEvent *event=(FXEvent*)ptr;
638  FXint _x, _y, mx, my;
639 
640  Point pofs(glcanvas->getX(), glcanvas->getY());
641  _x=m_Data.getDim1Size();
642  _y=m_Data.getDim2Size();
643  mx=event->win_x;
644  my=event->win_y;
645 #ifdef WIN32
646  mx-=glcanvas->getX();
647  my-=glcanvas->getY();
648 #endif
649  mx=(int)(mx/m_XYScale);
650  my=(int)(my/m_XYScale);
651  if( mx < _x && my < _y){
652  cout << "doing nothing at " << mx << " " << my << endl;
653  static int lastclick = -1;
654  if(lastclick>0) {
655  m_DB[m_CSpecies.id]["scale"] = (FXString().format("%i",int(abs(lastclick-mx)/m_Unit))).text();
656  cout << m_DB[m_CSpecies.id] << " for " << m_Unit << " mm" << endl;
657  lastclick=-1;
658  } else lastclick = mx;
659  }
660  return 1;
661 }
662 
663 void ImageWindow::setStatusText(const char* msg, bool append)
664 {
665  if(!append)
666  m_Statusline->setNormalText(msg);
667  else
668  m_Statusline->setNormalText(m_Statusline->getNormalText()+FXString(msg));
669 }
670 
671 FXbool ImageWindow::cmdline(int argc, char ** argv){
672 
673  if(argc >= 2) filename=argv[1];
674  if(argc >= 3) savefilename=argv[2];
675 
676  return TRUE;
677 }
678 
679 // Here we begin
680 int main(int argc,char *argv[]){
681 
682  // Make application
683  FXApp application("Deformable Model Segmentation","FoxText");
684 
685  // Start app
686  application.init(argc,argv);
687 
688  // Make window
689  ImageWindow *iw = new ImageWindow(&application);
690  iw->cmdline(argc,argv);
691 
692  // Create the application's windows
693  application.create();
694 
695  // Run the application
696  return application.run();
697 }
698 
699 /* emacs layout configuration
700  ;;; Local Variables: ***
701  ;;; tab-width: 4 ***
702  ;;; End: ***
703 */
#define NULL
Definition: simpletypes.h:9
int getDim1Size() const
Definition: Data.h:44
void iterateClassification(dword maxit=10)
Definition: Clusterer.h:161
FXbool cmdline(int argc, char **argv)
Definition: browser.cpp:671
vector< CElement< D > > m_Classes
Definition: Clusterer.h:176
bool nextSelector(int walkdir=1, bool wrap=true, dword mincount=1)
Definition: SpeciesDB.cpp:291
dword id
Definition: SpeciesDB.h:41
STL namespace.
const std::string & getDirectory() const
Definition: SpeciesDB.h:55
virtual std::vector< float > getMValue(int x, int y) const
get multi-channel value
Definition: Sensor.h:49
void changeSpecies(const Species &s)
Definition: browser.cpp:391
long onKeyPress(FXObject *, FXSelector, void *ptr)
Definition: browser.cpp:415
long onLoadImage(FXObject *, FXSelector, void *)
Definition: browser.cpp:370
bool load(const char *filename, dword ppmm=0)
Definition: Data.cpp:62
long onLeftMouseClick(FXObject *, FXSelector, void *)
Definition: browser.cpp:613
long onConfigure(FXObject *, FXSelector, void *)
Definition: browser.cpp:292
bool setTitle(const char *title)
Definition: browser.cpp:154
bool load(const char *filename)
Definition: SpeciesDB.cpp:241
FXIMPLEMENT(SensorDialog, FXDialogBox, SensorDialogMap, ARRAYNUMBER(SensorDialogMap)) SensorDialog
Definition: sensordlg.cpp:18
bool load(const char *filename)
Definition: SpeciesDB.cpp:13
DMatrix< T > & abs(DMatrix< T > &mat)
Definition: DMatrixUtil.h:132
void setStatusText(const char *msg, bool append=false)
Definition: browser.cpp:663
virtual ~ImageWindow()
Definition: browser.cpp:219
int getDim2Size() const
Definition: Data.h:45
long onRightMouseClick(FXObject *, FXSelector, void *)
Definition: browser.cpp:635
const ByteImage & getImage() const
Definition: Data.h:54
long onKeyRelease(FXObject *, FXSelector, void *ptr)
Definition: browser.cpp:598
int main(int argc, char *argv[])
Definition: browser.cpp:680
void draw(float x=0, float y=0, float sx=1.0f, float sy=1.0f) const
Definition: Data.cpp:113
long onCanvasRepaint(FXObject *, FXSelector, void *)
Definition: browser.cpp:276
Definition: Data.h:21
long onCmdOpenGL(FXObject *, FXSelector, void *)
Definition: browser.cpp:361
unsigned char byte
Definition: simpletypes.h:4
dword getScale() const
Definition: SpeciesDB.cpp:229
float val[D]
Definition: Clusterer.h:77
void setSize(int nx, int ny)
Definition: Image.h:268
vector< CElement< D > > m_Elements
Definition: Clusterer.h:175
std::string getFlagString() const
Definition: SpeciesDB.cpp:181
FXDEFMAP(ImageWindow) ImageWindowMap[]
bool nextSelection(int dir=1, bool wrap=true)
Definition: SpeciesDB.cpp:261
Definition: Point.h:16
Species & getCurSpecies()
Returns a handle to the currently selected species in the data base.
Definition: SpeciesDB.h:90
const FXchar * patterns[]
Definition: browser.cpp:26
bool setStatusText(const char *stext)
Definition: browser.cpp:164
virtual void create()
Definition: browser.cpp:233
long onExpose(FXObject *, FXSelector, void *)
Definition: browser.cpp:303
bool initialized() const
Definition: Data.h:52
void drawScene()
Definition: browser.cpp:309