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

#include <CQGLLayoutViewer.h>

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

Public Slots

void slotRevertCurve ()
 
void updateWidget ()
 

Signals

void documentChanged ()
 
void singleCurveSelected (bool selected)
 

Public Member Functions

void change_style (const CLRenderInformationBase *pRenderInfo, bool defaultStyle=false)
 
 CQGLLayoutViewer (QWidget *pParent=0, Qt::WindowFlags f=0)
 
double fitToScreen ()
 
CQGLLayoutPaintergetPainter ()
 
const CQGLLayoutPaintergetPainter () const
 
void restoreDeducedRoles ()
 
void revertDeducedRoles ()
 
void setZoomFactor (double zoom)
 
void update (const CCopasiDataModel *pDataModel, CLayout *pLayout, const CLRenderInformationBase *pRenderInfo, const QString &baseDir)
 
virtual ~CQGLLayoutViewer ()
 

Protected Slots

void slotDocumentChanged ()
 
void slotHValueChanged (int value)
 
void slotSingleCurveSelected (bool selected)
 
void slotVValueChanged (int value)
 

Protected Member Functions

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

Protected Attributes

QScrollBar * mpHorizontalScrollbar
 
CQGLLayoutPaintermpLayoutPainter
 
QScrollBar * mpVerticalScrollbar
 

Detailed Description

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

Definition at line 20 of file CQGLLayoutViewer.h.

Constructor & Destructor Documentation

CQGLLayoutViewer::CQGLLayoutViewer ( QWidget *  pParent = 0,
Qt::WindowFlags  f = 0 
)

Constructor.

Definition at line 18 of file CQGLLayoutViewer.cpp.

References documentChanged(), mpHorizontalScrollbar, mpLayoutPainter, mpVerticalScrollbar, singleCurveSelected(), slotDocumentChanged(), slotHValueChanged(), slotSingleCurveSelected(), slotVValueChanged(), and TRUE.

18  : QFrame(pParent, f)
19 {
20  QVBoxLayout* pVBoxLayout = new QVBoxLayout(this);
21  this->setLayout(pVBoxLayout);
22  pVBoxLayout->setContentsMargins(0, 0, 0, 0);
23  QFrame* pHBox = new QFrame(this);
24  QHBoxLayout* pHBoxLayout = new QHBoxLayout(pHBox);
25  pHBox->setLayout(pHBoxLayout);
26  pHBoxLayout->setContentsMargins(0, 0, 0, 0);
27  // the QGLformat needs to enable sample buffers, otherwise
28  // there is no anti aliasing
29  QGLFormat format(QGL::SampleBuffers);
30  format.setDoubleBuffer(TRUE);
31  this->mpLayoutPainter = new CQGLLayoutPainter(format, pHBox);
32  pHBoxLayout->addWidget(this->mpLayoutPainter);
33  this->mpVerticalScrollbar = new QScrollBar(Qt::Vertical, pHBox);
34  this->mpVerticalScrollbar->setSingleStep(1);
35  pHBoxLayout->addWidget(this->mpVerticalScrollbar);
36  pVBoxLayout->addWidget(pHBox);
37  this->mpHorizontalScrollbar = new QScrollBar(Qt::Horizontal, this);
38  this->mpHorizontalScrollbar->setSingleStep(1);
39  pVBoxLayout->addWidget(this->mpHorizontalScrollbar);
40  connect(this->mpVerticalScrollbar, SIGNAL(valueChanged(int)), this, SLOT(slotVValueChanged(int)));
41  connect(this->mpHorizontalScrollbar, SIGNAL(valueChanged(int)), this, SLOT(slotHValueChanged(int)));
42  connect(this->mpLayoutPainter, SIGNAL(documentChanged()), this, SLOT(slotDocumentChanged()));
43  connect(this->mpLayoutPainter, SIGNAL(singleCurveSelected(bool)), this, SLOT(slotSingleCurveSelected(bool)));
44 }
void singleCurveSelected(bool selected)
#define TRUE
Definition: CGA.h:25
void documentChanged()
void slotSingleCurveSelected(bool selected)
CQGLLayoutPainter * mpLayoutPainter
void slotVValueChanged(int value)
QScrollBar * mpVerticalScrollbar
void slotHValueChanged(int value)
QScrollBar * mpHorizontalScrollbar
CQGLLayoutViewer::~CQGLLayoutViewer ( )
virtual

