]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.cxx
1495 BUG
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / mathplot.cxx
1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        mathplot.cpp
3 // Purpose:     Framework for mathematical graph plotting in wxWindows
4 // Author:      David Schalig
5 // Modified by:
6 // Created:     21/07/2003
7 // Copyright:   (c) David Schalig
8 // Licence:     wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 /*EED
12 #ifdef __GNUG__
13 #pragma implementation "plot.h"
14 #endif
15 */
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18 #ifdef __BORLANDC__
19 #pragma hdrstop
20 #endif
21
22 /*EED
23 #ifndef WX_PRECOMP
24 #include "wx/object.h"
25 #include "wx/font.h"
26 #include "wx/colour.h"
27 #include "wx/settings.h"
28 #include "wx/sizer.h"
29 #include "wx/log.h"
30 #include "wx/intl.h"
31 #include "wx/dcclient.h"
32 #endif
33
34 // EED
35 #ifndef WX_PRECOMP
36 #include <wx/wx.h>
37 #endif
38 */
39
40
41 #include "mathplot.h"
42 //#include "wx/bmpbuttn.h"
43 //#include "wx/module.h"
44
45 //#include <math.h>
46
47 //-----------------------------------------------------------------------------
48 // mpLayer
49 //-----------------------------------------------------------------------------
50
51 IMPLEMENT_ABSTRACT_CLASS(mpLayer, wxObject)
52
53 mpLayer::mpLayer()
54 {
55 // EED wx 2.8.5
56 //      SetPen( *wxBLACK_PEN);
57 //      SetFont(*wxNORMAL_FONT);
58
59         wxFont ff( *wxNORMAL_FONT);
60         wxPen pp( *wxBLACK_PEN);
61         SetPen( pp );
62         SetFont( ff );
63
64 }
65
66 //-----------------------------------------------------------------------------
67 // mpLayer implementations - functions
68 //-----------------------------------------------------------------------------
69
70 IMPLEMENT_ABSTRACT_CLASS(mpFX, mpLayer)
71
72 mpFX::mpFX(wxString name, int flags)
73
74         SetName(name);
75         m_flags = flags; 
76 }
77
78 void mpFX::Plot(wxDC & dc, mpWindow & w)
79 {
80         dc.SetPen( m_pen);
81
82         if (m_pen.GetWidth() <= 1) 
83         {
84                 for (wxCoord i = -(w.GetScrX()>>1); i < (w.GetScrX()>>1); ++i)
85                 {
86                         dc.DrawPoint(i, (wxCoord) ((w.GetPosY() - GetY( (double)i / w.GetScaleX() + w.GetPosX()) ) * w.GetScaleY()));
87                 }
88         }
89         else
90         {
91                 for (wxCoord i = -(w.GetScrX()>>1); i < (w.GetScrX()>>1); ++i)
92                 {
93                         wxCoord c = (wxCoord) ((w.GetPosY() - GetY( (double)i / w.GetScaleX() + w.GetPosX()) ) * w.GetScaleY());
94                         dc.DrawLine( i, c, i, c);
95                 }
96         }
97
98         if (!m_name.IsEmpty())
99         {
100                 dc.SetFont(m_font);
101
102                 wxCoord tx, ty;
103                 dc.GetTextExtent(m_name, &tx, &ty);
104
105                 if ((m_flags & mpALIGNMASK) == mpALIGN_RIGHT)
106                         tx = (w.GetScrX()>>1) - tx - 8;
107                 else if ((m_flags & mpALIGNMASK) == mpALIGN_CENTER)
108                         tx = -tx/2;
109                 else
110                         tx = -(w.GetScrX()>>1) + 8;
111
112                 dc.DrawText( m_name, tx, (wxCoord) ((w.GetPosY() - GetY( (double)tx / w.GetScaleX() + w.GetPosX())) * w.GetScaleY()) );
113         }
114 }
115
116 IMPLEMENT_ABSTRACT_CLASS(mpFY, mpLayer)
117
118 mpFY::mpFY(wxString name, int flags)
119
120         SetName(name);
121         m_flags = flags;
122 }
123
124 void mpFY::Plot(wxDC & dc, mpWindow & w)
125 {
126         dc.SetPen( m_pen);
127
128         wxCoord i;
129
130         if (m_pen.GetWidth() <= 1) 
131         {
132                 for (i = -(w.GetScrY()>>1); i < (w.GetScrY()>>1); ++i)
133                 {
134                         dc.DrawPoint((wxCoord) ((GetX( (double)i / w.GetScaleY() + w.GetPosY()) - w.GetPosX()) * w.GetScaleX()), -i);
135                 }
136         }
137         else
138         {
139                 for (i = -(w.GetScrY()>>1); i < (w.GetScrY()>>1); ++i)
140                 {
141                         wxCoord c =  (wxCoord) ((GetX( (double)i / w.GetScaleY() + w.GetPosY()) - w.GetPosX()) * w.GetScaleX());
142                         dc.DrawLine(c, -i, c, -i);
143                 }
144         }
145
146         if (!m_name.IsEmpty())
147         {
148                 dc.SetFont(m_font);
149
150                 wxCoord tx, ty;
151                 dc.GetTextExtent(m_name, &tx, &ty);
152
153                 if ((m_flags & mpALIGNMASK) == mpALIGN_TOP)
154                         ty = (w.GetScrY()>>1) - 8;
155                 else if ((m_flags & mpALIGNMASK) == mpALIGN_CENTER)
156                         ty = 16 - ty/2;
157                 else
158                         ty = -(w.GetScrY()>>1) + 8;
159
160                 dc.DrawText( m_name, (wxCoord) ((GetX( (double)i / w.GetScaleY() + w.GetPosY()) - w.GetPosX()) * w.GetScaleX()), -ty);
161         }
162 }
163
164 IMPLEMENT_ABSTRACT_CLASS(mpFXY, mpLayer)
165
166 mpFXY::mpFXY(wxString name, int flags)
167
168         SetName(name);
169         m_flags = flags; 
170 }
171
172 void mpFXY::Plot(wxDC & dc, mpWindow & w)
173 {
174         dc.SetPen( m_pen);
175
176         double x, y;
177         Rewind();
178
179         // for some reason DrawPoint does not use the current pen,
180         // so we use DrawLine for fat pens
181
182         if (m_pen.GetWidth() <= 1) 
183         {
184                 while (GetNextXY(x, y))
185                 {
186                         dc.DrawPoint( (wxCoord) ((x - w.GetPosX()) * w.GetScaleX()) ,
187                                 (wxCoord) ((w.GetPosY() - y) * w.GetScaleY()) );
188                 }
189         }
190         else
191         {
192                 while (GetNextXY(x, y))
193                 {
194                         wxCoord cx = (wxCoord) ((x - w.GetPosX()) * w.GetScaleX());
195                         wxCoord cy = (wxCoord) ((w.GetPosY() - y) * w.GetScaleY());
196                         dc.DrawLine(cx, cy, cx, cy);
197                 }
198         }
199
200         if (!m_name.IsEmpty())
201         {
202                 dc.SetFont(m_font);
203
204                 wxCoord tx, ty;
205                 dc.GetTextExtent(m_name, &tx, &ty);
206
207                 // xxx implement else ... if (!HasBBox())
208                 {
209                         const int sx = w.GetScrX()>>1;
210                         const int sy = w.GetScrY()>>1;
211
212                         if ((m_flags & mpALIGNMASK) == mpALIGN_NE)
213                         {
214                                 tx = sx - tx - 8;
215                                 ty = -sy + 8;
216                         }
217                         else if ((m_flags & mpALIGNMASK) == mpALIGN_NW)
218                         {
219                                 tx = -sx + 8;
220                                 ty = -sy + 8;
221                         }
222                         else if ((m_flags & mpALIGNMASK) == mpALIGN_SW)
223                         {
224                                 tx = -sx + 8;
225                                 ty = sy - 8 - ty;
226                         }
227                         else
228                         {
229                                 tx = sx - tx - 8;
230                                 ty = sy - 8 - ty;
231                         }
232                 }
233                 //else
234                 //{
235                 //}
236
237                 dc.DrawText( m_name, tx, ty);
238         }
239 }
240
241 //-----------------------------------------------------------------------------
242 // mpLayer implementations - furniture (scales, ...)
243 //-----------------------------------------------------------------------------
244
245 #define mpLN10 2.3025850929940456840179914546844
246
247 IMPLEMENT_CLASS(mpScaleX, mpLayer)
248
249 mpScaleX::mpScaleX(wxString name)
250
251         SetName(name);/*
252         SetFont(*wxSMALL_FONT);
253         SetPen(*wxGREY_PEN);*/
254
255         wxFont ff( *wxSMALL_FONT);
256         wxPen pp( *wxGREY_PEN);
257         SetPen( pp );
258         SetFont( ff );
259 }
260
261 void mpScaleX::Plot(wxDC & dc, mpWindow & w)
262 {
263         dc.SetPen( m_pen);
264         dc.SetFont( m_font);
265
266         const int orgy   = (int)(w.GetPosY() * w.GetScaleY());
267         const int extend = w.GetScrX()/2;
268
269         dc.DrawLine( -extend, orgy, extend, orgy);
270
271         const double dig  = floor( log( 128.0 / w.GetScaleX() ) / mpLN10 );
272         const double step = exp( mpLN10 * dig);
273         const double end  = w.GetPosX() + (double)extend / w.GetScaleX();
274
275         wxCoord tx, ty;
276         wxString s;
277         wxString fmt;
278         int tmp = (int)dig;
279         if (tmp>=1)
280         {
281                 fmt = wxT("%.f");
282         }
283         else
284         {
285                 tmp=8-tmp;
286                 fmt.Printf(wxT("%%.%df"), tmp >= -1 ? 2 : -tmp);
287         }
288
289         double n = floor( (w.GetPosX() - (double)extend / w.GetScaleX()) / step ) * step ;
290
291         tmp=-65535;
292         for (;n < end; n += step)
293         {
294                 const int p = (int)((n - w.GetPosX()) * w.GetScaleX());
295                 dc.DrawLine( p, orgy, p, orgy+4);
296
297                 s.Printf(fmt, n);
298                 dc.GetTextExtent(s, &tx, &ty);
299                 if ((p-tx/2-tmp) > 64)
300                 {
301                         dc.DrawText( s, p-tx/2, orgy+4);
302                         tmp=p+tx/2;
303                 }
304         }
305
306         dc.GetTextExtent(m_name, &tx, &ty);
307         dc.DrawText( m_name, extend - tx - 4, orgy + 4 + ty);
308 }
309
310 IMPLEMENT_CLASS(mpScaleY, mpLayer)
311
312 mpScaleY::mpScaleY(wxString name)
313
314         SetName(name);/*
315         SetFont(*wxSMALL_FONT);
316         SetPen(*wxGREY_PEN);*/
317         wxFont ff( *wxSMALL_FONT);
318         wxPen pp( *wxGREY_PEN);
319         SetPen( pp );
320         SetFont( ff );
321 }
322
323 void mpScaleY::Plot(wxDC & dc, mpWindow & w, int orgy)
324 {
325         dc.SetPen( m_pen);
326         dc.SetFont( m_font);
327
328         const int orgx   = -(int)(w.GetPosX() * w.GetScaleX());
329         const int extend = w.GetScrY()/2;
330
331         double sizedc = dc.GetSize().GetHeight()-orgy;
332
333         dc.DrawLine( orgx, GetYTranslated(sizedc, -extend), orgx, GetYTranslated(sizedc, extend));
334
335         const double dig  = floor( log( 128.0 / w.GetScaleY() ) / mpLN10 );
336         const double step = exp( mpLN10 * dig);
337         const double end  = w.GetPosY() + (double)extend / w.GetScaleY();
338
339         wxCoord tx, ty;
340         wxString s;
341         wxString fmt;
342         int tmp = (int)dig;
343         if (tmp>=1)
344         {
345                 fmt = wxT("%.f");
346         }
347         else
348         {
349                 tmp=8-tmp;
350                 fmt.Printf(wxT("%%.%df"), tmp >= -1 ? 2 : -tmp);
351         }
352
353         double n = floor( (w.GetPosY() - (double)extend / w.GetScaleY()) / step ) * step ;
354
355         tmp=65536;
356         for (;n < end; n += step)
357         {
358                 const int p = (int)((w.GetPosY() - n) * w.GetScaleY());
359                 dc.DrawLine( orgx, GetYTranslated(sizedc, p), orgx+4, GetYTranslated(sizedc,p));
360
361                 s.Printf(fmt, n);
362                 dc.GetTextExtent(s, &tx, &ty);
363                 if ((tmp-p+ty/2) > 32)
364                 {
365                         dc.DrawText( s, orgx+4, GetYTranslated(sizedc,p-ty/2));
366                         tmp=p-ty/2;
367                 }
368         }
369
370         dc.GetTextExtent(m_name, &tx, &ty);
371         dc.DrawText( m_name, orgx-tx-4, GetYTranslated(sizedc,-extend + ty + 4));
372 }
373
374 //-----------------------------------------------------------------------------
375 // mpWindow
376 //-----------------------------------------------------------------------------
377
378 IMPLEMENT_DYNAMIC_CLASS(mpWindow, wxScrolledWindow)
379
380 BEGIN_EVENT_TABLE(mpWindow, wxScrolledWindow)
381 EVT_PAINT    ( mpWindow::OnPaint)
382 EVT_SIZE     ( mpWindow::OnSize)
383 EVT_SCROLLWIN( mpWindow::OnScroll2)
384
385 EVT_MIDDLE_UP( mpWindow::OnShowPopupMenu)
386 EVT_RIGHT_UP ( mpWindow::OnShowPopupMenu)
387 EVT_MENU( mpID_CENTER,    mpWindow::OnCenter)
388 EVT_MENU( mpID_FIT,       mpWindow::OnFit)
389 EVT_MENU( mpID_ZOOM_IN,   mpWindow::OnZoomIn)
390 EVT_MENU( mpID_ZOOM_OUT,  mpWindow::OnZoomOut)
391 //EVT_MENU( mpID_LINE_GUIDES, mpWindow::OnGuideLines)
392 // New method that belongs to the mpWindow
393 EVT_MENU( mpID_LOCKASPECT,mpWindow::OnLockAspect)
394 END_EVENT_TABLE()
395
396 mpWindow::mpWindow( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag )
397 : wxScrolledWindow( parent, id, wxDefaultPosition, wxDefaultSize, flag, wxT("wxPlotter") )
398 {
399         m_scaleX = m_scaleY = 1.0;
400         m_posX   = m_posY   = 0;
401         m_scrX   = m_scrY   = 64;
402         m_minX   = m_minY   = 0;
403         m_maxX   = m_maxY   = 0;
404         maxScrX = maxScrY   = 200;
405         minScrX = minScrY   = 0;
406         m_clickedX =  0;
407         m_clickedY = 5000;
408         m_lockaspect = FALSE;
409         offsetX = offsetY = 0;
410         offsetPixelX = offsetPixelY= 0;
411         _bitmap_functions=NULL;
412
413         real_guideLine_X = -1;
414         real_guideLine_Y = -1;
415         drawGuides = true;
416         type=1;
417
418         m_popmenu.Append( mpID_CENTER,     _("Center"),      _("Center plot view to this position"));
419         m_popmenu.Append( mpID_FIT,        _("Fit"),         _("Set plot view to show all items"));
420         m_popmenu.Append( mpID_ZOOM_IN,    _("Zoom in"),     _("Zoom in plot view."));
421         m_popmenu.Append( mpID_ZOOM_OUT,   _("Zoom out"),    _("Zoom out plot view."));
422         m_popmenu.AppendCheckItem( mpID_LOCKASPECT, _("Lock aspect"), _("Lock horizontal and vertical zoom aspect."));
423
424         m_popmenu.AppendCheckItem( mpID_LINE_GUIDES, _("Turn off guide lines"), _("Enables/Disables the guide lines"));
425
426         m_layers.DeleteContents(TRUE);
427         SetBackgroundColour( *wxWHITE );
428         EnableScrolling(FALSE, FALSE);
429         SetSizeHints(128, 128);
430         
431         //_bitmap_functions= new wxBitmap(700,800);
432
433         UpdateAll();
434 }
435
436 mpWindow::~mpWindow()
437 {
438 }
439
440 void mpWindow::Fit()
441 {
442         if (UpdateBBox())
443         {
444                 int cx, cy;
445                 GetClientSize( &cx, &cy);
446                 
447                 double d;
448                 d = m_maxX - m_minX;
449                 if (d!=0)
450                 {
451                         m_scaleX = cx/d;
452                         m_posX = m_minX + d/2;
453                 }
454                 d = m_maxY - m_minY;
455                 if (d!=0)
456                 {
457                         m_scaleY = cy/d;
458                         m_posY = m_minY + d/2;
459                 }
460
461                 if (m_lockaspect)
462                 {
463                         double s = (m_scaleX + m_scaleY)/2;
464                         m_scaleX = s;
465                         m_scaleY = s;
466                 }
467
468                 UpdateAll();
469         }
470 }
471
472 void mpWindow::ZoomIn()
473 {
474         m_scaleX = m_scaleX * 2;
475         m_scaleY = m_scaleY * 2;
476         UpdateAll();
477 }
478
479 void mpWindow::ZoomOut()
480 {
481         m_scaleX = m_scaleX / 2;
482         m_scaleY = m_scaleY / 2;
483         UpdateAll();
484 }
485
486 void mpWindow::LockAspect(bool enable)
487 {
488         m_lockaspect = enable;
489
490         m_popmenu.Check(mpID_LOCKASPECT, enable);
491
492         if (m_lockaspect)
493         {
494                 double s = (m_scaleX + m_scaleY)/2;
495                 m_scaleX = s;
496                 m_scaleY = s;
497         }
498
499         UpdateAll();
500 }
501
502 void mpWindow::OnShowPopupMenu(wxMouseEvent &event)
503 {
504         m_clickedX = event.GetX();
505         m_clickedY = event.GetY();
506         PopupMenu( &m_popmenu, event.GetX(), event.GetY());
507 }
508
509 void mpWindow::OnLockAspect(wxCommandEvent &event)
510 {
511         LockAspect( !m_popmenu.IsChecked(mpID_LOCKASPECT) );
512 }
513
514 void mpWindow::OnFit(wxCommandEvent &event)
515 {
516         Fit();
517 }
518
519 void mpWindow::OnCenter(wxCommandEvent &event)
520 {
521         int cx, cy;
522         GetClientSize(&cx, &cy);
523         SetPos( (double)(m_clickedX-cx/2) / m_scaleX + m_posX, (double)(cy/2-m_clickedY) / m_scaleY + m_posY);
524 }
525
526 void mpWindow::OnZoomIn(wxCommandEvent &event)
527 {
528         int cx, cy;
529         GetClientSize(&cx, &cy);
530         m_posX = (double)(m_clickedX-cx/2) / m_scaleX + m_posX;
531         m_posY = (double)(cy/2-m_clickedY) / m_scaleY + m_posY;
532         ZoomIn();
533 }
534
535 void mpWindow::OnZoomOut(wxCommandEvent &event)
536 {
537         ZoomOut();
538 }
539
540 void mpWindow::OnSize( wxSizeEvent &event )
541 {
542         UpdateAll();
543 }
544
545 bool mpWindow::AddLayer( mpLayer* layer)
546 {
547         bool ret = m_layers.Append( layer) != NULL;
548         UpdateAll();
549         return ret;
550 }
551
552 void mpWindow::DelLayer( mpLayer* layer)
553 {
554         m_layers.DeleteObject( layer);
555         UpdateAll();
556 }
557
558 void mpWindow::Refresh(bool eraseBackground, const wxRect* rect)
559 {
560         wxScrolledWindow::Refresh(false);
561 }
562
563
564 void mpWindow::OnPaint( wxPaintEvent &event )
565 {
566         wxPaintDC dc(this);
567         dc.GetSize(&m_scrX, &m_scrY);
568
569         //m_scrX=200;
570         //m_scrY=200;
571
572         wxMemoryDC temp_dc;
573         //_bitmap_functions->SetWidth(m_scrX);
574         //_bitmap_functions->SetHeight(m_scrY);
575         _bitmap_functions=new wxBitmap(m_scrX,m_scrY);
576         temp_dc.SelectObject(*_bitmap_functions);
577
578         // Background
579         //      wxColour colourParent =  wxColour(255,0,0);
580         temp_dc.SetBrush(wxBrush( *wxWHITE_BRUSH  ) );
581         temp_dc.SetPen(wxPen( *wxBLACK_PEN  ));
582         temp_dc.DrawRectangle(0,0,m_scrX,m_scrY);
583         
584
585         wxNode *node = m_layers.GetFirst();
586         while (node)
587         {
588                 ((mpLayer*)node->GetData())->Plot( temp_dc, *this);
589                 node = node->GetNext();
590         }
591         
592         //dc.SetDeviceOrigin(70,40);
593         //dc.SetAxisOrientation(false,true);
594         //temp_dc.SetAxisOrientation(true,false);
595         
596         //EED 14mai2009
597         //dc.Blit(0,0, m_scrX, m_scrY, &temp_dc,-70,-m_scrY+40);
598         
599         temp_dc.SetDeviceOrigin(0,0);
600         dc.Blit(0,0, m_scrX, m_scrY, &temp_dc,0,0);
601         
602         
603         delete _bitmap_functions; 
604         //_bitmap_functions
605         //dc.SetAxisOrientation(false,true);
606
607
608 }
609
610 /*
611 void mpWindow::OnPaint( wxPaintEvent &event )
612 {
613         wxPaintDC dc(this);
614         
615         //dc.BeginDrawing();
616         
617         dc.GetSize(&m_scrX, &m_scrY);
618         
619         //const int orgy   = m_scrY-40;
620         //dc.SetDeviceOrigin(70,orgy);
621         //dc.SetAxisOrientation(true,true);
622
623 //      wxMemoryDC temp_dc;
624 //      
625 //      //_bitmap_functions=new wxBitmap(m_scrX,m_scrY);
626 //      
627 //      _bitmap_functions->SetWidth(100);//m_scrX);
628 //      _bitmap_functions->SetHeight(200);//m_scrY);
629 //      
630 //      temp_dc.SelectObject(*_bitmap_functions);
631 //      
632 //      // Background
633 //      wxColour colourParent =  wxColour(255,0,0);
634 //      temp_dc.SetBrush(wxBrush( colourParent ,wxSOLID  ));
635 //      temp_dc.SetPen(wxPen( colourParent ,1,wxSOLID  ));
636 //      temp_dc.DrawRectangle(0,0,100,200);
637 //      dc.Blit(0,0, 100, 200, &temp_dc,0,0);
638 //      //dc.SetDeviceOrigin( m_scrX>>1, m_scrY>>1);
639
640         wxNode *node = m_layers.GetFirst();
641         while (node)
642         {
643                 ((mpLayer*)node->GetData())->Plot( dc, *this);
644                 node = node->GetNext();
645         }
646         //temp_dc.SetAxisOrientation(true,false);
647         //dc.EndDrawing();
648         // dc.SetAxisOrientation(true,true);
649          //dc.Blit(70,(int)(-m_scrY+40),m_scrX-100,m_scrY-50,&temp_dc,0,0);
650 }
651 */
652
653 void mpWindow::OnScroll2(wxScrollWinEvent &event)
654 {
655         int width, height;
656         GetClientSize( &width, &height);
657         int px, py;
658         GetViewStart( &px, &py);
659
660         if (event.GetOrientation() == wxHORIZONTAL)
661         {
662                 SetPosX( (double)px / GetScaleX() + m_minX + (double)(width>>1)/GetScaleX());
663         }
664         else
665         {
666                 SetPosY( m_maxY - (double)py / GetScaleY() - (double)(height>>1)/GetScaleY());
667         }
668         event.Skip();
669 }
670
671 bool mpWindow::UpdateBBox()
672 {
673         bool first = TRUE;
674
675         wxNode *node = m_layers.GetFirst();
676
677         while(node)
678         {
679                 mpLayer* f = (mpLayer*)node->GetData();
680
681                 if (f->HasBBox())
682                 {
683                         if (first)
684                         {
685                                 first = FALSE;
686                                 m_minX = f->GetMinX(); m_maxX=f->GetMaxX();
687                                 m_minY = f->GetMinY(); m_maxY=f->GetMaxY();
688                         }
689                         else
690                         {
691                                 if (f->GetMinX()<m_minX) m_minX=f->GetMinX(); if (f->GetMaxX()>m_maxX) m_maxX=f->GetMaxX();
692                                 if (f->GetMinY()<m_minY) m_minY=f->GetMinY(); if (f->GetMaxY()>m_maxY) m_maxY=f->GetMaxY();
693                         }
694                 }
695                 node = node->GetNext();
696         }
697
698         return first == FALSE;
699 }
700
701 void mpWindow::UpdateAll()
702 {
703         if (UpdateBBox())
704         {
705                 int cx, cy;
706                 GetClientSize( &cx, &cy);
707
708                 const int sx = (int)((m_maxX - m_minX) * GetScaleX()); // JPRx
709                 const int sy = (int)((m_maxY - m_minY) * GetScaleY()); // JPRx
710                 const int px = (int)((GetPosX() - m_minX) * GetScaleX() - (cx>>1)); // JPRx
711                 const int py = (int)((GetPosY() - m_minY) * GetScaleY() - (cy>>1)); // JPRx
712                 SetScrollbars( 1, 1, sx, sy, px, py);
713         }
714
715         FitInside();
716         Refresh( false );
717 }
718
719 /*
720 * Guide lines menu handler method that reacts to the mpID_LINE_GUIDES cimmand event
721 * event The corresponding event to handle
722 */
723 /*
724 void mpWindow :: OnGuideLines (wxCommandEvent   &event)
725 {
726         wxString nextAction_text;
727         if( drawGuides )
728         {
729                 setLineGuidesCondition(false);
730                 nextAction_text << "Turn on guide lines";
731                 UpdateAll();
732         }
733         else
734         {
735                 setLineGuidesCondition(true);
736                 nextAction_text << "Turn off guide lines";
737                 UpdateAll();
738         }
739         m_popmenu.SetLabel ( mpID_LINE_GUIDES, nextAction_text ); 
740 }
741 */
742
743
744
745 bool mpWindow::drawGuideLines()
746         {
747                 return drawGuides;
748         }       
749