00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00020
00021 #ifndef PLOTMAPBASE_H
00022 #define PLOTMAPBASE_H
00023
00025
00027 #include <map>
00028 #include <vector>
00029 using std::map;
00030 using std::vector;
00031
00033 class QColor;
00034 class QImage;
00035 class QPoint;
00036 class QString;
00037
00039 #include <plotmapwidget.h>
00040 class PlotMapExtensionWidget;
00041 class PlotMapLabel;
00042 #include "point3d.h"
00043
00045 class PlotMapBase : public PlotMapWidget
00046 {
00047 Q_OBJECT
00048
00049 public:
00050 PlotMapBase(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0);
00051 ~PlotMapBase();
00052
00053 bool loadMapFile(const QString filename, const bool noerrors = false);
00054
00055 public slots:
00056 bool loadMapFile();
00057
00058 signals:
00059 void optionsChanged();
00060
00061 protected:
00062 void mousePressEvent(QMouseEvent* e);
00063 void mouseReleaseEvent(QMouseEvent* e);
00064 void mouseMoveEvent(QMouseEvent* e);
00065
00066
00067 private slots:
00068 void saveImage();
00069 void showOptions();
00070 void applyOptions();
00071 void autoApply(bool state);
00072 void resetOptions();
00073
00074 private:
00075 void makeConnections();
00076 void init();
00077 void updateImage();
00078 void updatePixmap();
00079 void updateCrosses();
00080 void updateIsoLines();
00081 QColor plotColor(const QColor foregroundColor, const QColor backgroundColor, const double opaqueness);
00082 bool onPixmap(const QPoint position);
00083 QPoint mapToImage(const QPoint position);
00084 Point3D<double> interpolate2D(const Point3D<double>& point1, const Point3D<double>& point2, const double density1, const double density2, const double isoLevel);
00085 bool hasPoint(const unsigned int segment, const unsigned int level, const vector<map<unsigned int, unsigned int>* >& segmentMaps);
00086 Point3D<double> getPoint(const unsigned int segment, const unsigned int level, const vector<map<unsigned int, unsigned int>* >& segmentMaps, const vector< vector<Point3D<double> >* >& segments);
00087 void startSearch(const unsigned int segment, const unsigned int level, const bool circular, const vector<map<unsigned int, unsigned int>* >& segmentMaps, vector<bool>& segmentVisited, const vector< vector<Point3D<double> >* >& segments);
00088 bool getNeighbours(const unsigned int currentSegment, const unsigned int previousSegment, unsigned int& segment1, unsigned int& segment2, unsigned int& segment3);
00089 bool isHorizontal(const unsigned int segment);
00090 void continuePolygon(const unsigned int startCurve, const unsigned int endCurve, unsigned int currentCurve, vector<Point3D<double> >& isoPolygon, vector<bool>& curveAdded, const Point3D<double>& startPoint, const bool fromStart, const double isoLevel);
00091 void nextPolygonCCWT(const unsigned int startCurve, const unsigned int endCurve, vector<Point3D<double> >& isoPolygon, vector<bool>& curveAdded, const Point3D<double>& startPoint, const Point3D<double>& refPoint, const double isoLevel);
00092 void nextPolygonCWT(const unsigned int startCurve, const unsigned int endCurve, vector<Point3D<double> >& isoPolygon, vector<bool>& curveAdded, const Point3D<double>& startPoint, const Point3D<double>& refPoint, const double isoLevel);
00093 void nextPolygonCCWR(const unsigned int startCurve, const unsigned int endCurve, vector<Point3D<double> >& isoPolygon, vector<bool>& curveAdded, const Point3D<double>& startPoint, const Point3D<double>& refPoint, const double isoLevel);
00094 void nextPolygonCWR(const unsigned int startCurve, const unsigned int endCurve, vector<Point3D<double> >& isoPolygon, vector<bool>& curveAdded, const Point3D<double>& startPoint, const Point3D<double>& refPoint, const double isoLevel);
00095 void nextPolygonCCWB(const unsigned int startCurve, const unsigned int endCurve, vector<Point3D<double> >& isoPolygon, vector<bool>& curveAdded, const Point3D<double>& startPoint, const Point3D<double>& refPoint, const double isoLevel);
00096 void nextPolygonCWB(const unsigned int startCurve, const unsigned int endCurve, vector<Point3D<double> >& isoPolygon, vector<bool>& curveAdded, const Point3D<double>& startPoint, const Point3D<double>& refPoint, const double isoLevel);
00097 void nextPolygonCCWL(const unsigned int startCurve, const unsigned int endCurve, vector<Point3D<double> >& isoPolygon, vector<bool>& curveAdded, const Point3D<double>& startPoint, const Point3D<double>& refPoint, const double isoLevel);
00098 void nextPolygonCWL(const unsigned int startCurve, const unsigned int endCurve, vector<Point3D<double> >& isoPolygon, vector<bool>& curveAdded, const Point3D<double>& startPoint, const Point3D<double>& refPoint, const double isoLevel);
00099 QRect labelRect() const;
00100
00101 template<typename T> void limitRange(const T& min, T& value, const T& max);
00102
00104 Point3D<unsigned int> numPoints;
00105 unsigned int numAtoms;
00106 vector< vector<double> > points;
00107 vector< Point3D<double> > coords;
00108 PlotMapExtensionWidget* options;
00109 QPoint mousePosition;
00110 PlotMapLabel* plotLabel;
00111 bool loadInProgress;
00112 Point3D<double> origin, delta;
00113 double maxValue, minValue;
00114 vector< vector<Point3D<double> >* > isoCurves;
00115 vector<QColor> isoCurveColors;
00116
00118 static const double AUTOANG;
00119 };
00120
00121 #endif
00122