Structural deformable models
Public Types | Public Member Functions | Protected Member Functions | List of all members
ImageWindow Class Reference

#include <deform.h>

Inheritance diagram for ImageWindow:
Inheritance graph
[legend]
Collaboration diagram for ImageWindow:
Collaboration graph
[legend]

Public Types

enum  {
  ID_CANVAS =FXMainWindow::ID_LAST, ID_TEST, ID_LOAD, ID_OPENGL,
  ID_LAST
}
 
enum  {
  ID_CANVAS =FXMainWindow::ID_LAST, ID_TEST, ID_LOAD, ID_TIMEOUT,
  ID_OPENGL, ID_LAST, ID_EDSENS
}
 

Public Member Functions

long onCanvasRepaint (FXObject *, FXSelector, void *)
 
long onLeftMouseClick (FXObject *, FXSelector, void *)
 
long onRightMouseClick (FXObject *, FXSelector, void *)
 
long onKeyPress (FXObject *, FXSelector, void *ptr)
 
long onKeyRelease (FXObject *, FXSelector, void *ptr)
 
long onCmdRestore (FXObject *, FXSelector, void *)
 
long onLoadImage (FXObject *, FXSelector, void *)
 
long onMouseDown (FXObject *, FXSelector, void *)
 
long onMouseUp (FXObject *, FXSelector, void *)
 
long onMouseMove (FXObject *, FXSelector, void *)
 
long onExpose (FXObject *, FXSelector, void *)
 
long onConfigure (FXObject *, FXSelector, void *)
 
long onCmdOpenGL (FXObject *, FXSelector, void *)
 
void drawScene ()
 
void changeSpecies (const Species &s)
 
void setStatusText (const char *msg, bool append=false)
 
 ImageWindow (FXApp *a)
 
virtual void create ()
 
FXbool cmdline (int argc, char **argv)
 
virtual ~ImageWindow ()
 
long onCanvasRepaint (FXObject *, FXSelector, void *)
 
long onLeftMouseClick (FXObject *, FXSelector, void *)
 
long onRightMouseClick (FXObject *, FXSelector, void *)
 
long onMouseMove (FXObject *, FXSelector, void *)
 
long onKeyPress (FXObject *, FXSelector, void *ptr)
 
long onKeyRelease (FXObject *, FXSelector, void *ptr)
 
long onCmdRestore (FXObject *, FXSelector, void *)
 
long onLoadImage (FXObject *, FXSelector, void *)
 
long onExpose (FXObject *, FXSelector, void *)
 
long onConfigure (FXObject *, FXSelector, void *)
 
long onCmdOpenGL (FXObject *, FXSelector, void *)
 
long onToggleSensorDlg (FXObject *, FXSelector, void *)
 
long onTimeout (FXObject *, FXSelector, void *)
 
int selectSensor (int sido)
 
void drawScene ()
 
void setStatusText (const char *msg, bool append=false)
 
 ImageWindow (FXApp *a)
 
virtual void create ()
 
FXbool cmdline (int argc, char **argv)
 
virtual ~ImageWindow ()
 

Protected Member Functions

 ImageWindow ()
 
 ImageWindow ()
 

Detailed Description

Definition at line 51 of file browser.cpp.

Member Enumeration Documentation

anonymous enum
Enumerator
ID_CANVAS 
ID_TEST 
ID_LOAD 
ID_OPENGL 
ID_LAST 

Definition at line 107 of file browser.cpp.

anonymous enum
Enumerator
ID_CANVAS 
ID_TEST 
ID_LOAD 
ID_TIMEOUT 
ID_OPENGL 
ID_LAST 
ID_EDSENS 

Definition at line 68 of file deform.h.

Constructor & Destructor Documentation

ImageWindow::ImageWindow ( )
inlineprotected

Definition at line 80 of file browser.cpp.

References setStatusText().

Referenced by main(), and setStatusText().

80 : m_Selector(m_DB) {}
ImageWindow::ImageWindow ( FXApp *  a)

Definition at line 175 of file browser.cpp.

References ID_CANVAS, ID_LOAD, and NULL.

175  :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 }
#define NULL
Definition: simpletypes.h:9
ImageWindow::~ImageWindow ( )
virtual

Definition at line 219 of file browser.cpp.

References NULL.

Referenced by setStatusText().

219  {
220 
221  if(picture) {
222  delete picture;
223  picture=NULL;
224  }
225  if(font) {
226  delete font;
227  font=NULL;
228  }
229 }
#define NULL
Definition: simpletypes.h:9
ImageWindow::ImageWindow ( )
inlineprotected
ImageWindow::ImageWindow ( FXApp *  a)
virtual ImageWindow::~ImageWindow ( )
virtual

Member Function Documentation

void ImageWindow::changeSpecies ( const Species s)

Definition at line 391 of file browser.cpp.

References drawScene(), SpeciesDB::getDirectory(), Species::getFlagString(), Species::getScale(), Dataset::load(), setStatusText(), and setTitle().

Referenced by create(), onKeyPress(), and onLoadImage().

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 }
const std::string & getDirectory() const
Definition: SpeciesDB.h:55
bool load(const char *filename, dword ppmm=0)
Definition: Data.cpp:62
bool setTitle(const char *title)
Definition: browser.cpp:154
void setStatusText(const char *msg, bool append=false)
Definition: browser.cpp:663
dword getScale() const
Definition: SpeciesDB.cpp:229
std::string getFlagString() const
Definition: SpeciesDB.cpp:181
void drawScene()
Definition: browser.cpp:309
FXbool ImageWindow::cmdline ( int  argc,
char **  argv 
)
FXbool ImageWindow::cmdline ( int  argc,
char **  argv 
)

Definition at line 671 of file browser.cpp.

Referenced by main(), and onTimeout().

671  {
672 
673  if(argc >= 2) filename=argv[1];
674  if(argc >= 3) savefilename=argv[2];
675 
676  return TRUE;
677 }
virtual void ImageWindow::create ( )
virtual
void ImageWindow::create ( )
virtual

Definition at line 233 of file browser.cpp.

References changeSpecies(), SpeciesDB::load(), DBSelector::load(), and setStatusText().

Referenced by setStatusText().

233  {
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 }
void changeSpecies(const Species &s)
Definition: browser.cpp:391
bool load(const char *filename)
Definition: SpeciesDB.cpp:241
bool load(const char *filename)
Definition: SpeciesDB.cpp:13
void setStatusText(const char *msg, bool append=false)
Definition: browser.cpp:663
void ImageWindow::drawScene ( )
void ImageWindow::drawScene ( )

Definition at line 309 of file browser.cpp.

References Dataset::draw(), Dataset::getDim1Size(), Dataset::getDim2Size(), and Dataset::initialized().

Referenced by changeSpecies(), ImageWindow(), onExpose(), onKeyPress(), and setStatusText().

309  {
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 }
int getDim1Size() const
Definition: Data.h:44
int getDim2Size() const
Definition: Data.h:45
void draw(float x=0, float y=0, float sx=1.0f, float sy=1.0f) const
Definition: Data.cpp:113
bool initialized() const
Definition: Data.h:52
long ImageWindow::onCanvasRepaint ( FXObject *  ,
FXSelector  ,
void *   
)
long ImageWindow::onCanvasRepaint ( FXObject *  ,
FXSelector  ,
void *  ptr 
)

Definition at line 276 of file browser.cpp.

Referenced by ImageWindow(), and setStatusText().

276  {
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 }
long ImageWindow::onCmdOpenGL ( FXObject *  ,
FXSelector  ,
void *   
)
long ImageWindow::onCmdOpenGL ( FXObject *  ,
FXSelector  ,
void *   
)

Definition at line 361 of file browser.cpp.

Referenced by ImageWindow(), and setStatusText().

361  {
362  glcanvas->makeCurrent();
363 // SettingsDialog sd((FXWindow*)this,glvisual);
364  glcanvas->makeNonCurrent();
365  //sd.execute();
366  return 1;
367 }
long ImageWindow::onCmdRestore ( FXObject *  ,
FXSelector  ,
void *   
)
long ImageWindow::onCmdRestore ( FXObject *  ,
FXSelector  ,
void *   
)

Referenced by ImageWindow().

long ImageWindow::onConfigure ( FXObject *  ,
FXSelector  ,
void *   
)
long ImageWindow::onConfigure ( FXObject *  ,
FXSelector  ,
void *   
)

Definition at line 292 of file browser.cpp.

Referenced by ImageWindow(), and setStatusText().

292  {
293  if(glcanvas->makeCurrent()){
294  glViewport(0,0,glcanvas->getWidth(),glcanvas->getHeight());
295  glcanvas->makeNonCurrent();
296  }
297  return 1;
298 }
long ImageWindow::onExpose ( FXObject *  ,
FXSelector  ,
void *   
)
long ImageWindow::onExpose ( FXObject *  ,
FXSelector  ,
void *   
)

Definition at line 303 of file browser.cpp.

References drawScene().

Referenced by ImageWindow(), and setStatusText().

303  {
304  drawScene();
305  return 1;
306 }
void drawScene()
Definition: browser.cpp:309
long ImageWindow::onKeyPress ( FXObject *  ,
FXSelector  ,
void *  ptr 
)
long ImageWindow::onKeyPress ( FXObject *  obj,
FXSelector  sel,
void *  ptr 
)

Definition at line 415 of file browser.cpp.

