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

#include <CQLayoutView.h>

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

Public Slots

void slotFitOnScreen ()
 
void slotLayoutChanged (int)
 
void slotRenderInformationChanged (int)
 
void slotResetZoom ()
 
void slotSaveToFile (const QString &fileName)
 
void slotZoomIn ()
 
void slotZoomOut ()
 

Public Member Functions

 CQLayoutView (QWidget *parent=NULL)
 
 CQLayoutView (CQLayoutScene *scene)
 
void fillSelectionToolBar (QToolBar *toolBar)
 
void fillZoomMenu (QMenu *menu)
 
void fillZoomTooBar (QToolBar *toolBar)
 
CCopasiDataModelgetDataModel ()
 
void setDataModel (CCopasiDataModel *dataModel, CLayout *layout=NULL)
 
virtual ~CQLayoutView ()
 

Protected Member Functions

void wheelEvent (QWheelEvent *event)
 

Protected Attributes

bool mIgnoreEvents
 
QAction * mpActFitOnScreen
 
QAction * mpActResetZoom
 
QAction * mpActZoomIn
 
QAction * mpActZoomOut
 
CCopasiDataModelmpDataModel
 
QComboBox * mpLayoutDropdown
 
QComboBox * mpRenderDropdown
 
double mScaleFactor
 

Private Member Functions

void createActions ()
 

Detailed Description

Definition at line 19 of file CQLayoutView.h.

Constructor & Destructor Documentation

CQLayoutView::CQLayoutView ( QWidget *  parent = NULL)

Definition at line 219 of file CQLayoutView.cpp.

References createActions().

220  : QGraphicsView(parent)
221  , mScaleFactor(1.15)
222  , mIgnoreEvents(false)
223 {
224  setDragMode(QGraphicsView::ScrollHandDrag);
225  createActions();
226 }
bool mIgnoreEvents
Definition: CQLayoutView.h:51
double mScaleFactor
Definition: CQLayoutView.h:48
void createActions()
CQLayoutView::CQLayoutView ( CQLayoutScene scene)

Definition at line 240 of file CQLayoutView.cpp.

References createActions().

241  : QGraphicsView(scene)
242  , mScaleFactor(1.15)
243  , mIgnoreEvents(false)
244 
245 {
246  setDragMode(QGraphicsView::ScrollHandDrag);
247  createActions();
248 }
bool mIgnoreEvents
Definition: CQLayoutView.h:51
double mScaleFactor
Definition: CQLayoutView.h:48
void createActions()
CQLayoutView::~CQLayoutView ( )
virtual

Definition at line 26 of file CQLayoutView.cpp.

27 {
28 }

Member Function Documentation

void CQLayoutView::createActions ( )
private

Definition at line 270 of file CQLayoutView.cpp.

References CQIconResource::icon(), mpActFitOnScreen, mpActResetZoom, mpActZoomIn, mpActZoomOut, mpLayoutDropdown, mpRenderDropdown, slotFitOnScreen(), slotLayoutChanged(), slotRenderInformationChanged(), slotResetZoom(), slotZoomIn(), slotZoomOut(), CQIconResource::viewmag1, CQIconResource::viewmagfit, CQIconResource::viewmagMinus, and CQIconResource::viewmagPlus.

Referenced by CQLayoutView().

271 {
272  mpActFitOnScreen = new QAction(tr("Fit On Screen"), this);
273  mpActFitOnScreen->setShortcut(QKeySequence::fromString("F5"));
275  connect(mpActFitOnScreen, SIGNAL(triggered()), this, SLOT(slotFitOnScreen()));
276  addAction(mpActFitOnScreen);
277 
278  mpActResetZoom = new QAction(tr("Reset Zoom"), this);
280  connect(mpActResetZoom, SIGNAL(triggered()), this, SLOT(slotResetZoom()));
281  addAction(mpActResetZoom);
282 
283  mpActZoomIn = new QAction(tr("Zoom In"), this);
285  mpActZoomIn->setShortcut(QKeySequence::ZoomIn);
286  connect(mpActZoomIn, SIGNAL(triggered()), this, SLOT(slotZoomIn()));
287  addAction(mpActZoomIn);
288 
289  mpActZoomOut = new QAction(tr("Zoom Out"), this);
291  mpActZoomOut->setShortcut(QKeySequence::ZoomOut);
292  connect(mpActZoomOut, SIGNAL(triggered()), this, SLOT(slotZoomOut()));
293  addAction(mpActZoomOut);
294 
295  mpLayoutDropdown = new QComboBox;
296  mpLayoutDropdown->setSizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow);
297 
298  mpRenderDropdown = new QComboBox;
299  mpRenderDropdown->setSizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow);
300 
301  connect(mpLayoutDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotLayoutChanged(int)));
302  connect(mpRenderDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotRenderInformationChanged(int)));
303 
304  setInteractive(true);
305  setRenderHints(QPainter::Antialiasing);
306 }
QComboBox * mpLayoutDropdown
Definition: CQLayoutView.h:49
QAction * mpActZoomOut
Definition: CQLayoutView.h:45
QAction * mpActFitOnScreen
Definition: CQLayoutView.h:46
void slotResetZoom()
QAction * mpActZoomIn
Definition: CQLayoutView.h:44
void slotFitOnScreen()
static const QIcon & icon(const IconID &id)
QAction * mpActResetZoom
Definition: CQLayoutView.h:47
void slotZoomOut()
void slotLayoutChanged(int)
QComboBox * mpRenderDropdown
Definition: CQLayoutView.h:50
void slotRenderInformationChanged(int)
void CQLayoutView::fillSelectionToolBar ( QToolBar *  toolBar)

Definition at line 308 of file CQLayoutView.cpp.

References mpLayoutDropdown, and mpRenderDropdown.

309 {
310  QFrame* pFrame1 = new QFrame;
311  QHBoxLayout* pLayout = new QHBoxLayout;
312  pLayout->setSpacing(3);
313  pFrame1->setLayout(pLayout);
314  QLabel* pLabel = new QLabel(tr("Layout:"));
315  pLayout->addWidget(pLabel);
316  pLayout->addWidget(mpLayoutDropdown);
317 
318  QFrame* pFrame2 = new QFrame;
319  pLayout = new QHBoxLayout;
320  pLayout->setSpacing(3);
321  pFrame2->setLayout(pLayout);
322  QLabel* mpRenderLabel = new QLabel(tr("Render Information:"));
323  pLayout->addWidget(mpRenderLabel);
324  pLayout->addWidget(mpRenderDropdown);
325 
326  toolBar->addWidget(pFrame1);
327  toolBar->addWidget(pFrame2);
328 }
QComboBox * mpLayoutDropdown
Definition: CQLayoutView.h:49
QComboBox * mpRenderDropdown
Definition: CQLayoutView.h:50
void CQLayoutView::fillZoomMenu ( QMenu *  menu)

Definition at line 250 of file CQLayoutView.cpp.

References mpActFitOnScreen, mpActResetZoom, mpActZoomIn, and mpActZoomOut.

251 {
252  if (menu == NULL) return;
253 
254  menu->addAction(mpActFitOnScreen);
255  menu->addAction(mpActZoomIn);
256  menu->addAction(mpActZoomOut);
257  menu->addAction(mpActResetZoom);
258 }
QAction * mpActZoomOut
Definition: CQLayoutView.h:45
QAction * mpActFitOnScreen
Definition: CQLayoutView.h:46
QAction * mpActZoomIn
Definition: CQLayoutView.h:44
QAction * mpActResetZoom
Definition: CQLayoutView.h:47
void CQLayoutView::fillZoomTooBar ( QToolBar *  toolBar)

Definition at line 260 of file CQLayoutView.cpp.

References mpActFitOnScreen, mpActResetZoom, mpActZoomIn, and mpActZoomOut.

261 {
262  if (toolBar == NULL) return;
263 
264  toolBar->addAction(mpActFitOnScreen);
265  toolBar->addAction(mpActZoomIn);
266  toolBar->addAction(mpActZoomOut);
267  toolBar->addAction(mpActResetZoom);
268 }
QAction * mpActZoomOut
Definition: CQLayoutView.h:45
QAction * mpActFitOnScreen
Definition: CQLayoutView.h:46
QAction * mpActZoomIn
Definition: CQLayoutView.h:44
QAction * mpActResetZoom
Definition: CQLayoutView.h:47
CCopasiDataModel * CQLayoutView::getDataModel ( )

Definition at line 354 of file CQLayoutView.cpp.

References mpDataModel.

355 {
356  return mpDataModel;
357 }
CCopasiDataModel * mpDataModel
Definition: CQLayoutView.h:52
void CQLayoutView::setDataModel ( CCopasiDataModel dataModel,
CLayout layout = NULL 
)

Definition at line 359 of file CQLayoutView.cpp.

References CCopasiObject::getObjectName(), mpDataModel, mpLayoutDropdown, mpRenderDropdown, updateLayoutList(), and updateRenderInformationList().

360 {
361  mpDataModel = dataModel;
362 
364 
365  if (layout != NULL)
366  mpLayoutDropdown->setCurrentIndex(mpLayoutDropdown->findText(layout->getObjectName().c_str()));
367 
368  updateRenderInformationList(mpRenderDropdown, dataModel, layout);
369 }
CLRenderInformationBase * updateRenderInformationList(QComboBox *list, CCopasiDataModel *dataModel, CLayout *layout)
QComboBox * mpLayoutDropdown
Definition: CQLayoutView.h:49
const std::string & getObjectName() const
CCopasiDataModel * mpDataModel
Definition: CQLayoutView.h:52
QComboBox * mpRenderDropdown
Definition: CQLayoutView.h:50
void updateLayoutList(QComboBox *list, CCopasiDataModel *dataModel)
void CQLayoutView::slotFitOnScreen ( )
slot

Definition at line 330 of file CQLayoutView.cpp.

Referenced by createActions().

331 {
332  setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
333  fitInView(scene()->itemsBoundingRect(), Qt::KeepAspectRatio);
334  update();
335 }
void CQLayoutView::slotLayoutChanged ( int  index)
slot

Definition at line 188 of file CQLayoutView.cpp.

References CQLayoutScene::getCurrentLayout(), CLRenderInformationBase::getKey(), CCopasiDataModel::getListOfLayouts(), CLRenderInformationBase::getName(), mIgnoreEvents, mpDataModel, mpRenderDropdown, CQLayoutScene::recreate(), CQLayoutScene::setLayout(), and updateRenderInformationList().

Referenced by createActions().

189 {
190  if (mIgnoreEvents || index < 0) return;
191 
192  if (mpDataModel == NULL) return;
193 
194  CQLayoutScene* current = dynamic_cast<CQLayoutScene*>(scene());
195 
196  if (current == NULL) return;
197 
198  CLayout* layout = (*mpDataModel->getListOfLayouts())[index];
199 
200  if (layout == NULL || layout == current->getCurrentLayout()) return;
201 
202  mIgnoreEvents = true;
203  // update the corresponding render information list
205 
206  if (render != NULL)
207  {
208  if (render->getName().empty())
209  mpRenderDropdown->setCurrentIndex(mpRenderDropdown->findText(render->getKey().c_str()));
210  else
211  mpRenderDropdown->setCurrentIndex(mpRenderDropdown->findText(render->getName().c_str()));
212  }
213 
214  mIgnoreEvents = false;
215  current->setLayout(layout, mpDataModel, render);
216  current->recreate();
217 }
const CLayout * getCurrentLayout() const
bool mIgnoreEvents
Definition: CQLayoutView.h:51
CLRenderInformationBase * updateRenderInformationList(QComboBox *list, CCopasiDataModel *dataModel, CLayout *layout)
void setLayout(CLayout *layout, CCopasiDataModel *model=NULL, CLRenderInformationBase *renderInformation=NULL)
CCopasiDataModel * mpDataModel
Definition: CQLayoutView.h:52
QComboBox * mpRenderDropdown
Definition: CQLayoutView.h:50
CListOfLayouts * getListOfLayouts()
const std::string & getKey() const
const std::string & getName() const
void CQLayoutView::slotRenderInformationChanged ( int  index)
slot

Definition at line 149 of file CQLayoutView.cpp.

References CQLayoutScene::getCurrentLayout(), getDefaultStyle(), CListOfLayouts::getListOfGlobalRenderInformationObjects(), CCopasiDataModel::getListOfLayouts(), CLayout::getListOfLocalRenderInformationObjects(), getNumDefaultStyles(), mIgnoreEvents, mpDataModel, CQLayoutScene::recreate(), CQLayoutScene::setRenderInformation(), and CCopasiVector< T >::size().

Referenced by createActions().

150 {
151  if (mIgnoreEvents || index < 0) return;
152 
153  if (mpDataModel == NULL) return;
154 
155  CQLayoutScene* current = dynamic_cast<CQLayoutScene*>(scene());
156 
157  if (current == NULL || current->getCurrentLayout() == NULL) return;
158 
159  CLRenderInformationBase* render = NULL;
160  int numLocal = current->getCurrentLayout()->getListOfLocalRenderInformationObjects().size();
161 
162  if (numLocal > index)
163  {
164  render = current->getCurrentLayout()->getListOfLocalRenderInformationObjects()[index];
165  }
166 
168 
169  if (render == NULL && numLocal + numGlobal > index)
170  {
172  }
173 
174  size_t numDefault = getNumDefaultStyles();
175 
176  if (render == NULL && numLocal + numGlobal + numDefault > (size_t)index)
177  {
178  render = getDefaultStyle(index - numGlobal - numLocal);
179  }
180 
181  if (render == NULL)
182  return;
183 
184  current->setRenderInformation(mpDataModel, render);
185  current->recreate();
186 }
const CLayout * getCurrentLayout() const
bool mIgnoreEvents
Definition: CQLayoutView.h:51
const CCopasiVector< CLLocalRenderInformation > & getListOfLocalRenderInformationObjects() const
Definition: CLayout.h:149
virtual size_t size() const
CLGlobalRenderInformation * getDefaultStyle(size_t index)
void setRenderInformation(CCopasiDataModel *model, CLRenderInformationBase *renderInformation)
CCopasiDataModel * mpDataModel
Definition: CQLayoutView.h:52
size_t getNumDefaultStyles()
CListOfLayouts * getListOfLayouts()
const CCopasiVector< CLGlobalRenderInformation > & getListOfGlobalRenderInformationObjects() const
void CQLayoutView::slotResetZoom ( )
slot

Definition at line 336 of file CQLayoutView.cpp.

Referenced by createActions().

337 {
338  setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
339  resetMatrix();
340  ensureVisible(scene()->itemsBoundingRect());
341  update();
342 }
void CQLayoutView::slotSaveToFile ( const QString &  fileName)
slot

Definition at line 228 of file CQLayoutView.cpp.

References CQLayoutScene::saveToFile().

229 {
230  CQLayoutScene* layoutScene = dynamic_cast<CQLayoutScene*>(scene());
231 
232  if (layoutScene == NULL) return;
233 
234  layoutScene->saveToFile(
235  fileName.toStdString(),
236  QFileInfo(fileName).suffix().toStdString()
237  );
238 }
void saveToFile(const std::string &fileName, const std::string &fileType="pdf")
void CQLayoutView::slotZoomIn ( )
slot

Definition at line 343 of file CQLayoutView.cpp.

References mScaleFactor.

Referenced by createActions(), and wheelEvent().

344 {
345  setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
346  scale(mScaleFactor, mScaleFactor);
347 }
double mScaleFactor
Definition: CQLayoutView.h:48
void CQLayoutView::slotZoomOut ( )
slot

Definition at line 348 of file CQLayoutView.cpp.

References mScaleFactor.

Referenced by createActions(), and wheelEvent().

349 {
350  setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
351  scale(1.0 / mScaleFactor, 1.0 / mScaleFactor);
352 }
double mScaleFactor
Definition: CQLayoutView.h:48
void CQLayoutView::wheelEvent ( QWheelEvent *  event)
protected

Definition at line 371 of file CQLayoutView.cpp.

References slotZoomIn(), and slotZoomOut().

372 {
373  if (QApplication::keyboardModifiers() == Qt::ControlModifier ||
374  QApplication::keyboardModifiers() == Qt::MetaModifier ||
375  QApplication::keyboardModifiers() == Qt::ShiftModifier)
376  {
377  if (event->delta() > 0)
378  {
379  // Zoom in
380  slotZoomIn();
381  }
382  else
383  {
384  // Zooming out
385  slotZoomOut();
386  }
387  }
388  else
389  {
390  QGraphicsView::wheelEvent(event);
391  }
392 }
void slotZoomOut()

Member Data Documentation

bool CQLayoutView::mIgnoreEvents
protected

Definition at line 51 of file CQLayoutView.h.

Referenced by slotLayoutChanged(), and slotRenderInformationChanged().

QAction* CQLayoutView::mpActFitOnScreen
protected

Definition at line 46 of file CQLayoutView.h.

Referenced by createActions(), fillZoomMenu(), and fillZoomTooBar().

QAction* CQLayoutView::mpActResetZoom
protected

Definition at line 47 of file CQLayoutView.h.

Referenced by createActions(), fillZoomMenu(), and fillZoomTooBar().

QAction* CQLayoutView::mpActZoomIn
protected

Definition at line 44 of file CQLayoutView.h.

Referenced by createActions(), fillZoomMenu(), and fillZoomTooBar().

QAction* CQLayoutView::mpActZoomOut
protected

Definition at line 45 of file CQLayoutView.h.

Referenced by createActions(), fillZoomMenu(), and fillZoomTooBar().

CCopasiDataModel* CQLayoutView::mpDataModel
protected
QComboBox* CQLayoutView::mpLayoutDropdown
protected

Definition at line 49 of file CQLayoutView.h.

Referenced by createActions(), fillSelectionToolBar(), and setDataModel().

QComboBox* CQLayoutView::mpRenderDropdown
protected
double CQLayoutView::mScaleFactor
protected

Definition at line 48 of file CQLayoutView.h.

Referenced by slotZoomIn(), and slotZoomOut().


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