NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
wx.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * wx.cpp is part of Math Graphic Library *
3 * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU Library General Public License as *
7 * published by the Free Software Foundation; either version 3 of the *
8 * License, or (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU Library General Public *
16 * License along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20//-----------------------------------------------------------------------------
21#include <wx/dcclient.h>
22#include <wx/msgdlg.h>
23#include <wx/clipbrd.h>
24#include <wx/dataobj.h>
25#include <wx/menu.h>
26#include <wx/scrolwin.h>
27#include <wx/artprov.h>
28
29#include <cmath>
30
31#include <mgl2/canvas_wnd.h>
32#include "wx.h"
33
34#include "../common/datastructures.h"
35#include "../kernel/core/ui/language.hpp"
36
37#include "terminal/terminal.hpp"
38#include "graphviewer.hpp"
39
40#include "icons/addtext.xpm"
41#include "icons/addline.xpm"
42#include "icons/addrect.xpm"
43#include "icons/addcirc.xpm"
44#include "icons/rotate_new.xpm"
45#include "icons/zoom_new.xpm"
46#include "icons/newstart1.xpm"
47#include "icons/newstop1.xpm"
48
49extern Language _guilang;
50
51//-----------------------------------------------------------------------------
52class mglCanvasWX : public mglCanvasWnd
53{
54friend class wxMGL;
55public:
56 int sshow;
58 wxWindow *Wnd;
59
61 virtual ~mglCanvasWX();
62
64 void Window(int argc, char **argv, int (*draw)(mglBase *gr, void *p), const char *title,
65 void *par=NULL, void (*reload)(void *p)=NULL, bool maximize=false);
70 void ToggleRotate();
71 void ToggleZoom();
72 void ToggleNo();
73 void Update();
74 void Adjust();
75 void GotoFrame(int d);
76 void Animation();
77
78protected:
79 wxScrolledWindow *scroll;
80 wxMenu *popup;
81
82 void MakeMenu();
83};
84
85//-----------------------------------------------------------------------------
86const wxString ScriptName(L"default");
87
88enum
89{
92};
93
94BEGIN_EVENT_TABLE(wxMGL, wxWindow)
95 EVT_TIMER (TIMER_ID, wxMGL::OnNextSlide)
96 EVT_PAINT (wxMGL::OnPaint)
98 EVT_SIZE (wxMGL::OnSize)
99 EVT_LEFT_DOWN (wxMGL::OnMouseLeftDown)
100 EVT_RIGHT_DOWN (wxMGL::OnMouseDown)
101 EVT_MIDDLE_DOWN (wxMGL::OnMouseDown)
102 EVT_LEFT_UP (wxMGL::OnMouseLeftUp)
103 EVT_RIGHT_UP (wxMGL::OnMouseRightUp)
104 EVT_MOTION (wxMGL::OnMouseMove)
105 EVT_KEY_DOWN (wxMGL::OnKeyDown)
106 EVT_NAVIGATION_KEY(wxMGL::OnNavigationKey)
107// EVT_ENTER_WINDOW(wxMGL::OnEnter)
108 EVT_LEAVE_WINDOW(wxMGL::OnLeave)
109 EVT_CLOSE (wxMGL::OnClose)
110
121
122
123
124
125
126
127
139wxMGL::wxMGL(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, bool frameless, const wxString& name) : wxWindow(parent, id, pos, size, style, name)
140{
141 AutoResize = true;
142 draw_par = nullptr;
143 draw_func = 0;
144 gr = nullptr;
145 popup = nullptr;
146 draw_cl = nullptr;
148 zoom_x0 = zoom_y0 = 0;
149 zoom_x1 = zoom_y1 = 1;
150 l_x1 = l_y1 = 0;
151 start_x = start_y = 0;
154 drawModeActive = false;
155 skiprotate = 0;
156 nFrameCounter = 0;
157 nFramesToSkip = 2;
158 timer = new wxTimer(this, TIMER_ID);
159 animation = false;
160
161 SetOwnBackgroundColour(*wxWHITE);
162
163 if (!frameless)
164 {
165 m_parentFrame = static_cast<wxFrame*>(parent);
166 // Initialize the toolbar
168
169 m_parentFrame->Bind(wxEVT_MENU, &wxMGL::OnMenuEvent, this, ID_GRAPH_EXPORT);
170 m_parentFrame->Bind(wxEVT_MENU, &wxMGL::OnMenuEvent, this, ID_GRAPH_COPY);
171 m_parentFrame->Bind(wxEVT_MENU, &wxMGL::OnMenuEvent, this, ID_GRAPH_ROTATE);
172 m_parentFrame->Bind(wxEVT_MENU, &wxMGL::OnMenuEvent, this, ID_GRAPH_ZOOM);
173 m_parentFrame->Bind(wxEVT_MENU, &wxMGL::OnMenuEvent, this, ID_GRAPH_RESET);
174 m_parentFrame->Bind(wxEVT_MENU, &wxMGL::OnMenuEvent, this, ID_GRAPH_NEXT);
175 m_parentFrame->Bind(wxEVT_MENU, &wxMGL::OnMenuEvent, this, ID_GRAPH_PREVIOUS);
176 m_parentFrame->Bind(wxEVT_MENU, &wxMGL::OnMenuEvent, this, ID_GRAPH_RUN);
177 m_parentFrame->Bind(wxEVT_MENU, &wxMGL::OnMenuEvent, this, ID_GRAPH_STOP);
178
179 for (int i = ID_GRAPH_DRAW_FIRST+1; i < ID_GRAPH_DRAW_LAST; i++)
180 m_parentFrame->Bind(wxEVT_MENU, &wxMGL::OnMenuEvent, this, i);
181
182 statusbar = m_parentFrame->CreateStatusBar(3);
183 int nWidths[] = {-2,-1,-1};
184 statusbar->SetFieldsCount(3, nWidths);
185 }
186 else
187 m_parentFrame = nullptr;
188}
189
190
197{
198 timer->Stop();
199
200 if (draw_cl)
201 delete draw_cl;
202
203 draw_cl = nullptr;
204}
205
206
216{
217 if (!m_parentFrame)
218 return;
219
220 if (gr->GetNumFrame() <= 1)
221 {
222 toptoolbar->EnableTool(ID_GRAPH_NEXT, false);
223 toptoolbar->EnableTool(ID_GRAPH_PREVIOUS, false);
224 toptoolbar->EnableTool(ID_GRAPH_RUN, false);
225 toptoolbar->EnableTool(ID_GRAPH_STOP, false);
226 }
227 else
228 {
229 wxString slidescount;
230 slidescount.Printf("%d / %d", gr->GetNumFrame(), gr->GetNumFrame());
231 statusbar->SetStatusText(slidescount, 2);
232 nFrameCounter = gr->GetNumFrame()-1;
233 }
234}
235
236
245{
246 return double(mgl_get_width(gr->Self())) / mgl_get_height(gr->Self());
247}
248
249
258{
259 if (!m_parentFrame)
260 return;
261
262 toptoolbar = m_parentFrame->CreateToolBar(wxTB_HORIZONTAL | wxTB_FLAT);
263 toptoolbar->AddTool(ID_GRAPH_EXPORT, _guilang.get("GUI_GRAPH_EXPORT"), wxArtProvider::GetBitmap(wxART_FILE_SAVE, wxART_TOOLBAR), _guilang.get("GUI_GRAPH_EXPORT"));
264 toptoolbar->AddTool(ID_GRAPH_COPY, _guilang.get("GUI_GRAPH_COPY"), wxArtProvider::GetBitmap(wxART_COPY, wxART_TOOLBAR), _guilang.get("GUI_GRAPH_COPY"));
265 toptoolbar->AddSeparator();
266
267 wxBitmap bm_rotate(rotate_new_xpm);
268 toptoolbar->AddTool(ID_GRAPH_ROTATE, _guilang.get("GUI_GRAPH_ROTATE"), bm_rotate, _guilang.get("GUI_GRAPH_ROTATE"), wxITEM_CHECK);
269 wxBitmap bm_zoom(zoom_new_xpm);
270 toptoolbar->AddTool(ID_GRAPH_ZOOM, _guilang.get("GUI_GRAPH_ZOOM"), bm_zoom, _guilang.get("GUI_GRAPH_ZOOM"), wxITEM_CHECK);
271 toptoolbar->AddTool(ID_GRAPH_RESET, _guilang.get("GUI_GRAPH_RESET"), wxArtProvider::GetBitmap(wxART_UNDO, wxART_TOOLBAR), _guilang.get("GUI_GRAPH_RESET"));
272 toptoolbar->AddSeparator();
273
274 toptoolbar->AddTool(ID_GRAPH_PREVIOUS, _guilang.get("GUI_GRAPH_PREVIOUS"), wxArtProvider::GetBitmap(wxART_GO_BACK, wxART_TOOLBAR), _guilang.get("GUI_GRAPH_PREVIOUS"));
275 toptoolbar->AddTool(ID_GRAPH_NEXT, _guilang.get("GUI_GRAPH_NEXT"), wxArtProvider::GetBitmap(wxART_GO_FORWARD, wxART_TOOLBAR), _guilang.get("GUI_GRAPH_NEXT"));
276 wxBitmap bm_run(newstart1_xpm);
277 toptoolbar->AddTool(ID_GRAPH_RUN, _guilang.get("GUI_GRAPH_RUN"), bm_run, _guilang.get("GUI_GRAPH_RUN"));
278 wxBitmap bm_stop(newstop1_xpm);
279 toptoolbar->AddTool(ID_GRAPH_STOP, _guilang.get("GUI_GRAPH_STOP"), bm_stop, _guilang.get("GUI_GRAPH_STOP"));
280 toptoolbar->EnableTool(ID_GRAPH_STOP, false);
281 toptoolbar->AddSeparator();
282
283 wxBitmap bm_addline(addline);
284 toptoolbar->AddTool(ID_GRAPH_LINE, _guilang.get("GUI_GRAPH_LINE"), bm_addline, _guilang.get("GUI_GRAPH_LINE"), wxITEM_CHECK);
285 wxBitmap bm_addrect(addrect);
286 toptoolbar->AddTool(ID_GRAPH_RECT, _guilang.get("GUI_GRAPH_RECT"), bm_addrect, _guilang.get("GUI_GRAPH_RECT"), wxITEM_CHECK);
287 wxBitmap bm_addcirc(addcirc);
288 toptoolbar->AddTool(ID_GRAPH_CIRCLE, _guilang.get("GUI_GRAPH_CIRCLE"), bm_addcirc, _guilang.get("GUI_GRAPH_CIRCLE"), wxITEM_CHECK);
289 wxBitmap bm_addtext(addtext);
290 toptoolbar->AddTool(ID_GRAPH_TEXT, _guilang.get("GUI_GRAPH_TEXT"), bm_addtext, _guilang.get("GUI_GRAPH_TEXT"), wxITEM_CHECK);
291
292 styling = new wxTextCtrl(toptoolbar, wxID_ANY, "B-__");
293
294 toptoolbar->AddControl(styling, "STYLE");
295 toptoolbar->Realize();
296}
297
298
308{
309 if (!m_parentFrame)
310 return;
311
312 static const wxString fileFilter = "PNG (*.png)|*.png|JPG (*.jpg)|*.jpg;*.jpeg|EPS (*.eps)|*.eps|SVG (*.svg)|*.svg";
313
314 wxFileName fileName;
315 wxString path = static_cast<GraphViewer*>(m_parentFrame)->m_terminal->getPathSettings()[PLOTPATH];
316 wxFileDialog dlg(this, _guilang.get("GUI_DLG_SAVEAS"), path, "graph", fileFilter, wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR);
317
318 // ie, user clicked cancel
319 if (dlg.ShowModal() != wxID_OK)
320 {
321 return;
322 }
323
324 fileName = wxFileName(dlg.GetPath());
325
326 if (fileName.GetExt() == "png")
327 ExportPNG(fileName.GetFullPath());
328 else if (fileName.GetExt() == "jpg")
329 ExportJPG(fileName.GetFullPath());
330 else if (fileName.GetExt() == "eps")
331 ExportEPS(fileName.GetFullPath());
332 else if (fileName.GetExt() == "svg")
333 ExportSVG(fileName.GetFullPath());
334}
335
336
347void wxMGL::OnPaint(wxPaintEvent& event)
348{
349 wxPaintDC dc(this);
350
351 if (!gr && !draw_cl)
352 {
353 dc.SetBackground(wxBrush(*wxWHITE));
354 dc.Clear();
355 return;
356 }
357
358 if (!pic.IsOk())
359 Update();
360
361 // Draw the bitmap, which was selected by the
362 // Repaint function
363 dc.DrawBitmap(pic, 0, 0, false);
364
365 // Prepare the brushes for the drawing tools
366 dc.SetBrush(*wxTRANSPARENT_BRUSH);
367 dc.SetPen(*wxBLACK_DASHED_PEN);
368
369 // Draw the zooming rectangle
370 if (zoomactive)
371 dc.DrawRectangle(mouse_x0, mouse_y0, mouse_x1-mouse_x0, mouse_y1-mouse_y0);
372
373 // Draw the previews of the drawing objects
374 if (drawModeActive)
375 {
376 switch (drawMode)
377 {
378 case DM_LINE:
379 dc.DrawLine(start_x, start_y, mouse_x1, mouse_y1);
380 break;
381 case DM_CIRCLE:
382 dc.DrawCircle(start_x, start_y, hypot(mouse_x1-start_x, mouse_y1-start_y));
383 break;
384 case DM_RECT:
385 dc.DrawRectangle(start_x, start_y, mouse_x1-start_x, mouse_y1-start_y);
386 break;
387
388 }
389 }
390}
391
392
402void wxMGL::OnEraseBackground(wxEraseEvent& event)
403{
404 // Empty method to avoid flickering
405}
406
407
416void wxMGL::OnSize(wxSizeEvent& event)
417{
418 wxSize ev = event.GetSize();
419
420 // Do nothing, if the graph does not exist
421 if (!gr)
422 {
423 wxWindow::SetSize(ev);
424 Refresh();
425 return;
426 }
427
428 // Do nothing if the size did not change
429 if (mgl_get_width(gr->Self()) == ev.GetWidth() && mgl_get_height(gr->Self()) == ev.GetHeight())
430 return;
431
432 // Resize the image canvas
433 if (AutoResize && ev.GetWidth() > 0 && ev.GetHeight() > 0)
434 {
435 gr->SetSize(ev.GetWidth(), ev.GetHeight(), false);
436 Update();
437 }
438 else
439 SetSize(mgl_get_width(gr->Self()), mgl_get_height(gr->Self()));
440}
441
442
452void wxMGL::OnNextSlide(wxTimerEvent& )
453{
454 NextSlide();
455}
456
457
467void wxMGL::SetPer(int p)
468{
469 // Convert the integer percentage into a double value
470 if (100*dPerspective != p && p >= 0 && p < 100)
471 {
472 dPerspective = 0.01*p;
473 Repaint();
474 }
475}
476
477
486void wxMGL::SetPhi(int p)
487{
488 if (dAzimutalViewPoint != p)
489 {
491 Repaint();
492 }
493}
494
495
504void wxMGL::SetTet(int t)
505{
506 if (dPolarViewPoint != t)
507 {
508 dPolarViewPoint = t;
509 Repaint();
510 }
511}
512
513
522void wxMGL::SetZoom(bool z)
523{
524 if (bZoomingMode != z)
525 {
527 bZoomingMode = z;
528 bRotatingMode = false;
529 Update();
530 }
531
532 if (bZoomingMode)
533 SetCursor(wxCursor(wxCURSOR_MAGNIFIER));
534
536 statusbar->SetStatusText(_guilang.get("GUI_GRAPH_ZOOM"), 1);
537}
538
539
549{
550 if (bRotatingMode != r)
551 {
553 bZoomingMode = false;
554 bRotatingMode = r;
555 Update();
556 }
557
558 if (bRotatingMode)
559 SetCursor(wxCursor(wxCURSOR_HAND));
560
562 statusbar->SetStatusText(_guilang.get("GUI_GRAPH_ROTATE"), 1);
563}
564
565
576{
577 if (drawMode != dm)
578 {
579 bZoomingMode = false;
580 bRotatingMode = false;
581 drawMode = dm;
582 Update();
583 }
584
585 // Set the correct cursor
586 if (dm == DM_NONE)
587 SetCursor(wxCursor(wxCURSOR_ARROW));
588 else if (dm == DM_TEXT)
589 SetCursor(wxCursor(wxCURSOR_IBEAM));
590 else
591 SetCursor(wxCursor(wxCURSOR_CROSS));
592
593 // Unselect the view modification tools
594 toptoolbar->ToggleTool(ID_GRAPH_ZOOM, false);
595 toptoolbar->ToggleTool(ID_GRAPH_ROTATE, false);
596
597 // Unselect the drawing tools first
598 for (int i = ID_GRAPH_DRAW_FIRST+1; i < ID_GRAPH_DRAW_LAST; i++)
599 toptoolbar->ToggleTool(i, false);
600
601 // Select the correct drawing tool and
602 // display a corresponding message in the
603 // status bar
604 switch (dm)
605 {
606 case DM_LINE:
607 toptoolbar->ToggleTool(ID_GRAPH_LINE, true);
608 statusbar->SetStatusText(_guilang.get("GUI_GRAPH_LINE"), 1);
609 break;
610 case DM_CIRCLE:
611 toptoolbar->ToggleTool(ID_GRAPH_CIRCLE, true);
612 statusbar->SetStatusText(_guilang.get("GUI_GRAPH_CIRCLE"), 1);
613 break;
614 case DM_RECT:
615 toptoolbar->ToggleTool(ID_GRAPH_RECT, true);
616 statusbar->SetStatusText(_guilang.get("GUI_GRAPH_RECT"), 1);
617 break;
618 case DM_TEXT:
619 toptoolbar->ToggleTool(ID_GRAPH_TEXT, true);
620 statusbar->SetStatusText(_guilang.get("GUI_GRAPH_TEXT"), 1);
621 break;
622 }
623}
624
625
636void wxMGL::DrawCurrentObject(int end_x, int end_y)
637{
638 // Get the starting and ending postions
639 mglPoint startPoint = gr->CalcXYZ(start_x, start_y);
640 mglPoint endPoint = gr->CalcXYZ(end_x, end_y);
641
642 // Get the style from the toolbar
643 std::string style = styling->GetLineText(0).ToStdString();
644
645 // Draw the object
646 switch (drawMode)
647 {
648 case DM_LINE:
649 gr->Line(startPoint, endPoint, style.c_str());
650 Update();
651 break;
652 case DM_CIRCLE:
653 gr->Circle(startPoint, hypot(endPoint.x - startPoint.x, endPoint.y - startPoint.y), style.c_str());
654 Update();
655 break;
656 case DM_RECT:
657 gr->Face(startPoint, mglPoint(startPoint.x, endPoint.y), mglPoint(endPoint.x, startPoint.y), endPoint, style.c_str());
658 Update();
659 break;
660 case DM_TEXT:
661 wxString text;
662 wxTextEntryDialog dialog(this, _guilang.get("GUI_DLG_DRAWTEXT_QUESTION"), _guilang.get("GUI_DLG_DRAWTEXT"), wxEmptyString, wxOK | wxCANCEL | wxCENTRE);
663
664 if (dialog.ShowModal() == wxID_OK)
665 {
666 text = dialog.GetValue();
667 gr->Puts(startPoint, text.ToStdString().c_str(), style.c_str());
668 Update();
669 }
670
671 break;
672 }
673}
674
675
684{
685 SetPhi(0);
686 SetTet(0);
687 SetPer(0);
688 zoom_x0 = zoom_y0 = 0;
689 zoom_x1 = zoom_y1 = 1;
690 bZoomingMode = bRotatingMode = false;
691 Repaint();
692}
693
694
705void wxMGL::ZoomIn(int x, int y)
706{
707 double w_off = 2.0*x/double(GetSize().GetWidth())-1.0, h_off = -2.0*y/double(GetSize().GetHeight())+1.0;
708 mreal d;
709 d = (zoom_y1-zoom_y0)/4;
710 zoom_y0 = zoom_y0 + d + 2*h_off*d;
711 zoom_y1 = zoom_y1 - d + 2*h_off*d;
712 d = (zoom_x1-zoom_x0)/4;
713 zoom_x0 = zoom_x0 + d + 2*w_off*d;
714 zoom_x1 = zoom_x1 - d + 2*w_off*d;
715 Repaint();
716}
717
718
729void wxMGL::ZoomOut(int x, int y)
730{
731 double w_off = 2.0*x/double(GetSize().GetWidth())-1.0, h_off = -2.0*y/double(GetSize().GetHeight())+1.0;
732 mreal d;
733 d = (zoom_y1-zoom_y0)/2;
734 zoom_y0 = zoom_y0 - d - h_off*d;
735 zoom_y1 = zoom_y1 + d - h_off*d;
736 d = (zoom_x1-zoom_x0)/2;
737 zoom_x0 = zoom_x0 - d - w_off*d;
738 zoom_x1 = zoom_x1 + d - w_off*d;
739 Repaint();
740}
741
742
751{
752 if (!draw_cl && !gr)
753 return;
754
755 if (draw_func || draw_cl)
756 {
757 if (!vAnimationBuffer.size() || vAnimationBuffer.size() < (size_t)gr->GetNumFrame())
758 {
759 if (bRotatingMode)
760 gr->Zoom(0,0,1,1);
761
762 if (draw_func)
763 draw_func(gr->Self(), draw_par); // drawing itself
764 else if (draw_cl)
765 {
766 draw_cl->Draw(gr);
767 }
768
769 const char *buf = mgl_get_mess(gr->Self());
770
771 if (*buf)
772 {
773 wxMessageDialog dlg(this, wxString(buf,wxConvLocal), appName, wxOK);
774 dlg.ShowModal();
775 }
776 }
777 }
778 else if (mgl_get_num_frame(gr->Self())>0)
779 {
780 mgl_set_alpha(gr->Self(),alpha);
781 mgl_set_light(gr->Self(),light);
782 mgl_get_frame(gr->Self(),0);
783 }
784
785 MousePos.Empty();
786 Repaint();
787}
788
789
800{
801 const unsigned char *bb = mgl_get_rgb(gr->Self());
802 int w = mgl_get_width(gr->Self());
803 int h = mgl_get_height(gr->Self());
804 unsigned char *tmp = (unsigned char*)malloc(3*w*h);
805 memcpy(tmp, bb, 3*w*h);
806 return wxImage(w, h, tmp);
807}
808
809
819{
820 if (!draw_cl && !gr)
821 return;
822
824 return;
825
826 if (bZoomingMode)
827 gr->Zoom(zoom_x0, zoom_y0, zoom_x1, zoom_y1);
828
829 if (bRotatingMode)
831
832 if (dPerspective)
833 gr->Perspective(dPerspective);
834
835 // Set the new bitmap
836 setBitmap();
837
838 wxSize sz = GetSize();
839
840 // Resize the current window, if the picture does
841 // not fit
842 if (pic.GetWidth() != sz.GetWidth() || pic.GetHeight() != sz.GetHeight())
843 SetSize(pic.GetWidth(), pic.GetHeight());
844
845 Refresh();
846 wxWindow::Update();
847}
848
849
859void wxMGL::OnMouseLeftDown(wxMouseEvent &ev)
860{
861 long x=ev.GetX(), y=ev.GetY();
862
864 {
865 Refresh();
866 }
867
868 if (bZoomingMode)
869 zoomactive = true;
870
871 if (drawMode != DM_NONE)
872 {
873 start_x = x;
874 start_y = y;
875 drawModeActive = true;
876 }
877
878 mouse_x1 = mouse_x0 = x;
879 mouse_y1 = mouse_y0 = y;
880 ev.Skip();
881
882 // Forward the mouse event to the custom window
883 if (!m_parentFrame)
884 {
885 wxMouseEvent event(ev);
886 m_parent->GetEventHandler()->ProcessEvent(event);
887 }
888}
889
890
900void wxMGL::OnMouseDown(wxMouseEvent &ev)
901{
902 mouse_x1 = mouse_x0 = ev.GetX();
903 mouse_y1 = mouse_y0 = ev.GetY();
904 ev.Skip();
905}
906
907
917void wxMGL::OnMouseLeftUp(wxMouseEvent& ev)
918{
919 // Apply the zooming
920 if (bZoomingMode)
921 {
922 if (mouse_x0 == mouse_x1 || mouse_y0 == mouse_y1)
923 {
927 zoomactive = false;
928 return;
929 }
930
931 int w1 = GetSize().GetWidth(), h1 = GetSize().GetHeight();
932 mreal _x1, _x2, _y1, _y2;
933
934 _x1 = zoom_x0 + (zoom_x1-zoom_x0) * mouse_x0/mreal(w1);
935 _y1 = zoom_y1 - (zoom_y1-zoom_y0) * mouse_y1/mreal(h1);
936 _x2 = zoom_x0 + (zoom_x1-zoom_x0) * mouse_x1/mreal(w1);
937 _y2 = zoom_y1 - (zoom_y1-zoom_y0) * mouse_y0/mreal(h1);
938
939 zoom_x0 = _x1;
940 zoom_x1 = _x2;
941 zoom_y0 = _y1;
942 zoom_y1 = _y2;
943
944 if (zoom_x0 > zoom_x1)
945 {
946 _x1 = zoom_x0;
948 zoom_x1 = _x1;
949 }
950
951 if (zoom_y0 > zoom_y1)
952 {
953 _x1 = zoom_y0;
955 zoom_y1 = _x1;
956 }
957
960 zoomactive = false;
961 Update();
962 }
963
964 // Refresh the drawing after rotation
965 if (bRotatingMode)
966 {
967 gr->SetQuality(MGL_DRAW_NORM);
968 skiprotate = 0;
969 Update();
970 }
971
972 // Draw the current drawing object
973 if (drawMode != DM_NONE)
974 {
975 drawModeActive = false;
976 DrawCurrentObject(ev.GetX(), ev.GetY());
977 }
978}
979
980
990void wxMGL::OnMouseRightUp(wxMouseEvent &ev)
991{
992 if (popup && !bRotatingMode)
993 PopupMenu(popup, ev.GetPosition());
994
995 if (bRotatingMode)
996 {
997 gr->SetQuality(MGL_DRAW_NORM);
998 skiprotate = 0;
999 Update();
1000 }
1001 else if (bZoomingMode)
1002 {
1006 zoomactive = false;
1007 }
1008}
1009
1010
1020void wxMGL::OnMouseMove(wxMouseEvent &ev)
1021{
1022 if (!m_parentFrame)
1023 return;
1024
1025 long w = GetSize().GetWidth(), h = GetSize().GetHeight();
1026 mouse_x1 = ev.GetX();
1027 mouse_y1 = ev.GetY();
1028 mglPoint p = gr->CalcXYZ(mouse_x1, mouse_y1);
1029
1030 if (zoomactive)
1031 {
1032 mglPoint start = gr->CalcXYZ(mouse_x0,mouse_y0);
1033 MousePos.Printf(wxT("[%.4g, %.4g] --> [%.4g, %.4g]"), start.x, start.y, p.x, p.y);
1034 }
1035 else if (drawModeActive && drawMode != DM_NONE && drawMode != DM_TEXT)
1036 {
1037 mglPoint start = gr->CalcXYZ(start_x, start_y);
1038 MousePos.Printf(wxT("[%.4g, %.4g] --> [%.4g, %.4g]"), start.x, start.y, p.x, p.y);
1039 }
1040 else
1041 MousePos.Printf(wxT("[%.4g, %.4g]"), p.x, p.y);
1042
1043 // Apply the transformations related to the rotation
1044 // mode
1045 if (bRotatingMode && ev.ButtonIsDown(wxMOUSE_BTN_ANY))
1046 {
1047 gr->SetQuality(MGL_DRAW_DOTS);
1048 skiprotate++;
1049
1050 // Apply the rotation effect
1051 if (ev.ButtonIsDown(wxMOUSE_BTN_LEFT))
1052 {
1053 mreal ff = 240/sqrt(mreal(w*h));
1055 dPolarViewPoint += int((mouse_y0-mouse_y1)*ff);
1056
1057 if (dAzimutalViewPoint > 180)
1058 dAzimutalViewPoint -= 360;
1059
1060 if (dAzimutalViewPoint < -180)
1061 dAzimutalViewPoint += 360;
1062
1063 if (dPolarViewPoint > 180)
1064 dPolarViewPoint -= 360;
1065
1066 if (dPolarViewPoint < -180)
1067 dPolarViewPoint += 360;
1068 }
1069
1070 // Apply the perspective effect
1071 if (ev.ButtonIsDown(wxMOUSE_BTN_RIGHT))
1072 {
1073 mreal ff = 2.*(mouse_y0-mouse_y1)/w, gg = 0.5*(mouse_x1-mouse_x0)/h;
1074 mreal cx = (zoom_x0+zoom_x1)/2, cy = (zoom_y0+zoom_y1)/2;
1075 zoom_x0 = cx+(zoom_x0-cx)*exp(-ff);
1076 zoom_x1 = cx+(zoom_x1-cx)*exp(-ff);
1077 zoom_y0 = cy+(zoom_y0-cy)*exp(-ff);
1078 zoom_y1 = cy+(zoom_y1-cy)*exp(-ff);
1080
1081 if (dPerspective < 0)
1082 dPerspective = 0;
1083
1084 if (dPerspective >= 1)
1085 dPerspective = 0.9999;
1086 }
1087
1088 // Apply the shift effect (probably not used)
1089 if (ev.ButtonIsDown(wxMOUSE_BTN_MIDDLE))
1090 {
1091 mreal ff = 1./sqrt(mreal(w*h));
1092 mreal dx = (mouse_x0-mouse_x1)*ff*(zoom_x1-zoom_x0), dy = (mouse_y0-mouse_y1)*ff*(zoom_y1-zoom_y0);
1093 zoom_x0 += dx;
1094 zoom_x1 += dx;
1095 zoom_y0 -= dy;
1096 zoom_y1 -= dy;
1097 }
1098
1101 Update();
1102 }
1103
1104 if (bZoomingMode || drawMode != DM_NONE)
1105 Refresh(0);
1106
1107 statusbar->SetStatusText(MousePos);
1108}
1109
1110
1120void wxMGL::OnEnter(wxMouseEvent& event)
1121{
1122 if (m_parentFrame)
1123 this->SetFocus();
1124
1125 event.Skip();
1126}
1127
1128
1138void wxMGL::OnLeave(wxMouseEvent& event)
1139{
1140 if (bRotatingMode)
1141 {
1142 gr->SetQuality(MGL_DRAW_NORM);
1143 skiprotate = 0;
1144 Update();
1145 }
1146}
1147
1148
1158void wxMGL::OnKeyDown(wxKeyEvent& event)
1159{
1160 if (!m_parentFrame)
1161 {
1162 event.Skip();
1163 return;
1164 }
1165 // connecting the ESC Key with closing the viewer
1166 if (event.GetKeyCode() == WXK_ESCAPE)
1167 m_parent->Close();
1168
1169 // Start or stop the animation
1170 if (event.GetKeyCode() == ' ')
1171 {
1172 if (timer->IsRunning())
1173 Animation(false);
1174 else
1175 Animation(true);
1176 }
1177
1178 // Next Slide
1179 if (event.GetKeyCode() == WXK_RIGHT || event.GetKeyCode() == WXK_DOWN)
1180 NextSlide();
1181
1182 // Previous slide
1183 if (event.GetKeyCode() == WXK_LEFT || event.GetKeyCode() == WXK_UP)
1184 PrevSlide();
1185}
1186
1187
1197void wxMGL::OnNavigationKey(wxNavigationKeyEvent& event)
1198{
1199 if (!m_parentFrame)
1200 {
1201 event.Skip();
1202 return;
1203 }
1204
1205 // connect the navigation keys with next and previous image
1206 if (event.GetDirection())
1207 NextSlide();
1208 else
1209 PrevSlide();
1210}
1211
1212
1222void wxMGL::OnMenuEvent(wxCommandEvent& event)
1223{
1224 switch (event.GetId())
1225 {
1226 case ID_GRAPH_EXPORT:
1227 OnExport();
1228 break;
1229 case ID_GRAPH_COPY:
1230 this->Copy();
1231 break;
1232 case ID_GRAPH_ALPHA:
1233 //SetAlpha(!alpha);
1234 break;
1235 case ID_GRAPH_LIGHT:
1236 //SetLight(!light);
1237 break;
1238 case ID_GRAPH_ROTATE:
1240 break;
1241 case ID_GRAPH_ZOOM:
1243 break;
1244 case ID_GRAPH_CIRCLE:
1246 break;
1247 case ID_GRAPH_RECT:
1249 break;
1250 case ID_GRAPH_TEXT:
1252 break;
1253 case ID_GRAPH_LINE:
1255 break;
1256 case ID_GRAPH_RESET:
1258 zoom_x0 = zoom_y0 = 0;
1259 zoom_x1 = zoom_y1 = 1;
1260 Update();
1261 break;
1262 case ID_GRAPH_NEXT:
1263 NextSlide();
1264 break;
1265 case ID_GRAPH_PREVIOUS:
1266 PrevSlide();
1267 break;
1268 case ID_GRAPH_RUN:
1269 Animation(true);
1270 break;
1271 case ID_GRAPH_STOP:
1272 Animation(false);
1273 break;
1274 }
1275}
1276
1277
1287void wxMGL::OnClose(wxCloseEvent& event)
1288{
1289 // Stop the animation before closing
1290 Animation(false);
1291}
1292
1293
1304{
1305 if (animation && vAnimationBuffer.size() == (size_t)gr->GetNumFrame())
1306 {
1307 pic = wxBitmap(vAnimationBuffer[nFrameCounter]);
1308 }
1309 else if (animation)
1310 {
1311 vAnimationBuffer.emplace_back(ConvertFromGraph());
1312 pic = wxBitmap(vAnimationBuffer.back());
1313 }
1314 else
1315 pic = wxBitmap(ConvertFromGraph());
1316}
1317
1318
1328wxString mglSetExtension(const wxString &fname, const wxString& ext)
1329{
1330 if (fname.find('.') == std::string::npos)
1331 return fname + "." + ext;
1332 return fname;
1333}
1334//-----------------------------------------------------------------------------
1335// NOTE: this is replacement for wxString::char_str() which is for v.2.8 or later
1336const char* mglw_str(const wxString &str)
1337{
1338 return str.c_str();
1339}
1340//-----------------------------------------------------------------------------
1341void wxMGL::ExportPNG(wxString fname)
1342{
1343 if (fname.IsEmpty())
1344 fname = ScriptName;
1345 if (fname.IsEmpty())
1346 wxMessageBox(appName, wxT("No filename."),wxOK|wxICON_ERROR ,this);
1347 else
1348 gr->WriteFrame(mglw_str(mglSetExtension(fname,"png")));
1349}
1350//-----------------------------------------------------------------------------
1351void wxMGL::ExportPNGs(wxString fname)
1352{
1353 if (fname.IsEmpty())
1354 fname = ScriptName;
1355 if (fname.IsEmpty())
1356 wxMessageBox(appName, wxT("No filename."),wxOK|wxICON_ERROR ,this);
1357 else
1358 gr->WriteFrame(mglw_str(mglSetExtension(fname,"png")));
1359 //mgl_write_png_solid(gr->Self(),mglw_str(mglSetExtension(fname,"png")), mglw_str(appName));
1360}
1361//-----------------------------------------------------------------------------
1362void wxMGL::ExportJPG(wxString fname)
1363{
1364 if (fname.IsEmpty())
1365 fname = ScriptName;
1366 if (fname.IsEmpty())
1367 wxMessageBox(appName, wxT("No filename."),wxOK|wxICON_ERROR ,this);
1368 else
1369 gr->WriteFrame(mglw_str(mglSetExtension(fname,"jpg")));
1370 //mgl_write_jpg(gr->Self(),mglw_str(mglSetExtension(fname,"jpg")), mglw_str(appName));
1371}
1372//-----------------------------------------------------------------------------
1373void wxMGL::ExportBPS(wxString fname)
1374{
1375 if(fname.IsEmpty()) fname = ScriptName;
1376 if(fname.IsEmpty()) wxMessageBox(appName, wxT("No filename."),wxOK|wxICON_ERROR ,this);
1377 else
1378 {
1379 setlocale(LC_ALL, "C");
1380 mgl_write_bps(gr->Self(),mglw_str(mglSetExtension(fname,"eps")), mglw_str(appName));
1381 setlocale(LC_ALL, "");
1382 }
1383}
1384//-----------------------------------------------------------------------------
1385void wxMGL::ExportEPS(wxString fname)
1386{
1387 if(fname.IsEmpty())
1388 fname = ScriptName;
1389 if(fname.IsEmpty())
1390 wxMessageBox(appName, wxT("No filename."),wxOK|wxICON_ERROR ,this);
1391 else
1392 {
1393 setlocale(LC_ALL, "C");
1394 gr->WriteFrame(mglw_str(mglSetExtension(fname,"eps")));
1395 //mgl_write_eps(gr->Self(),mglw_str(mglSetExtension(fname,"eps")), mglw_str(appName));
1396 setlocale(LC_ALL, "");
1397 }
1398}
1399//-----------------------------------------------------------------------------
1400void wxMGL::ExportSVG(wxString fname)
1401{
1402 if(fname.IsEmpty())
1403 fname = ScriptName;
1404 if(fname.IsEmpty())
1405 wxMessageBox(appName, wxT("No filename."),wxOK|wxICON_ERROR ,this);
1406 else
1407 {
1408 setlocale(LC_ALL, "C");
1409 gr->WriteFrame(mglw_str(mglSetExtension(fname,"svg")));
1410 //mgl_write_svg(gr->Self(),mglw_str(mglSetExtension(fname,"svg")), mglw_str(appName));
1411 setlocale(LC_ALL, "");
1412 }
1413}
1414//-----------------------------------------------------------------------------
1416{
1417 if (wxTheClipboard->Open())
1418 {
1419 wxTheClipboard->SetData( new wxBitmapDataObject(pic) );
1420 wxTheClipboard->Close();
1421 }
1422}
1423//-----------------------------------------------------------------------------
1424void wxMGL::SetSize(int w, int h)
1425{
1426 gr->SetSize(w, h, false);
1427 wxWindow::SetSize(w, h);
1428 Update();
1429}
1430//-----------------------------------------------------------------------------
1432{
1433 wxSize sz=GetSize();
1434 gr->SetSize(sz.GetWidth(), sz.GetHeight(), false);
1435 Repaint();
1436}
1437
1438
1447{
1448 if (gr->GetNumFrame() > 1)
1449 {
1450 // Fill the animation buffer, if needed
1451 if (vAnimationBuffer.size() < (size_t)gr->GetNumFrame())
1452 {
1453 gr->GetFrame(nFrameCounter);
1454
1455 if (animation && m_parentFrame)
1456 statusbar->SetStatusText(_guilang.get("GUI_GRAPH_RENDERING"), 1);
1457 }
1458 else if (animation && m_parentFrame)
1459 statusbar->SetStatusText(_guilang.get("GUI_GRAPH_RENDERING_DONE"), 1);
1460
1461 nFrameCounter++;
1462
1463 if (nFrameCounter >= gr->GetNumFrame())
1464 nFrameCounter = 0;
1465
1466 if (m_parentFrame)
1467 {
1468 wxString slidescount;
1469 slidescount.Printf("%d / %d", nFrameCounter+1, gr->GetNumFrame());
1470 statusbar->SetStatusText(slidescount, 2);
1471 }
1472
1473 Update();
1474 }
1475}
1476
1477
1486{
1487 if (gr->GetNumFrame() > 1)
1488 {
1489 nFrameCounter--;
1490
1491 if (nFrameCounter < 0)
1492 nFrameCounter = gr->GetNumFrame()-1;
1493
1494 gr->GetFrame(nFrameCounter);
1495
1496 if (m_parentFrame)
1497 {
1498 wxString slidescount;
1499 slidescount.Printf("%d / %d", nFrameCounter+1, gr->GetNumFrame());
1500 statusbar->SetStatusText(slidescount, 2);
1501 }
1502
1503 Update();
1504 }
1505}
1506
1507
1517void wxMGL::Animation(bool st)
1518{
1519 if (!gr || gr->GetNumFrame() <= 1)
1520 return;
1521
1522 if (st)
1523 {
1524 if (m_parentFrame)
1525 {
1527 skiprotate = 0;
1529 toptoolbar->EnableTool(ID_GRAPH_EXPORT, false);
1530 toptoolbar->EnableTool(ID_GRAPH_COPY, false);
1531 toptoolbar->EnableTool(ID_GRAPH_ROTATE, false);
1532 toptoolbar->EnableTool(ID_GRAPH_ZOOM, false);
1533 toptoolbar->EnableTool(ID_GRAPH_RESET, false);
1534
1535 toptoolbar->EnableTool(ID_GRAPH_NEXT, false);
1536 toptoolbar->EnableTool(ID_GRAPH_PREVIOUS, false);
1537 toptoolbar->EnableTool(ID_GRAPH_RUN, false);
1538 toptoolbar->EnableTool(ID_GRAPH_STOP, true);
1539
1540 for (int i = ID_GRAPH_DRAW_FIRST+1; i < ID_GRAPH_DRAW_LAST; i++)
1541 toptoolbar->EnableTool(i, false);
1542 }
1543
1544 nFrameCounter = 0;
1545 animation = true;
1546
1547 timer->Start(40);
1548 }
1549 else
1550 {
1551 timer->Stop();
1552
1553 if (m_parentFrame)
1554 {
1555 toptoolbar->EnableTool(ID_GRAPH_EXPORT, true);
1556 toptoolbar->EnableTool(ID_GRAPH_COPY, true);
1557 toptoolbar->EnableTool(ID_GRAPH_ROTATE, true);
1558 toptoolbar->EnableTool(ID_GRAPH_ZOOM, true);
1559 toptoolbar->EnableTool(ID_GRAPH_RESET, true);
1560
1561 toptoolbar->EnableTool(ID_GRAPH_NEXT, true);
1562 toptoolbar->EnableTool(ID_GRAPH_PREVIOUS, true);
1563 toptoolbar->EnableTool(ID_GRAPH_RUN, true);
1564 toptoolbar->EnableTool(ID_GRAPH_STOP, false);
1565
1566 for (int i = ID_GRAPH_DRAW_FIRST+1; i < ID_GRAPH_DRAW_LAST; i++)
1567 toptoolbar->EnableTool(i, true);
1568
1569 statusbar->SetStatusText("", 1);
1570 }
1571
1572 animation = false;
1573
1574 if (vAnimationBuffer.size())
1575 {
1576 vAnimationBuffer.clear();
1577 vAnimationBuffer.shrink_to_fit();
1578 }
1579 }
1580}
1581
1582
1592{
1593 if (gr)
1594 {
1595 mglPoint p = gr->CalcXYZ(mouse_x0, mouse_y0);
1596 return wxString::Format("{%.12g,%.12g}", p.x, p.y);
1597 }
1598
1599 return "{nan,nan}";
1600}
1601
1602
This class handles the internal language system and returns the language strings of the selected lang...
Definition: language.hpp:38
std::string get(const std::string &sMessage, const std::vector< std::string > &vTokens) const
This member function returns the language string for the passed language identifier and replaces all ...
Definition: language.cpp:292
wxScrolledWindow * scroll
Scrolling area.
Definition: wx.cpp:79
wxMenu * popup
Popup menu.
Definition: wx.cpp:80
int sshow
Current state of animation switch (toggle button)
Definition: wx.cpp:56
void Adjust()
Adjust size of bitmap to window size.
virtual ~mglCanvasWX()
void ToggleRotate()
Switch on/off rotation by mouse.
void ToggleZoom()
Switch on/off zooming by mouse.
void Animation()
Run animation (I'm too lasy to change it)
void MakeMenu()
Create menu, toolbar and popup menu.
void ToggleAlpha()
Switch on/off transparency (do not overwrite switches in user drawing function)
wxWindow * Wnd
Pointer to window.
Definition: wx.cpp:58
void Window(int argc, char **argv, int(*draw)(mglBase *gr, void *p), const char *title, void *par=NULL, void(*reload)(void *p)=NULL, bool maximize=false)
Create a window for plotting. Now implemeted only for GLUT.
void GotoFrame(int d)
Show arbitrary frame (use relative step)
void Update()
Update picture by calling user drawing function.
void ToggleLight()
Switch on/off lighting (do not overwrite switches in user drawing function)
wxMGL * WMGL
Control which draw graphics.
Definition: wx.cpp:57
void ToggleNo()
Switch off all zooming and rotation.
Class is Wx widget which display MathGL graphics.
Definition: wx.h:39
wxString getClickedCoords()
Return the clicked coordinates as a parsable string. This is used by the custom GUI event handler.
Definition: wx.cpp:1591
wxBitmap pic
Pixmap for drawing (changed by update)
Definition: wx.h:172
void SetSize(int w, int h)
Set popup menu pointer.
Definition: wx.cpp:1424
double dPerspective
Value of perspective ( must be in [0,1) )
Definition: wx.h:174
wxString MousePos
Last mouse position.
Definition: wx.h:171
double GetRatio()
This member function returns the image aspect ratio.
Definition: wx.cpp:244
void PrevSlide()
Show previous slide.
Definition: wx.cpp:1485
void DrawCurrentObject(int end_x, int end_y)
This member function draws the drawing object selected by the toolbar after the user released the lef...
Definition: wx.cpp:636
void OnSize(wxSizeEvent &event)
This member function is the resizing event handler.
Definition: wx.cpp:416
void OnNextSlide(wxTimerEvent &evt)
Show next slide.
Definition: wx.cpp:452
void OnMouseDown(wxMouseEvent &ev)
This member function is the event handling function applied, when the user presses any of the other m...
Definition: wx.cpp:900
int mouse_y1
Temporary variables for mouse.
Definition: wx.h:199
@ DM_LINE
Definition: wx.h:133
@ DM_TEXT
Definition: wx.h:136
@ DM_CIRCLE
Definition: wx.h:135
@ DM_RECT
Definition: wx.h:134
@ DM_NONE
Definition: wx.h:132
mreal start_y
start coordinates for drawing
Definition: wx.h:186
int mouse_y0
Definition: wx.h:199
void OnMouseLeftDown(wxMouseEvent &ev)
This member function is the event handling function applied, when the user presses the left mouse but...
Definition: wx.cpp:859
wxToolBar * toptoolbar
Definition: wx.h:201
int mouse_x1
Definition: wx.h:199
void Repaint()
Get mouse rotation state.
Definition: wx.cpp:818
void SetRotate(bool r)
Switch on/off mouse rotation.
Definition: wx.cpp:548
bool AutoResize
Allow auto resizing (default is false)
Definition: wx.h:42
wxImage ConvertFromGraph()
This member function converts the RGB image created by the mglGraph object into a platform-independen...
Definition: wx.cpp:799
mreal zoom_y0
Definition: wx.h:187
bool alpha
Transparency state.
Definition: wx.h:175
mreal start_x
Definition: wx.h:186
std::vector< wxImage > vAnimationBuffer
Definition: wx.h:192
wxTextCtrl * styling
Definition: wx.h:205
bool bRotatingMode
Mouse rotation state.
Definition: wx.h:178
void OnLeave(wxMouseEvent &event)
Event handler for leaving the window. Will change the drawing mode to normal and redraw the windows c...
Definition: wx.cpp:1138
void OnMouseMove(wxMouseEvent &ev)
This member function is the event handling function applied, when the user moves the mouse.
Definition: wx.cpp:1020
void OnExport()
This member function displays the file dialog during exporting the current image displayed in the win...
Definition: wx.cpp:307
void SetZoom(bool z)
Switch on/off mouse zooming.
Definition: wx.cpp:522
void OnEraseBackground(wxEraseEvent &event)
This member function handles the background erasing process. It is disabled to avoid flickering (kind...
Definition: wx.cpp:402
mglGraph * gr
pointer to grapher
Definition: wx.h:165
int mouse_x0
Definition: wx.h:199
int nFramesToSkip
Definition: wx.h:182
void UpdateTools()
This member function dis- or enables the animation tools depending on whether an animation is availab...
Definition: wx.cpp:215
void InitializeToolbar()
This member function initializes the toolbar of the GraphViewer Window.
Definition: wx.cpp:257
double dAzimutalViewPoint
Rotation angles.
Definition: wx.h:173
void OnKeyDown(wxKeyEvent &event)
This member function is the event handling function applied, when the user presses a key.
Definition: wx.cpp:1158
void OnEnter(wxMouseEvent &event)
This member function is the event handling function applied, when the user moves the mouse in the win...
Definition: wx.cpp:1120
int skiprotate
Definition: wx.h:181
void SetPhi(int p)
Set Phi-angle value.
Definition: wx.cpp:486
wxString appName
Application name for message boxes.
Definition: wx.h:41
void OnNavigationKey(wxNavigationKeyEvent &event)
This member function is the event handling function applied, when the user presses a navigation key.
Definition: wx.cpp:1197
mglDraw * draw_cl
Definition: wx.h:169
bool bZoomingMode
Mouse zoom state.
Definition: wx.h:177
mreal zoom_x0
Definition: wx.h:187
void Animation(bool st=true)
Start animation.
Definition: wx.cpp:1517
int(* draw_func)(mglBase *gr, void *par)
Drawing function for window procedure. It should return the number of frames.
Definition: wx.h:168
void ExportBPS(wxString fname=L"")
export to bitmap EPS file
Definition: wx.cpp:1373
virtual ~wxMGL()
Destructor: stops the timer, if it is running and deletes the referenced drawing class.
Definition: wx.cpp:196
void ExportEPS(wxString fname=L"")
export to vector EPS file
Definition: wx.cpp:1385
wxStatusBar * statusbar
Definition: wx.h:202
mreal zoom_y1
Zoom in region.
Definition: wx.h:187
wxTimer * timer
Timer for animation.
Definition: wx.h:190
void OnMenuEvent(wxCommandEvent &event)
This member function is the event handling function for any events emitted by the toolbar.
Definition: wx.cpp:1222
bool drawModeActive
Flag, if the current draw mode is active => mouse down.
Definition: wx.h:184
void ZoomIn(int x, int y)
Zoom in graphics.
Definition: wx.cpp:705
mreal zoom_x1
Definition: wx.h:187
wxFrame * m_parentFrame
Definition: wx.h:200
void ExportJPG(wxString fname=L"")
export to JPEG file
Definition: wx.cpp:1362
void OnMouseRightUp(wxMouseEvent &ev)
This member function is the event handling function applied, when the user releases the right mouse b...
Definition: wx.cpp:990
bool animation
Definition: wx.h:180
wxMenu * popup
Pointer to pop-up menu.
Definition: wx.h:189
void SetPer(int p)
Set perspective value.
Definition: wx.cpp:467
void Restore()
Restore zoom and rotation to default values.
Definition: wx.cpp:683
void OnPaint(wxPaintEvent &event)
This member function is the redrawing and painting event handler. It will display the bitmap currentl...
Definition: wx.cpp:347
void ZoomOut(int x, int y)
Zoom out graphics.
Definition: wx.cpp:729
void ExportPNG(wxString fname=L"")
export to PNG file
Definition: wx.cpp:1341
void SetTet(int t)
Set Theta-angle value.
Definition: wx.cpp:504
mreal l_x1
Definition: wx.h:185
void Adjust()
Adjust plot size to fill entire window.
Definition: wx.cpp:1431
void Update()
Update picture.
Definition: wx.cpp:750
void setBitmap()
This function sets the current bitmap either by explicit conversion from the RGB data in the mglGraph...
Definition: wx.cpp:1303
int drawMode
Stores the current draw mode.
Definition: wx.h:183
bool zoomactive
Definition: wx.h:179
void OnMouseLeftUp(wxMouseEvent &ev)
This member function is the event handling function applied, when the user releases the left mouse bu...
Definition: wx.cpp:917
int nFrameCounter
Definition: wx.h:191
double dPolarViewPoint
Definition: wx.h:173
void * draw_par
Definition: wx.h:166
void SetDrawMode(int dm)
This member function selects the current drawing mode by dis- and enabling the tools and the other mo...
Definition: wx.cpp:575
void OnClose(wxCloseEvent &event)
This member function is the event handling function applied, when the window is closed.
Definition: wx.cpp:1287
bool light
Lightning state.
Definition: wx.h:176
void Copy()
copy graphics to clipboard
Definition: wx.cpp:1415
void ExportSVG(wxString fname=L"")
export to SVG file
Definition: wx.cpp:1400
void ExportPNGs(wxString fname=L"")
export to PNG file (no transparency)
Definition: wx.cpp:1351
mreal l_y1
start coordinates for line
Definition: wx.h:185
void NextSlide()
Show next slide.
Definition: wx.cpp:1446
@ PLOTPATH
@ ID_GRAPH_ALPHA
@ ID_GRAPH_DRAW_FIRST
@ ID_GRAPH_ROTATE
@ ID_GRAPH_ZOOM
@ ID_GRAPH_CIRCLE
@ ID_GRAPH_STOP
@ ID_GRAPH_TEXT
@ ID_GRAPH_LIGHT
@ ID_GRAPH_DRAW_LAST
@ ID_GRAPH_COPY
@ ID_GRAPH_LINE
@ ID_GRAPH_PREVIOUS
@ ID_GRAPH_RUN
@ ID_GRAPH_EXPORT
@ ID_GRAPH_RESET
@ ID_GRAPH_NEXT
@ ID_GRAPH_RECT
char name[32]
Definition: resampler.cpp:371
EVT_ERASE_BACKGROUND(wxTreeListHeaderWindow::OnEraseBackground) void wxTreeListHeaderWindow
END_EVENT_TABLE()
wxString mglSetExtension(const wxString &fname, const wxString &ext)
This function is used to append the extension to the filename, if needed.
Definition: wx.cpp:1328
const char * mglw_str(const wxString &str)
Definition: wx.cpp:1336
Language _guilang
@ LAST_ID
Definition: wx.cpp:91
@ TIMER_ID
Definition: wx.cpp:90
const wxString ScriptName(L"default")