References dmutil::abs(), changeSpecies(), Species::DEL, drawScene(), Species::FLIPPED, DBSelector::getCurSpecies(), Dataset::getDim1Size(), Dataset::getDim2Size(), SpeciesDB::getDirectory(), Dataset::getImage(), Sensor::getMValue(), Species::id, Clusterer< D >::iterateClassification(), Clusterer< D >::m_Classes, Clusterer< D >::m_Elements, DBSelector::nextSelection(), DBSelector::nextSelector(), Species::SCALE, Species::SEL1, Species::SEL2, Species::SEL3, Species::SEL4, Species::SEL5, and CElement< D >::val.

Referenced by ImageWindow(), and onToggleSensorDlg().

415  {
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 }
int getDim1Size() const
Definition: Data.h:44
bool nextSelector(int walkdir=1, bool wrap=true, dword mincount=1)
Definition: SpeciesDB.cpp:291
dword id
Definition: SpeciesDB.h:41
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
DMatrix< T > & abs(DMatrix< T > &mat)
Definition: DMatrixUtil.h:132
int getDim2Size() const
Definition: Data.h:45
const ByteImage & getImage() const
Definition: Data.h:54
unsigned char byte
Definition: simpletypes.h:4
float val[D]
Definition: Clusterer.h:77
bool nextSelection(int dir=1, bool wrap=true)
Definition: SpeciesDB.cpp:261
Species & getCurSpecies()
Returns a handle to the currently selected species in the data base.
Definition: SpeciesDB.h:90
void drawScene()
Definition: browser.cpp:309
long ImageWindow::onKeyRelease ( FXObject *  ,
FXSelector  ,
void *  ptr 
)
long ImageWindow::onKeyRelease ( FXObject *  ,
FXSelector  ,
void *  ptr 
)

Definition at line 598 of file browser.cpp.

Referenced by ImageWindow(), and selectSensor().

598  {
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 }
long ImageWindow::onLeftMouseClick ( FXObject *  ,
FXSelector  ,
void *   
)
long ImageWindow::onLeftMouseClick ( FXObject *  ,
FXSelector  ,
void *  ptr 
)

Definition at line 613 of file browser.cpp.

References Dataset::getDim1Size(), and Dataset::getDim2Size().

Referenced by ImageWindow(), and selectSensor().

613  {
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 }
int getDim1Size() const
Definition: Data.h:44
int getDim2Size() const
Definition: Data.h:45
Definition: Point.h:16
long ImageWindow::onLoadImage ( FXObject *  ,
FXSelector  ,
void *   
)
long ImageWindow::onLoadImage ( FXObject *  ,
FXSelector  ,
void *   
)

Definition at line 370 of file browser.cpp.

References changeSpecies(), SpeciesDB::load(), patterns, Image< T >::setSize(), and setStatusText().

Referenced by ImageWindow(), and onToggleSensorDlg().

370  {
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 }
void changeSpecies(const Species &s)
Definition: browser.cpp:391
bool load(const char *filename)
Definition: SpeciesDB.cpp:13
void setStatusText(const char *msg, bool append=false)
Definition: browser.cpp:663
void setSize(int nx, int ny)
Definition: Image.h:268
const FXchar * patterns[]
Definition: browser.cpp:26
long ImageWindow::onMouseDown ( FXObject *  ,
FXSelector  ,
void *   
)
long ImageWindow::onMouseMove ( FXObject *  ,
FXSelector  ,
void *   
)
long ImageWindow::onMouseMove ( FXObject *  ,
FXSelector  ,
void *  ptr 
)

Definition at line 432 of file deform.cpp.

Referenced by ImageWindow().

432  {
433 
434  FXEvent *event=(FXEvent*)ptr;
435  FXint _x, _y, mx, my;
436 
437  Point pofs(glcanvas->getX(), glcanvas->getY());
438  _x=m_Brain.getData().getDim1Size();
439  _y=m_Brain.getData().getDim2Size();
440  mx=event->win_x;
441  my=event->win_y;
442 // #ifdef SHIFT_CANVAS_ORIGIN
443 // mx-=glcanvas->getX();
444 // my-=glcanvas->getY();
445 // #endif
446  mx=(int)(mx/m_XYScale);
447  my=(int)(my/m_XYScale);
448  if( mx < _x && my < _y){
449  m_Brain.triggerTest((int)(mx),
450  (int)(my),KEY_H);
451  }
452  return 1;
453 }
int getDim1Size() const
Definition: Data.h:44
bool triggerTest(int mx, int my, int what=0)
Definition: Brain.cpp:442
const Dataset & getData() const
Definition: Brain.cpp:77
int getDim2Size() const
Definition: Data.h:45
Definition: Point.h:16
long ImageWindow::onMouseUp ( FXObject *  ,
FXSelector  ,
void *   
)
long ImageWindow::onRightMouseClick ( FXObject *  ,
FXSelector  ,
void *   
)
long ImageWindow::onRightMouseClick ( FXObject *  ,
FXSelector  ,
void *  ptr 
)