Destructor.

Definition at line 49 of file CQGLLayoutViewer.cpp.

50 {}

Member Function Documentation

void CQGLLayoutViewer::change_style ( const CLRenderInformationBase pRenderInfo,
bool  defaultStyle = false 
)

The default style indicates that the passed in render information is a default style. The renderer uses this information to determine whether roles for species reference glyphs need to be deduced.

Definition at line 185 of file CQGLLayoutViewer.cpp.

References CQGLLayoutPainter::change_style(), and mpLayoutPainter.

Referenced by CQNewMainWindow::change_style(), and CQNewMainWindow::updateRenderer().

186 {
187  this->mpLayoutPainter->change_style(pRenderInfo, defaultStyle);
188 }
void change_style(const CLRenderInformationBase *pRenderInfo, bool defaultStyle=false)
CQGLLayoutPainter * mpLayoutPainter
void CQGLLayoutViewer::documentChanged ( )
signal
double CQGLLayoutViewer::fitToScreen ( )

Calculates the ratio that is needed to fit the diagram on the current viewport and sets this as the zoom factor. The methods returns the new zoom factor.

Calculates the ratio that is needed to fit the diagram on the current viewport and sets this as the zoom factor. The methods return the newly calculated zoom factor.

Definition at line 163 of file CQGLLayoutViewer.cpp.

References CQGLLayoutPainter::fitToScreen(), mpLayoutPainter, and updateScrollbars().

Referenced by CQNewMainWindow::slotFitToScreen().

164 {
165  double zoom = this->mpLayoutPainter->fitToScreen();
166  this->updateScrollbars();
167  return zoom;
168 }
CQGLLayoutPainter * mpLayoutPainter
CQGLLayoutPainter * CQGLLayoutViewer::getPainter ( )
const CQGLLayoutPainter * CQGLLayoutViewer::getPainter ( ) const

Returns a const pointer to the OpenGL painter.

Definition at line 228 of file CQGLLayoutViewer.cpp.

References mpLayoutPainter.

229 {
230  return this->mpLayoutPainter;
231 }
CQGLLayoutPainter * mpLayoutPainter
void CQGLLayoutViewer::resetView ( )
protected

Definition at line 150 of file CQGLLayoutViewer.cpp.

References mpLayoutPainter, CQGLLayoutPainter::resetView(), and updateScrollbars().

151 {
152  // TODO disconnect the scrollbar listeners
153  // so that the display is only redrawn once
154  this->mpLayoutPainter->resetView();
155  this->updateScrollbars();
156 }
CQGLLayoutPainter * mpLayoutPainter
void CQGLLayoutViewer::resizeEvent ( QResizeEvent *  e)
protectedvirtual

Definition at line 52 of file CQGLLayoutViewer.cpp.

References updateScrollbars().

53 {
54  this->updateScrollbars();
55  QFrame::resizeEvent(e);
56 }
void CQGLLayoutViewer::restoreDeducedRoles ( )

Restores te deduced object roles after they have been temporarily reverted by a call to revertDeducedRoles.

void CQGLLayoutViewer::revertDeducedRoles ( )

This method tells the painter to temporarily revert the deduced object roles. The painter will however remember the rolls and a call to restoreDeducedRoles will restore them.

void CQGLLayoutViewer::setZoomFactor ( double  zoom)

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

Definition at line 58 of file CQGLLayoutViewer.cpp.

References mpLayoutPainter, CQGLLayoutPainter::setZoomFactor(), CQGLLayoutPainter::update(), and updateScrollbars().

Referenced by CQNewMainWindow::slotFitToScreen(), CQNewMainWindow::slotResetView(), CQNewMainWindow::slotZoomChanged(), and CQNewMainWindow::slotZoomMenuItemActivated().

59 {
60  this->mpLayoutPainter->setZoomFactor(zoom);
61  this->updateScrollbars();
62  this->mpLayoutPainter->update();
63 }
void setZoomFactor(double)
CQGLLayoutPainter * mpLayoutPainter
void CQGLLayoutViewer::singleCurveSelected ( bool  selected)
signal
void CQGLLayoutViewer::slotDocumentChanged ( )
protectedslot

This slot is called when the layout painter changes the document (layout).

Definition at line 194 of file CQGLLayoutViewer.cpp.

References documentChanged().

Referenced by CQGLLayoutViewer().

195 {
196  emit documentChanged();
197 }
void documentChanged()
void CQGLLayoutViewer::slotHValueChanged ( int  value)
protectedslot

Definition at line 143 of file CQGLLayoutViewer.cpp.

References CQGLLayoutPainter::getZoomFactor(), CQGLLayoutPainter::minX(), mpLayoutPainter, and CQGLLayoutPainter::setCurrentPositionX().

Referenced by CQGLLayoutViewer(), and updateScrollbars().

144 {
145  double minX = this->mpLayoutPainter->minX();
146  double zoom = this->mpLayoutPainter->getZoomFactor();
147  this->mpLayoutPainter->setCurrentPositionX((double)(minX + value / zoom));
148 }
double minX() const
void setCurrentPositionX(double x)
double getZoomFactor() const
CQGLLayoutPainter * mpLayoutPainter
void CQGLLayoutViewer::slotRevertCurve ( )
slot

This slot is called when the user initiates the action to revert the currently selected curve.

Definition at line 212 of file CQGLLayoutViewer.cpp.

References mpLayoutPainter, and CQGLLayoutPainter::revertCurve().

213 {
214  this->mpLayoutPainter->revertCurve();
215 }
CQGLLayoutPainter * mpLayoutPainter
void CQGLLayoutViewer::slotSingleCurveSelected ( bool  selected)
protectedslot

This slot is called when the selection changes. The value determines whether a single curve is selected or not.

Definition at line 203 of file CQGLLayoutViewer.cpp.

References singleCurveSelected().

Referenced by CQGLLayoutViewer().

204 {
205  emit singleCurveSelected(selected);
206 }
void singleCurveSelected(bool selected)
void CQGLLayoutViewer::slotVValueChanged ( int  value)
protectedslot

Definition at line 136 of file CQGLLayoutViewer.cpp.

References CQGLLayoutPainter::getZoomFactor(), CQGLLayoutPainter::minY(), mpLayoutPainter, and CQGLLayoutPainter::setCurrentPositionY().

Referenced by CQGLLayoutViewer(), and updateScrollbars().

137 {
138  double minY = this->mpLayoutPainter->minY();
139  double zoom = this->mpLayoutPainter->getZoomFactor();
140  this->mpLayoutPainter->setCurrentPositionY((double)(minY + value / zoom));
141 }
void setCurrentPositionY(double y)
double getZoomFactor() const
CQGLLayoutPainter * mpLayoutPainter
double minY() const
void CQGLLayoutViewer::update ( const CCopasiDataModel pDataModel,
CLayout pLayout,
const CLRenderInformationBase pRenderInfo,
const QString &  baseDir 
)

Definition at line 175 of file CQGLLayoutViewer.cpp.

References mpLayoutPainter, CQGLLayoutPainter::update(), and updateScrollbars().

Referenced by CQNewMainWindow::updateRenderer().

176 {
177  // pass the options on to the layout painter
178  if (pRenderInfo)
179  {
180  this->mpLayoutPainter->update(pDatamodel, pLayout, pRenderInfo, baseDir);
181  this->updateScrollbars();
182  }
183 }
CQGLLayoutPainter * mpLayoutPainter
void CQGLLayoutViewer::updateScrollbars ( )
protected

Definition at line 65 of file CQGLLayoutViewer.cpp.

References CQGLLayoutPainter::getZoomFactor(), CQGLLayoutPainter::maxX(), CQGLLayoutPainter::maxY(), CQGLLayoutPainter::minX(), CQGLLayoutPainter::minY(), mpHorizontalScrollbar, mpLayoutPainter, mpVerticalScrollbar, CQGLLayoutPainter::setCurrentPositionX(), CQGLLayoutPainter::setCurrentPositionY(), slotHValueChanged(), and slotVValueChanged().

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

