FOX/ObjCryst++  1.10.X (development)
wxMultiGraph.h
1 /* ObjCryst++ Object-Oriented Crystallographic Library
2  (c) 2005- Vincent Favre-Nicolin vincefn@users.sourceforge.net
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 
19 #ifndef _WX_WXMULTIGRAPH_H_
20 #define _WX_WXMULTIGRAPH_H_
21 
22 #ifdef _MSC_VER // MS VC++ predefined macros....
23 #undef min
24 #undef max
25 #endif
26 #include <valarray>
27 #include <map>
28 #include <string>
29 
30 #include "wx/wxprec.h"
31 #ifdef __BORLANDC__
32  #pragma hdrstop
33 #endif
34 #ifndef WX_PRECOMP
35  #include "wx/wx.h"
36 #endif
37 #include "ObjCryst/wxCryst/wxCryst.h"
38 
39 /* WX
40 
41 Select colour using wxColourDatabase (wxTheColourDatabase
42 
43 All display is normalized to max-min, i.e. each tracked value has
44 its own scale. Zooming is therefore relative to [0.0-1.0]
45 
46 Choose displayed Y values using a wxChoice, for both Y axis
47 
48 The list of values to be displayed can be chosen from a wxListBox
49 
50 */
51 namespace ObjCryst
52 {
53 class WXMultiGraph:public wxWindow
54 {
55  public:
56  WXMultiGraph(wxFrame *frame);
57  virtual ~WXMultiGraph();
58  void OnPaint(wxPaintEvent &event);
59  void OnMouse(wxMouseEvent &event);
60  void OnMouseWheel(wxMouseEvent &event);
61  void OnKeyDown(wxKeyEvent &event);
65  unsigned long AddGraph(const std::string &name);
70  void SetGraphData(const unsigned long id,const std::valarray<float> &vx,
71  const std::valarray<float> &vy);
75  virtual void DeleteGraph(const unsigned long id);
80  void AutoScale(const long id=-1,const bool xmin=true,const bool xmax=true,
81  const bool ymin=true,const bool ymax=true);
82  void OnUpdateUI(wxUpdateUIEvent &event);
83  void OnSize(wxSizeEvent &event);
84  void SetXLabel(const wxString &xlabel);
85  void SetYLabel(const wxString &ylabel);
86  virtual void UpdateDisplay();
87  private:
89  void Data2Screen(float &x,float &y);
91  void Screen2Data(float &x,float &y);
92  struct GraphData
93  {
94  std::string name;
95  std::valarray<float> vx;
96  std::valarray<float> vy;
97  float xmin,xmax,ymin,ymax;
98  };
99  std::map<unsigned long, GraphData> mvData;
101  float mMinX,mMaxX,mMinY,mMaxY;
103  long mLeft,mRight,mTop,mBottom;
105  wxMenu* mpPopUpMenu;
109  float mDragX0,mDragY0;
111  CrystMutex mMutexData;
113  wxFrame *mpParentFrame;
115  wxString mXLabel;
117  wxString mYLabel;
118  DECLARE_EVENT_TABLE()
119 };
120 
121 
122 }//namespace
123 #endif
virtual void DeleteGraph(const unsigned long id)
Remove graph.
void SetGraphData(const unsigned long id, const std::valarray< float > &vx, const std::valarray< float > &vy)
Set data for a given graph.
float mDragX0
dragging origin (in reduced coordinates)
Definition: wxMultiGraph.h:109
long mLeft
The margins in pixels around the graph.
Definition: wxMultiGraph.h:103
void Screen2Data(float &x, float &y)
Convert screen (pixel) to data coordinates.
bool mIsDragging
Are we within a dragging event ?
Definition: wxMultiGraph.h:107
wxString mYLabel
Y label.
Definition: wxMultiGraph.h:117
float mMinX
The current min & max values along x and y.
Definition: wxMultiGraph.h:101
CrystMutex mMutexData
Mutex for the data.
Definition: wxMultiGraph.h:111
void Data2Screen(float &x, float &y)
Convert data to screen (pixel) coordinates.
wxFrame * mpParentFrame
parent frame
Definition: wxMultiGraph.h:113
wxMenu * mpPopUpMenu
Pop-up menu.
Definition: wxMultiGraph.h:105
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: Atom.cpp:47
unsigned long AddGraph(const std::string &name)
Add a graph.
wxString mXLabel
X label.
Definition: wxMultiGraph.h:115
void AutoScale(const long id=-1, const bool xmin=true, const bool xmax=true, const bool ymin=true, const bool ymax=true)
Auto-scale graph, i.e.