Definition at line 635 of file browser.cpp.

References dmutil::abs(), Dataset::getDim1Size(), Dataset::getDim2Size(), and Species::id.

Referenced by ImageWindow(), and selectSensor().

635  {
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 }
int getDim1Size() const
Definition: Data.h:44
dword id
Definition: SpeciesDB.h:41
DMatrix< T > & abs(DMatrix< T > &mat)
Definition: DMatrixUtil.h:132
int getDim2Size() const
Definition: Data.h:45
Definition: Point.h:16
long ImageWindow::onTimeout ( FXObject *  ,
FXSelector  ,
void *   
)

Definition at line 456 of file deform.cpp.

References cmdline(), setStatusText(), and TIMER_INTERVAL.

Referenced by ImageWindow().

456  {
457  drawScene();
458  getApp()->addTimeout(this,ID_TIMEOUT,TIMER_INTERVAL);
459  return 1;
460 }
void drawScene()
Definition: browser.cpp:309
const FXuint TIMER_INTERVAL
Definition: deform.cpp:22
long ImageWindow::onToggleSensorDlg ( FXObject *  ,
FXSelector  ,
void *   
)

Definition at line 265 of file deform.cpp.

References onKeyPress(), onLoadImage(), patterns, and setStatusText().

Referenced by ImageWindow().

265  {
266  if(m_SensorDlg->shown()) m_SensorDlg->hide();
267  else m_SensorDlg->show();
268  return 1;
269 }
int ImageWindow::selectSensor ( int  sido)

Definition at line 325 of file deform.cpp.

References Image< T >::convertFrom(), NULL, onKeyRelease(), onLeftMouseClick(), onRightMouseClick(), setStatusText(), Image< T >::unsetNAN(), and Sensor::UPD_MINMAX.

Referenced by ImageWindow().

326 {
327  vuLock glock(m_Brain.getGeomMutex());
328  SensorCollection &sensors = m_Brain.getSensors();
329  sensor_ptr ss = NULL;
330  if((int)sensors.size()<=sido) sido=0;
331  if(sido<0) sido=sensors.size()-1;
332  int sid = sido;
333  for(SensorCollection::iterator s=sensors.begin();
334  s!=sensors.end();s++,sid--) {
335  if(!sid) {
336  ss = s->second;
337  break;
338  }
339  }
340  if(!ss || !sido) {
341  setStatusText("Showing original image.");
342  m_ScreenImg.setSize(0,0);
343  ((SensorCollection&)sensors).selectSensor("d0");
344  } else {
345  if(!ss->isUpdate(Sensor::UPD_MINMAX)) {
346  ss->enableUpdate(Sensor::UPD_MINMAX);
347  ss->setModified(Sensor::UPD_MINMAX);
348  }
349  Image<float> simg(ss->createSensorImage());
350  simg.unsetNAN(0);
351  float imax=ss->getMax(); //simg.findMax();
352  float imin=ss->getMin(); //simg.findMin();
353  //simg+=-imin;
354  //simg*=(255/(imax-imin));
355  simg*=255;
356  m_ScreenImg.convertFrom(simg);
357  m_RefreshScreenImg = true;
358  //m_ScreenImg.writePPM("sensor.ppm");
359  //m_ScreenImg = m_ScreenImg.mirror(false, true);
360 
361  char msg[1024];
362  sprintf(msg,"Showing sensor [%s] (min=%.4f max=%.4f).",
363  ss->getID().c_str(),imin,imax);
364  setStatusText(msg);
365  ((SensorCollection&)sensors).selectSensor(ss->getID());
366  }
367  return sido;
368 }
#define NULL
Definition: simpletypes.h:9
std::shared_ptr< Sensor > sensor_ptr
Definition: types_fwd.h:15
Image< T > & convertFrom(const Image< S > &rhs)
Definition: Image.h:91
const SensorCollection & getSensors() const
Definition: Brain.h:70
void setStatusText(const char *msg, bool append=false)
Definition: browser.cpp:663
vuMutex & getGeomMutex()
Definition: Brain.h:82
void setSize(int nx, int ny)
Definition: Image.h:268
Image< T > & unsetNAN(double val=0)
Definition: Image.h:523
void ImageWindow::setStatusText ( const char *  msg,
bool  append = false 
)
void ImageWindow::setStatusText ( const char *  msg,
bool  append = false 
)

Definition at line 663 of file browser.cpp.

Referenced by changeSpecies(), create(), ImageWindow(), onLoadImage(), onTimeout(), and setStatusText().

664 {
665  if(!append)
666  m_Statusline->setNormalText(msg);
667  else
668  m_Statusline->setNormalText(m_Statusline->getNormalText()+FXString(msg));
669 }

The documentation for this class was generated from the following files: