COPASI API  4.16.103
Public Slots | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | List of all members
CQGLViewport Class Reference

#include <CQGLViewport.h>

Inheritance diagram for CQGLViewport:
Inheritance graph
[legend]
Collaboration diagram for CQGLViewport:
Collaboration graph
[legend]

Public Slots

void updateWidget ()
 

Public Member Functions

 CQGLViewport (QWidget *pParent=0, Qt::WFlags f=0)
 
void createGraph (CLayout *lP)
 
double fitToScreen ()
 
const CQGLNetworkPaintergetPainter () const
 
CQGLNetworkPaintergetPainter ()
 
bool isCircleMode () const
 
void resetView ()
 
void setZoomFactor (double zoom)
 
virtual ~CQGLViewport ()
 

Protected Slots

void slotHValueChanged (int value)
 
void slotVValueChanged (int value)
 

Protected Member Functions

virtual void resizeEvent (QResizeEvent *e)
 
void updateScrollbars ()
 

Protected Attributes

QScrollBar * mpHorizontalScrollbar
 
CQGLNetworkPaintermpNetworkPainter
 
QScrollBar * mpVerticalScrollbar
 

Detailed Description

This class is supposed to act as a sort of scrollview for a CQGLNetworkPainter.

Definition at line 22 of file CQGLViewport.h.

Constructor & Destructor Documentation

CQGLViewport::CQGLViewport ( QWidget *  pParent = 0,
Qt::WFlags  f = 0 
)

Constructor.

Definition at line 31 of file CQGLViewport.cpp.

References mpHorizontalScrollbar, mpNetworkPainter, mpVerticalScrollbar, slotHValueChanged(), slotVValueChanged(), and TRUE.

31  :
32  QFrame(pParent, f)
33  , mpVerticalScrollbar(new QScrollBar(Qt::Vertical, NULL))
34  , mpHorizontalScrollbar(new QScrollBar(Qt::Horizontal, NULL))
35  , mpNetworkPainter(NULL)
36 {
37  QVBoxLayout* pVBoxLayout = new QVBoxLayout();
38  this->setLayout(pVBoxLayout);
39  QFrame* pHBox = new QFrame(this);
40  pHBox->setLayout(new QHBoxLayout());
41  pVBoxLayout->addWidget(pHBox);
42  QGLFormat format;
43  format.setDoubleBuffer(TRUE);
44  this->mpNetworkPainter = new CQGLNetworkPainter(format, pHBox);
45  pHBox->layout()->addWidget(this->mpNetworkPainter);
46  pHBox->layout()->addWidget(this->mpVerticalScrollbar);
47  this->mpVerticalScrollbar->setSingleStep(1);
48  pVBoxLayout->addWidget(this->mpHorizontalScrollbar);
49  this->mpHorizontalScrollbar->setSingleStep(1);
50  connect(this->mpVerticalScrollbar, SIGNAL(valueChanged(int)), this, SLOT(slotVValueChanged(int)));
51  connect(this->mpHorizontalScrollbar, SIGNAL(valueChanged(int)), this, SLOT(slotHValueChanged(int)));
52 }
#define TRUE
Definition: CGA.h:25
QScrollBar * mpVerticalScrollbar
Definition: CQGLViewport.h:27
CQGLNetworkPainter * mpNetworkPainter
Definition: CQGLViewport.h:29
void slotVValueChanged(int value)
QScrollBar * mpHorizontalScrollbar
Definition: CQGLViewport.h:28
void slotHValueChanged(int value)
CQGLViewport::~CQGLViewport ( )
virtual

Destructor.

Definition at line 57 of file CQGLViewport.cpp.

58 {}

Member Function Documentation

void CQGLViewport::createGraph ( CLayout lP)

Pass the layout on to the network painters createGraph and set the scrollbar ranges.

Definition at line 76 of file CQGLViewport.cpp.

References CQGLNetworkPainter::createGraph(), mpNetworkPainter, and updateScrollbars().

Referenced by CQLayoutMainWindow::CQLayoutMainWindow(), CQLayoutMainWindow::loadSBMLFile(), and CQLayoutMainWindow::setLayout().

77 {
78  this->mpNetworkPainter->createGraph(IP);
79  this->updateScrollbars();
80 }
void createGraph(CLayout *lP)
void updateScrollbars()
CQGLNetworkPainter * mpNetworkPainter
Definition: CQGLViewport.h:29
double CQGLViewport::fitToScreen ( )