66 {
67  // reset the scollbar range
68  // disconnect the scrollbar listeners and handle the update so that the GL
69  // window is only redrawn once
70  double zoom = this->mpLayoutPainter->getZoomFactor();
71  double maxX = this->mpLayoutPainter->maxX();
72  double maxY = this->mpLayoutPainter->maxY();
73  double minX = this->mpLayoutPainter->minX();
74  double minY = this->mpLayoutPainter->minY();
75  double graphWidth = (maxX - minX) * zoom;
76  double graphHeight = (maxY - minY) * zoom;
77  double rectangleHeight = this->mpLayoutPainter->contentsRect().height();
78  double rectangleWidth = this->mpLayoutPainter->contentsRect().width();
79  disconnect(this->mpVerticalScrollbar, SIGNAL(valueChanged(int)), this, SLOT(slotVValueChanged(int)));
80  disconnect(this->mpHorizontalScrollbar, SIGNAL(valueChanged(int)), this, SLOT(slotHValueChanged(int)));
81 
82  if (graphHeight < rectangleHeight)
83  {
84  this->mpVerticalScrollbar->hide();
85  this->mpVerticalScrollbar->setValue(0);
87  }
88  else
89  {
90  this->mpVerticalScrollbar->setPageStep(rectangleHeight);
91  int oldMaximum = this->mpVerticalScrollbar->maximum();
92  int newMaximum = (int)(graphHeight - rectangleHeight);
93  int oldValue = this->mpVerticalScrollbar->value();
94  int newValue = 0;
95 
96  if (oldValue != 0 && oldMaximum != 0)
97  {
98  newValue = (int)((double) oldValue * (double) newMaximum / (double) oldMaximum);
99  }
100 
101  this->mpVerticalScrollbar->setRange(0, newMaximum);
102  this->mpVerticalScrollbar->setValue(newValue);
103  this->mpLayoutPainter->setCurrentPositionY((double)(minY + newValue / zoom));
104  this->mpVerticalScrollbar->show();
105  }
106 
107  if (graphWidth < rectangleWidth)
108  {
109  this->mpHorizontalScrollbar->hide();
110  this->mpHorizontalScrollbar->setValue(0);
112  }
113  else
114  {
115  this->mpHorizontalScrollbar->setPageStep(rectangleWidth);
116  int oldMaximum = this->mpHorizontalScrollbar->maximum();
117  int newMaximum = (int)(graphWidth - rectangleWidth);
118  int oldValue = this->mpHorizontalScrollbar->value();
119  int newValue = 0;
120 
121  if (oldValue != 0 && oldMaximum != 0)
122  {
123  newValue = (int)((double) oldValue * (double) newMaximum / (double) oldMaximum);
124  }
125 
126  this->mpHorizontalScrollbar->setRange(0, newMaximum);
127  this->mpHorizontalScrollbar->setValue(newValue);
128  this->mpLayoutPainter->setCurrentPositionX((double)(minX + newValue / zoom));
129  this->mpHorizontalScrollbar->show();
130  }
131 
132  connect(this->mpVerticalScrollbar, SIGNAL(valueChanged(int)), this, SLOT(slotVValueChanged(int)));
133  connect(this->mpHorizontalScrollbar, SIGNAL(valueChanged(int)), this, SLOT(slotHValueChanged(int)));
134 }
double minX() const
double maxY() const
void setCurrentPositionX(double x)
void setCurrentPositionY(double y)
double maxX() const
double getZoomFactor() const
CQGLLayoutPainter * mpLayoutPainter
void slotVValueChanged(int value)
QScrollBar * mpVerticalScrollbar
double minY() const
void slotHValueChanged(int value)
if(!yymsg) yymsg
QScrollBar * mpHorizontalScrollbar
void CQGLLayoutViewer::updateWidget ( )
slot

Definition at line 170 of file CQGLLayoutViewer.cpp.

References mpLayoutPainter, and CQGLLayoutPainter::update().

171 {
172  this->mpLayoutPainter->update();
173 }
CQGLLayoutPainter * mpLayoutPainter

Member Data Documentation

QScrollBar* CQGLLayoutViewer::mpHorizontalScrollbar
protected

Definition at line 26 of file CQGLLayoutViewer.h.

Referenced by CQGLLayoutViewer(), and updateScrollbars().

CQGLLayoutPainter* CQGLLayoutViewer::mpLayoutPainter
protected
QScrollBar* CQGLLayoutViewer::mpVerticalScrollbar
protected

Definition at line 25 of file CQGLLayoutViewer.h.

Referenced by CQGLLayoutViewer(), and updateScrollbars().


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