PlotMapBase Class Reference

#include <plotmapbase.h>

List of all members.


Detailed Description

This class shows 2D density maps from files created with potdicht.

It's a replacement for spfmap with added analysis possibilities. This class provides the functionality for PlotMapWidget. The actual rendering is done in PlotMapLabel. The optionwidgets are provided by PlotMapExtensionWidget.

Definition at line 45 of file plotmapbase.h.

Public Slots

bool loadMapFile ()
 Tries to load a map file.

Signals

void optionsChanged ()

Public Member Functions

 PlotMapBase (QWidget *parent=0, const char *name=0, bool modal=FALSE, WFlags fl=0)
 ~PlotMapBase ()
 The default destructor.
bool loadMapFile (const QString filename, const bool noerrors=false)
 Tries to load a map file with the specified name.

Protected Member Functions

void mousePressEvent (QMouseEvent *e)
 Overridden from PlotMapWidget::mousePressEvent. Initiates mousedrags.
void mouseReleaseEvent (QMouseEvent *e)
 Overridden from PlotMapWidget::mouseReleaseEvent.
void mouseMoveEvent (QMouseEvent *e)
 Overridden from PlotMapWidget::mouseMoveEvent.

Private Slots

void saveImage ()
 Saves the image to a file.
void showOptions ()
 Shows the options widget.
void applyOptions ()
 Applies the options to the image.
void autoApply (bool state)
 Turns automatic application of options on/off.
void resetOptions ()
 Resets the options to their defaults.

Private Member Functions

void makeConnections ()
 Sets up all permanent connections. Called once from the constructor.
void init ()
 Initializes the dialog. Called once from the constructor.
void updateImage ()
 Regenerates the image depending on the options.
void updatePixmap ()
 Regenerates the pixmap from density values depending on the options.
void updateCrosses ()
 Updates which atoms are displayed as crosses.
void updateIsoLines ()
 Updates the list of points with isodensity values.
QColor plotColor (const QColor foregroundColor, const QColor backgroundColor, const double opaqueness)
 Returns a color calculated as the foregroundColor with an opaqueness against the backgroundColor.
bool onPixmap (const QPoint position)
 Returns true if position is on the actual drawing area.
QPoint mapToImage (const QPoint position)
 Returns the pixel position in the image corresponding to the point position on the widget.
Point3D< double > interpolate2D (const Point3D< double > &point1, const Point3D< double > &point2, const double density1, const double density2, const double isoLevel)
 Calculates the interpolated point in 2D between point1 and point2 with density values of density1 and density2 respectively.
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 isoLevel index level.
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 Point3D corresponding to the segment for isoLevel index level.
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.
bool getNeighbours (const unsigned int currentSegment, const unsigned int previousSegment, unsigned int &segment1, unsigned int &segment2, unsigned int &segment3)
 Returns the neighbours of currentSegment not from the cell containing previousSegment.
bool isHorizontal (const unsigned int segment)
 Returns true if a segment is positioned horizontally.
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 adds edge-curves to form a polygon.
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)
 Find the next curve in a counterclockwise direction on the top row.
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)
 Find the next curve in a clockwise direction on the top row.
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)
 Find the next curve in a counterclockwise direction on the rightmost column.
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)
 Find the next curve in a clockwise direction on the rightmost column.
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)
 Find the next curve in a counterclockwise direction on the bottom row.
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)
 Find the next curve in a clockwise direction on the bottom row.
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)
 Find the next curve in a counterclockwise direction on the leftmost column.
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)
 Find the next curve in a clockwise direction on the leftmost column.
QRect labelRect () const
 Returns the inner geometry of plotLabel with respect to the widget with a provision for the aspect ratio.
template<typename T>
void limitRange (const T &min, T &value, const T &max)
 Limits the value between min and max.

Private Attributes

Point3D< unsigned int > numPoints
 The number of grid points in 2 directions.
unsigned int numAtoms
 The number of atoms.
vector< vector< double > > points
 The values of the grid points: points[numPointsY][NumPointsX].
vector< Point3D< double > > coords
 The coordinates of the atoms.
PlotMapExtensionWidget * options
 The widget that allows changing the options.
QPoint mousePosition
 Holds the start position of a mouse drag.
PlotMapLabelplotLabel
 Shows the resulting map.
bool loadInProgress
 Is set to true if the points array is being updated.
Point3D< double > origin
Point3D< double > delta
 The origin and cell size for the 3D grid.
double maxValue
double minValue
 The maximum and minimum values of the grid.
vector< vector< Point3D< double > > * > isoCurves
 A data structure containing all isodensity curves.
vector< QColor > isoCurveColors
 A vector containing the color of each curve.

Static Private Attributes

static const double AUTOANG = 1.0/1.889726342
 Conversion factor atomic units -> angstrom.


Constructor & Destructor Documentation

PlotMapBase::PlotMapBase QWidget *  parent = 0,
const char *  name = 0,
bool  modal = FALSE,
WFlags  fl = 0
 

Definition at line 75 of file plotmapbase.cpp.

PlotMapBase::~PlotMapBase  ) 
 

The default destructor.

Definition at line 104 of file plotmapbase.cpp.


Member Function Documentation

bool PlotMapBase::loadMapFile const QString  filename,
const bool  noerrors = false
 

Tries to load a map file with the specified name.

If noerrors = true, no error-messages will be shown.

Definition at line 111 of file plotmapbase.cpp.

bool PlotMapBase::loadMapFile  )  [slot]
 

Tries to load a map file.

Definition at line 253 of file plotmapbase.cpp.

void PlotMapBase::optionsChanged  )  [signal]
 

void PlotMapBase::mousePressEvent QMouseEvent *  e  )  [protected]
 

Overridden from PlotMapWidget::mousePressEvent. Initiates mousedrags.

Definition at line 270 of file plotmapbase.cpp.

void PlotMapBase::mouseReleaseEvent QMouseEvent *  e  )  [protected]
 

Overridden from PlotMapWidget::mouseReleaseEvent.

Handles mousedrags and shows statistics for the selected box.

Definition at line 279 of file plotmapbase.cpp.

void PlotMapBase::mouseMoveEvent QMouseEvent *  e  )  [protected]
 

Overridden from PlotMapWidget::mouseMoveEvent.

Handles mousedrags in progress and updates statistics.

Definition at line 364 of file plotmapbase.cpp.

void PlotMapBase::saveImage  )  [private, slot]
 

Saves the image to a file.

Definition at line 421 of file plotmapbase.cpp.

void PlotMapBase::showOptions  )  [private, slot]
 

Shows the options widget.

Definition at line 469 of file plotmapbase.cpp.

void PlotMapBase::applyOptions  )  [private, slot]
 

Applies the options to the image.

Definition at line 492 of file plotmapbase.cpp.

void PlotMapBase::autoApply bool  state  )  [private, slot]
 

Turns automatic application of options on/off.

Definition at line 499 of file plotmapbase.cpp.

void PlotMapBase::resetOptions  )  [private, slot]
 

Resets the options to their defaults.

Definition at line 512 of file plotmapbase.cpp.

void PlotMapBase::makeConnections  )  [private]
 

Sets up all permanent connections. Called once from the constructor.

Definition at line 541 of file plotmapbase.cpp.

void PlotMapBase::init  )  [private]
 

Initializes the dialog. Called once from the constructor.

Definition at line 572 of file plotmapbase.cpp.

void PlotMapBase::updateImage  )  [private]
 

Regenerates the image depending on the options.

Definition at line 581 of file plotmapbase.cpp.

void PlotMapBase::updatePixmap  )  [private]
 

Regenerates the pixmap from density values depending on the options.

Definition at line 600 of file plotmapbase.cpp.

void PlotMapBase::updateCrosses  )  [private]
 

Updates which atoms are displayed as crosses.

Definition at line 651 of file plotmapbase.cpp.

void PlotMapBase::updateIsoLines  )  [private]
 

Updates the list of points with isodensity values.

These points are calculated using a procedure related to the Marching Squares but without lookup tables. Two sets of curves are produced: one set used for isolines (one curve for each line) and one set used for polygons (one curve for each isolevel). Points are ordered so the lines can be drawn with drawPolyLine or drawPolygon.

Definition at line 676 of file plotmapbase.cpp.

QColor PlotMapBase::plotColor const QColor  foregroundColor,
const QColor  backgroundColor,
const double  opaqueness
[private]
 

Returns a color calculated as the foregroundColor with an opaqueness against the backgroundColor.

Definition at line 902 of file plotmapbase.cpp.

bool PlotMapBase::onPixmap const QPoint  position  )  [private]
 

Returns true if position is on the actual drawing area.

Definition at line 942 of file plotmapbase.cpp.

QPoint PlotMapBase::mapToImage const QPoint  position  )  [private]
 

Returns the pixel position in the image corresponding to the point position on the widget.

Definition at line 960 of file plotmapbase.cpp.

Point3D< double > PlotMapBase::interpolate2D const Point3D< double > &  point1,
const Point3D< double > &  point2,
const double  density1,
const double  density2,
const double  isoLevel
[private]
 

Calculates the interpolated point in 2D between point1 and point2 with density values of density1 and density2 respectively.

The target density is isoLevel.

Definition at line 977 of file plotmapbase.cpp.

bool PlotMapBase::hasPoint const unsigned int  segment,
const unsigned int  level,
const vector< map< unsigned int, unsigned int > * > &  segmentMaps
[private]
 

Returns true if segment has a Point3D for isoLevel index level.

Definition at line 1010 of file plotmapbase.cpp.

Point3D< double > PlotMapBase::getPoint const unsigned int  segment,
const unsigned int  level,
const vector< map< unsigned int, unsigned int > * > &  segmentMaps,
const vector< vector< Point3D< double > > * > &  segments
[private]
 