Make the diagram fit the screen. Returns the new zoom factor.

Make the diagram fit the screen. Returns the new zoom value.

Definition at line 158 of file CQGLViewport.cpp.

References CQGLNetworkPainter::fitToScreen(), mpNetworkPainter, and updateScrollbars().

Referenced by CQLayoutMainWindow::slotFitToScreen().

159 {
160  double zoom = this->mpNetworkPainter->fitToScreen();
161  this->updateScrollbars();
162  return zoom;
163 }
void updateScrollbars()
CQGLNetworkPainter * mpNetworkPainter
Definition: CQGLViewport.h:29
const CQGLNetworkPainter * CQGLViewport::getPainter ( ) const
CQGLNetworkPainter * CQGLViewport::getPainter ( )

Definition at line 71 of file CQGLViewport.cpp.

References mpNetworkPainter.

72 {
73  return this->mpNetworkPainter;
74 }
CQGLNetworkPainter * mpNetworkPainter
Definition: CQGLViewport.h:29
bool CQGLViewport::isCircleMode ( ) const

Returns whether the layout window is in circle (animation mode) or not. This method only calls the corresponding method in the contained network painter.

Definition at line 170 of file CQGLViewport.cpp.

References CQGLNetworkPainter::isCircleMode(), and mpNetworkPainter.

Referenced by CQLayoutMainWindow::parameterTableValueChanged().

171 {
172  return this->mpNetworkPainter->isCircleMode();
173 }
CQGLNetworkPainter * mpNetworkPainter
Definition: CQGLViewport.h:29
void CQGLViewport::resetView ( )

Definition at line 146 of file CQGLViewport.cpp.

References mpNetworkPainter, CQGLNetworkPainter::resetView(), and updateScrollbars().

Referenced by CQLayoutMainWindow::slotResetView().

147 {
148  // TODO disconnect the scrollbar listeners
149  // so that the display is only redrawn once
150  this->mpNetworkPainter->resetView();
151  this->updateScrollbars();
152 }
void updateScrollbars()
CQGLNetworkPainter * mpNetworkPainter
Definition: CQGLViewport.h:29
void CQGLViewport::resizeEvent ( QResizeEvent *  e)
protectedvirtual

Definition at line 60 of file CQGLViewport.cpp.

References updateScrollbars().

61 {
62  this->updateScrollbars();
63  QFrame::resizeEvent(e);
64 }
void updateScrollbars()
void CQGLViewport::setZoomFactor ( double  zoom)

Sets the zoom factor on the network painter and updates the scrollbars.

Definition at line 82 of file CQGLViewport.cpp.

References mpNetworkPainter, CQGLNetworkPainter::setZoomFactor(), CQGLNetworkPainter::update(), and updateScrollbars().

Referenced by CQLayoutMainWindow::setZoomFactor().

83 {
84  // TODO make sure the GL window is only redrawn once
85  this->mpNetworkPainter->setZoomFactor(zoom);
86  this->updateScrollbars();
87  this->mpNetworkPainter->update();
88 }
void updateScrollbars()
CQGLNetworkPainter * mpNetworkPainter
Definition: CQGLViewport.h:29
void setZoomFactor(C_FLOAT64)
void CQGLViewport::slotHValueChanged ( int  value)
protectedslot

Definition at line 139 of file CQGLViewport.cpp.

References CQGLNetworkPainter::getGraphMin(), CLPoint::getX(), CQGLNetworkPainter::getZoomFactor(), mpNetworkPainter, and CQGLNetworkPainter::setCurrentPositionX().

Referenced by CQGLViewport().

140 {
141  CLPoint p = this->mpNetworkPainter->getGraphMin();
142  double zoom = this->mpNetworkPainter->getZoomFactor();
143  this->mpNetworkPainter->setCurrentPositionX((double)(p.getX() + value / zoom));
144 }
void setCurrentPositionX(C_FLOAT64 x)
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
Definition: CLBase.h:54
CQGLNetworkPainter * mpNetworkPainter
Definition: CQGLViewport.h:29
C_FLOAT64 getZoomFactor() const
const CLPoint & getGraphMin()
void CQGLViewport::slotVValueChanged ( int  value)
protectedslot

Definition at line 132 of file CQGLViewport.cpp.

References CQGLNetworkPainter::getGraphMin(), CLPoint::getY(), CQGLNetworkPainter::getZoomFactor(), mpNetworkPainter, and CQGLNetworkPainter::setCurrentPositionY().

Referenced by CQGLViewport().

133 {
134  CLPoint p = this->mpNetworkPainter->getGraphMin();
135  double zoom = this->mpNetworkPainter->getZoomFactor();
136  this->mpNetworkPainter->setCurrentPositionY((double)(p.getY() + value / zoom));
137 }
void setCurrentPositionY(C_FLOAT64 y)
Definition: CLBase.h:54
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
CQGLNetworkPainter * mpNetworkPainter
Definition: CQGLViewport.h:29
C_FLOAT64 getZoomFactor() const
const CLPoint & getGraphMin()
void CQGLViewport::updateScrollbars ( )
protected

Definition at line 90 of file CQGLViewport.cpp.

References CQGLNetworkPainter::getGraphMax(), CQGLNetworkPainter::getGraphMin(), CLPoint::getX(), CLPoint::getY(), CQGLNetworkPainter::getZoomFactor(), max, min, mpHorizontalScrollbar, mpNetworkPainter, mpVerticalScrollbar, and CQGLNetworkPainter::update().

Referenced by createGraph(), fitToScreen(), resetView(), resizeEvent(), and setZoomFactor().

91 {
92  // reset the scollbar range
93  // TODO check te setting for the scroll range since there seem to be some
94  // error messages
95  // disconnect the scrollbar listeners and handle the update so that the GL
96  // window is only redrawn once
97  double zoom = this->mpNetworkPainter->getZoomFactor();
100  double graphWidth = (max.getX() - min.getX()) * zoom;
101  double graphHeight = (max.getY() - min.getY()) * zoom;
102  double rectangleHeight = this->contentsRect().height();
103  double rectangleWidth = this->contentsRect().width();
104 
105  if (graphHeight < rectangleHeight)
106  {
107  this->mpVerticalScrollbar->hide();
108  this->mpVerticalScrollbar->setValue(0);
109  }
110  else
111  {
112  this->mpVerticalScrollbar->setPageStep(rectangleHeight);
113  this->mpVerticalScrollbar->setRange(0, (unsigned int)(graphHeight - rectangleHeight));
114  this->mpVerticalScrollbar->show();
115  this->mpNetworkPainter->update();
116  }
117 
118  if (graphWidth < rectangleWidth)
119  {
120  this->mpHorizontalScrollbar->hide();
121  this->mpHorizontalScrollbar->setValue(0);
122  }
123  else
124  {
125  this->mpHorizontalScrollbar->setPageStep(rectangleWidth);
126  this->mpHorizontalScrollbar->setRange(0, (unsigned int)(graphWidth - rectangleWidth));
127  this->mpHorizontalScrollbar->show();
128  this->mpNetworkPainter->update();
129  }
130 }
QScrollBar * mpVerticalScrollbar
Definition: CQGLViewport.h:27
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
Definition: CLBase.h:54
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
CQGLNetworkPainter * mpNetworkPainter
Definition: CQGLViewport.h:29
const CLPoint & getGraphMax()
C_FLOAT64 getZoomFactor() const
QScrollBar * mpHorizontalScrollbar
Definition: CQGLViewport.h:28
#define min(a, b)
Definition: f2c.h:175
const CLPoint & getGraphMin()
#define max(a, b)
Definition: f2c.h:176
void CQGLViewport::updateWidget ( )
slot

Definition at line 165 of file CQGLViewport.cpp.

References mpNetworkPainter, and CQGLNetworkPainter::update().

Referenced by CQLayoutMainWindow::parameterTableValueChanged().

166 {
167  this->mpNetworkPainter->update();
168 }
CQGLNetworkPainter * mpNetworkPainter
Definition: CQGLViewport.h:29

Member Data Documentation

QScrollBar* CQGLViewport::mpHorizontalScrollbar
protected

Definition at line 28 of file CQGLViewport.h.

Referenced by CQGLViewport(), and updateScrollbars().

CQGLNetworkPainter* CQGLViewport::mpNetworkPainter
protected
QScrollBar* CQGLViewport::mpVerticalScrollbar
protected

Definition at line 27 of file CQGLViewport.h.

Referenced by CQGLViewport(), and updateScrollbars().


The documentation for this class was generated from the following files: