plotmapbase.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                          plotmapbase.h  -  description
00003                              -------------------
00004     begin                : Tue Jul 22 2003
00005     copyright            : (C) 2003-2006 by Ben Swerts
00006     email                : bswerts@users.sourceforge.net
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 
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);       // constructor
00051     ~PlotMapBase();                     // destructor
00052 
00053     bool loadMapFile(const QString filename, const bool noerrors = false);      // Loads a map file with a specified name
00054 
00055   public slots:  
00056     bool loadMapFile();                 // Loads a map file and asks for a filename
00057 
00058   signals:
00059     void optionsChanged();              // signal which fires when optiosn have changed
00060     
00061   protected:
00062     void mousePressEvent(QMouseEvent* e);         // handles mouse press events
00063     void mouseReleaseEvent(QMouseEvent* e);       // handles mouse release events
00064     void mouseMoveEvent(QMouseEvent* e);          // handles the mouse move events for the pixmap
00065     //void paintEvent(QPaintEvent* e);    // handles repaints of the widget
00066 
00067   private slots:
00068     void saveImage();                   // saves the image
00069     void showOptions();                 // shows the options widget
00070     void applyOptions();                // applies the options
00071     void autoApply(bool state);         // turns on/off auto applying of options
00072     void resetOptions();                // resets the options to their defaults
00073        
00074   private:
00075     void makeConnections();             // Sets up all permanent connections
00076     void init();                        // Initializes the dialog
00077     void updateImage();                 // Updates the image from the current settings
00078     void updatePixmap();                // update the pixmap from density values
00079     void updateCrosses();               // update the atoms to be drawn as crosses
00080     void updateIsoLines();              // update the points making up the isolines
00081     QColor plotColor(const QColor foregroundColor, const QColor backgroundColor, const double opaqueness);    // returns the foreground with opaqueness on the backgroundColor
00082     bool onPixmap(const QPoint position);         // returns whether the position is on the pixmaplabel
00083     QPoint mapToImage(const QPoint position);     // returns the image-pixel-position of position
00084     Point3D<double> interpolate2D(const Point3D<double>& point1, const Point3D<double>& point2, const double density1, const double density2, const double isoLevel);       // calculates the interpolated point  
00085     bool hasPoint(const unsigned int segment, const unsigned int level, const vector<map<unsigned int, unsigned int>* >& segmentMaps); // returns true if segment has a Point3D for level
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); // returns the point correspondig to a segment
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); // starts a search for an isoline
00088     bool getNeighbours(const unsigned int currentSegment, const unsigned int previousSegment, unsigned int& segment1, unsigned int& segment2, unsigned int& segment3); // returns the neighbouring segments (false if edge)
00089     bool isHorizontal(const unsigned int segment); // returns true if a segment is horizontal
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); // recursively completes a polygon
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); // search for the next curve to add in the CCW direction on the top row
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); // search for the next curve to add in the CW direction on the top row
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); // search for the next curve to add in the CCW direction on the right column
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); // search for the next curve to add in the CW direction on the right column
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); // search for the next curve to add in the CCW direction on the bottom row
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); // search for the next curve to add in the CW direction on the bottom row
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); // search for the next curve to add in the CCW direction on the left column
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); // search for the next curve to add in the CW direction on the left column
00099     QRect labelRect() const;            // return the inner geometry of plotLabel with respect to the widget
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 

Generated on Fri May 19 14:31:55 2006 for Brabosphere by  doxygen 1.4.6-NO