Qucs-GUI
0.0.19
|
00001 /*************************************************************************** 00002 diagram.h 00003 ----------- 00004 begin : Thu Oct 2 2003 00005 copyright : (C) 2003 by Michael Margraf 00006 email : michael.margraf@alumni.tu-berlin.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef DIAGRAM_H 00019 #define DIAGRAM_H 00020 00021 #include "graph.h" 00022 #include "marker.h" 00023 #include "element.h" 00024 #include "viewpainter.h" 00025 00026 #include <QFile> 00027 #include <QTextStream> 00028 #include <QList> 00029 00030 #define MIN_SCROLLBAR_SIZE 8 00031 00032 #define INVALID_STR QObject::tr(" <invalid>") 00033 00034 // ------------------------------------------------------------ 00035 // Enlarge memory block if neccessary. 00036 #define FIT_MEMORY_SIZE \ 00037 if(p >= p_end) { \ 00038 int pos = p - g->begin(); \ 00039 assert(pos<Size); \ 00040 Size += 256; \ 00041 g->resizeScrPoints(Size); \ 00042 p = g->begin() + pos; \ 00043 p_end = g->begin() + (Size - 9); \ 00044 } 00045 00046 struct Axis { 00047 double min, max; // least and greatest values of all graph data 00048 double low, up; // the limits of the diagram 00049 bool log; // in "rectdiagram": logarithmic or linear 00050 QString Label; 00051 int numGraphs; // counts number of graphs using this axis 00052 bool GridOn; 00053 00054 bool autoScale; // manual limits or auto-scale ? 00055 double limit_min, limit_max, step; // if not auto-scale 00056 }; 00057 00058 00059 class Diagram : public Element { 00060 public: 00061 Diagram(int _cx=0, int _cy=0); 00062 virtual ~Diagram(); 00063 00064 virtual Diagram* newOne(); 00065 virtual int calcDiagram() { return 0; }; 00066 virtual void calcCoordinate 00067 (const double*, const double*, const double*, float*, float*, Axis const*) const {}; 00068 void calcCoordinateP (const double*x, const double*y, const double*z, Graph::iterator& p, Axis const* A) const; 00069 virtual void finishMarkerCoordinates(float&, float&) const; 00070 virtual void calcLimits() {}; 00071 virtual QString extraMarkerText(Marker const*) const {return "";} 00072 00073 virtual void paint(ViewPainter*); 00074 void setCenter(int, int, bool relative=false); 00075 void getCenter(int&, int&); 00076 void paintScheme(Schematic*); 00077 void Bounding(int&, int&, int&, int&); 00078 bool getSelected(int, int); 00079 bool resizeTouched(float, float, float); 00080 QString save(); 00081 bool load(const QString&, QTextStream*); 00082 00083 void getAxisLimits(Graph*); 00084 void updateGraphData(); 00085 void loadGraphData(const QString&); 00086 void recalcGraphData(); 00087 bool sameDependencies(Graph const*, Graph const*) const; 00088 int checkColumnWidth(const QString&, const QFontMetrics&, int, int, int); 00089 00090 virtual bool insideDiagram(float, float) const; 00091 bool insideDiagramP(Graph::iterator const& ) const; 00092 Marker* setMarker(int x, int y); 00093 00094 QString Name; // identity of diagram type (e.g. Polar), used for saving etc. 00095 QPen GridPen; 00096 00097 QList<Graph *> Graphs; 00098 QList<Arc *> Arcs; 00099 QList<Line *> Lines; 00100 QList<Text *> Texts; 00101 00102 int x3, y3; 00103 Axis xAxis, yAxis, zAxis; // axes (x, y left, y right) 00104 int State; // to remember which resize area was touched 00105 00106 bool hideLines; // for "Rect3D": hide invisible lines ? 00107 int rotX, rotY, rotZ; // for "Rect3D": rotation around x, y and z axis 00108 00109 protected: 00110 void calcSmithAxisScale(Axis*, int&, int&); 00111 void createSmithChart(Axis*, int Mode=7); 00112 void calcPolarAxisScale(Axis*, double&, double&, double&); 00113 void createPolarDiagram(Axis*, int Mode=3); 00114 00115 bool calcAxisScale(Axis*, double&, double&, double&, double&, double); 00116 bool calcAxisLogScale(Axis*, int&, double&, double&, double&, int); 00117 bool calcYAxis(Axis*, int); 00118 virtual void createAxisLabels(); 00119 00120 int regionCode(float, float) const; 00121 virtual void clip(Graph::iterator &) const; 00122 void rectClip(Graph::iterator &) const; 00123 00124 virtual void calcData(Graph*); 00125 00126 private: 00127 int Bounding_x1, Bounding_x2, Bounding_y1, Bounding_y2; 00128 }; 00129 00130 #endif