Returns the Point3D corresponding to the segment for isoLevel index level.

Definition at line 1019 of file plotmapbase.cpp.

void PlotMapBase::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
[private]
 

Starts a search for an isoline.

Definition at line 1039 of file plotmapbase.cpp.

bool PlotMapBase::getNeighbours const unsigned int  currentSegment,
const unsigned int  previousSegment,
unsigned int &  segment1,
unsigned int &  segment2,
unsigned int &  segment3
[private]
 

Returns the neighbours of currentSegment not from the cell containing previousSegment.

Definition at line 1180 of file plotmapbase.cpp.

bool PlotMapBase::isHorizontal const unsigned int  segment  )  [private]
 

Returns true if a segment is positioned horizontally.

Definition at line 1296 of file plotmapbase.cpp.

void PlotMapBase::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
[private]
 

Recursively adds edge-curves to form a polygon.

Definition at line 1310 of file plotmapbase.cpp.

void PlotMapBase::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
[private]
 

Find the next curve in a counterclockwise direction on the top row.

Definition at line 1398 of file plotmapbase.cpp.

void PlotMapBase::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
[private]
 

Find the next curve in a clockwise direction on the top row.

Definition at line 1481 of file plotmapbase.cpp.

void PlotMapBase::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
[private]
 

Find the next curve in a counterclockwise direction on the rightmost column.

Definition at line 1564 of file plotmapbase.cpp.

void PlotMapBase::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
[private]
 

Find the next curve in a clockwise direction on the rightmost column.

Definition at line 1650 of file plotmapbase.cpp.

void PlotMapBase::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
[private]
 

Find the next curve in a counterclockwise direction on the bottom row.

Definition at line 1733 of file plotmapbase.cpp.

void PlotMapBase::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
[private]
 

Find the next curve in a clockwise direction on the bottom row.

Definition at line 1816 of file plotmapbase.cpp.

void PlotMapBase::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
[private]
 

Find the next curve in a counterclockwise direction on the leftmost column.

Definition at line 1899 of file plotmapbase.cpp.

void PlotMapBase::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
[private]
 

Find the next curve in a clockwise direction on the leftmost column.

Definition at line 1987 of file plotmapbase.cpp.

QRect PlotMapBase::labelRect  )  const [private]
 

Returns the inner geometry of plotLabel with respect to the widget with a provision for the aspect ratio.

THe returned QRect is thus the actual drawing area.

Definition at line 2070 of file plotmapbase.cpp.

template<typename T>
void PlotMapBase::limitRange const T &  min,
T &  value,
const T &  max
[private]
 

Limits the value between min and max.

Definition at line 2090 of file plotmapbase.cpp.


Member Data Documentation

Point3D<unsigned int> PlotMapBase::numPoints [private]
 

The number of grid points in 2 directions.

Definition at line 104 of file plotmapbase.h.

unsigned int PlotMapBase::numAtoms [private]
 

The number of atoms.

Definition at line 105 of file plotmapbase.h.

vector< vector<double> > PlotMapBase::points [private]
 

The values of the grid points: points[numPointsY][NumPointsX].

Definition at line 106 of file plotmapbase.h.

vector< Point3D<double> > PlotMapBase::coords [private]
 

The coordinates of the atoms.

Definition at line 107 of file plotmapbase.h.

PlotMapExtensionWidget* PlotMapBase::options [private]
 

The widget that allows changing the options.

Definition at line 108 of file plotmapbase.h.

QPoint PlotMapBase::mousePosition [private]
 

Holds the start position of a mouse drag.

Definition at line 109 of file plotmapbase.h.

PlotMapLabel* PlotMapBase::plotLabel [private]
 

Shows the resulting map.

Definition at line 110 of file plotmapbase.h.

bool PlotMapBase::loadInProgress [private]
 

Is set to true if the points array is being updated.

Definition at line 111 of file plotmapbase.h.

Point3D<double> PlotMapBase::origin [private]
 

Definition at line 112 of file plotmapbase.h.

Point3D<double> PlotMapBase::delta [private]
 

The origin and cell size for the 3D grid.

Definition at line 112 of file plotmapbase.h.

double PlotMapBase::maxValue [private]
 

Definition at line 113 of file plotmapbase.h.

double PlotMapBase::minValue [private]
 

The maximum and minimum values of the grid.

Definition at line 113 of file plotmapbase.h.

vector< vector<Point3D<double> >* > PlotMapBase::isoCurves [private]
 

A data structure containing all isodensity curves.

Definition at line 114 of file plotmapbase.h.

vector<QColor> PlotMapBase::isoCurveColors [private]
 

A vector containing the color of each curve.

Definition at line 115 of file plotmapbase.h.

const double PlotMapBase::AUTOANG = 1.0/1.889726342 [static, private]
 

Conversion factor atomic units -> angstrom.

Definition at line 118 of file plotmapbase.h.


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