Source: k2dgrflow/plotfield.h


Annotated List
Files
Globals
Hierarchy
Index
/***************************************************************************
                          plotfield.h  -  description
                             -------------------
    begin                : Thu May 3 2001
    copyright            : (C) 2001 by benny
    email                : bm@cage.rug.ac.be
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef PLOTFIELD_H
#define PLOTFIELD_H

#include <qscrollview.h>
#include <qpainter.h>

#include <vector>

class K2dGrFlowView;
/**This file contains the drawing area of our k2dgrflow  application.
  * We have a scrollview, wich shows the user a widget with the drawing.
  *@author benny
  *First the class that contains the drawing. It knows how to draw a mesh, a domain, ...
  * It retrieves the data from a K2dGrFlowView, so a pointer to this has to be given to the class to be able to
  * to access the data it has to draw
  */
class PlotFieldView : public QWidget
{
    Q_OBJECT
public:
    /**enumeratior with the possible contents of a drawview
      */
    enum DrawContents{Blank, Domain , DomainMesh, Mesh, Result };

    PlotFieldView(K2dGrFlowView* owner, QWidget *parent=0, const char *name=0);
    ~PlotFieldView();
    const K2dGrFlowView* getOwner() const {return drawViewOwner ;} ;
    static const int fieldWidth = 1500 ;
    static const int fieldHeight = 2000;

public slots:
    /** updateDomain will repaint the widget so that a contents is drawn on it.
      */
    void   updateIt(DrawContents );
    /** functions to paint the drawing on a printer
      */
    void   print();
    void   printIt(DrawContents );
    void   zoomOut();
    void   zoomIn();

protected:
    /** draw whatever was asked to be drawn
      */
    void   drawIt( QPainter * );
    void   paintEvent( QPaintEvent * );
    //void   resizeEvent( QResizeEvent * );
private:
    /**private function that sets optimal drawing values
      */
    void setPlotValues();

    QPrinter     *printer;
    DrawContents  drawindex;
    const K2dGrFlowView* drawViewOwner;

    /**values for nice plotting of present figure
      */
    double scaleHor, scaleVer, transHor, transVer ;
    double zoomFactor;
    /**the number of contours that is plotted in a contourdiagramm
      */
    static const int nrCont=40;
    //two structures to quickly read input data of files wish must be displayed
    struct sid
      {
       int node1;
       int node2;
      };
    struct nod
      {
       double coord1;
       double coord2;
      };
    /**internally used function to see if there is a contour between two values
      */
    void contoursBetween(const double &value1, const double &value2, double *contValues, vector<int> &ContNrVect);
    /**internally used function to calculate the position of a contour on a line between two points of which the value is given
      */
    bool posCont(const double &contValue, const double &x1, const double &y1 , const double &value1,
                                         const double &x2,  const double &y2,  const double &value2, double &returnx , double &returny);
};

/**This class encapsulates the drawing area in a scrollview. That is, if necessary it makes vertical and horizontal
     scrollbars so that the user has access to the entire drawing.
    This is achieved by making a DrawView inside the viewport of the scrollview
  *@author benny
  */
class PlotField : public QScrollView  {
   Q_OBJECT
public:

    /**a constructor. A certain view must be specified. The PlotField has to pass this to the drawview contained by it
      */
	PlotField(K2dGrFlowView* owner, QWidget *parent=0, const char *name=0);
	~PlotField();

public slots:
     /**a slot that can be called to make the inside of the plotfield blank, connect it to actions that open new files !
       */
     void blank();
     /**a slot to connect to drawing a domain inside the plotfield
       */
     void plotDomain();
     /**a slot to connect to drawing a domain, meshed inside the plotfield
       */
     void plotDomainMesh();
     /**a slot to connect to drawing the Mesh of the domain inside the plotfield
       */
     void plotMesh();
     /**a slot to connect to drawing the result of FEM simulation inside the plotfield
       */
     void plotResult();
     /**a slot to print the contents of the view
       */
     void printDomain();
     /** slot to connect to if contents of the view must be printed
       */
     void print();
     /** slot to connect to zoom out
        */
     void zoomOut();
     /** slot to connect to zoom in
       */
     void zoomIn();

private:
     /** where it's all about. The widget the PlotField holds and that contains the actual drawing
        */
     PlotFieldView *plotWidget;
};

#endif

Generated by: benny@okidoki on Thu Jun 21 10:41:51 2001, using kdoc 2.0a53.