COPASI API  4.16.103
Functions
CQRenderConverter.cpp File Reference
#include <QtGui/QGraphicsItem>
#include <QtCore/QSharedPointer>
#include <QtGui/QPen>
#include <QtGui/QFont>
#include <QtGui/QFontMetrics>
#include <QtGui/QPixmap>
#include <QtCore/QFile>
#include <QtGui/QGraphicsScene>
#include <qlayout/CQRenderConverter.h>
#include <qlayout/CQRoundedRect.h>
#include <layout/CLStyle.h>
#include <layout/CLEllipse.h>
#include <layout/CLRectangle.h>
#include <layout/CLImage.h>
#include <layout/CLPolygon.h>
#include <layout/CLText.h>
#include <layout/CLCurve.h>
#include <layout/CLRenderCurve.h>
#include <layout/CLRenderCubicBezier.h>
#include <layout/CLRenderPoint.h>
#include <layout/CLLinearGradient.h>
#include <layout/CLRadialGradient.h>
#include <layout/CLRenderResolver.h>
#include <layout/CLGraphicalPrimitive1D.h>
#include <report/CCopasiRootContainer.h>
#include <CopasiDataModel/CCopasiDataModel.h>
#include <math.h>
Include dependency graph for CQRenderConverter.cpp:

Go to the source code of this file.

Functions

void addLineEndingToItem (QGraphicsPathItem *item, const CLLineEnding *ending, const CLGroup *group, const CLRenderResolver *resolver, QPointF point, QPointF second, QGraphicsItemGroup *itemGroup)
 
void addToPath (QPainterPath &path, const CLRenderCubicBezier *cubic, const CLBoundingBox *pBB)
 
void addToPath (QPainterPath &path, const CLRenderPoint *current, const CLBoundingBox *pBB)
 
void adjustPosition (QGraphicsTextItem *item, const CLBoundingBox *pBB, const CLText *pText, const CLGroup *group)
 
void applyRotationalMapping (QPainterPath &linePath, const CLLineEnding *ending, QPointF point, QPointF second)
 
void fillItemFromCurve (QGraphicsItemGroup *item, const CLBoundingBox *pBB, const CLCurve *pCurve, const CLGroup *group, const CLRenderResolver *resolver)
 
void fillItemFromEllipse (QGraphicsItemGroup *item, const CLBoundingBox *pBB, const CLEllipse *pEllipse, const CLGroup *group, const CLRenderResolver *resolver)
 
void fillItemFromGroup (QGraphicsItemGroup *item, const CLBoundingBox *bounds, const CLGroup *group, const CLRenderResolver *resolver)
 
void fillItemFromImage (QGraphicsItemGroup *item, const CLBoundingBox *pBB, const CLImage *pImage, const CLGroup *group, const CLRenderResolver *)
 
void fillItemFromPolygon (QGraphicsItemGroup *item, const CLBoundingBox *pBB, const CLPolygon *pPoly, const CLGroup *group, const CLRenderResolver *resolver)
 
void fillItemFromRectangle (QGraphicsItemGroup *item, const CLBoundingBox *pBB, const CLRectangle *pRect, const CLGroup *group, const CLRenderResolver *resolver)
 
void fillItemFromRenderCurve (QGraphicsItemGroup *item, const CLBoundingBox *pBB, const CLRenderCurve *pCurve, const CLGroup *group, const CLRenderResolver *resolver)
 
void fillItemFromText (QGraphicsItemGroup *item, const CLBoundingBox *pBB, const CLText *pText, const CLGroup *group, const CLRenderResolver *resolver)
 
QSharedPointer< QBrush > getBrush (const CLGraphicalPrimitive2D *item, const CLGroup *group, const CLRenderResolver *resolver, const CLBoundingBox *pBB)
 
QColor getColor (const CLColorDefinition *cd)
 
QColor getColor (const std::string &color, const CLRenderResolver *resolver)
 
QSharedPointer< QFont > getFont (const CLText *item, const CLGroup *group, const CLRenderResolver *, const CLBoundingBox *pBB)
 
QSharedPointer< QGradient > getGradient (const CLGradientBase *base, const CLBoundingBox *bounds, const CLRenderResolver *resolver)
 
QSharedPointer< QLinearGradient > getLinearGradient (const CLLinearGradient *linear, const CLBoundingBox *bounds, const CLRenderResolver *resolver)
 
QSharedPointer< QPainterPath > getPath (const CLPolygon *pCurve, const CLBoundingBox *pBB)
 
QSharedPointer< QPainterPath > getPath (const CLRectangle *pRect, const CLBoundingBox *pBB)
 
QSharedPointer< QPainterPath > getPath (const CLEllipse *pEllipse, const CLBoundingBox *pBB)
 
QSharedPointer< QPainterPath > getPath (const CLRenderCurve *pCurve, const CLBoundingBox *pBB)
 
QSharedPointer< QPen > getPen (const CLGraphicalPrimitive1D *item, const CLGroup *group, const CLRenderResolver *resolver, const CLBoundingBox *)
 
QSharedPointer< QRadialGradient > getRadialGradient (const CLRadialGradient *radial, const CLBoundingBox *bounds, const CLRenderResolver *resolver)
 
void moveToPoint (QPainterPath &path, const CLRenderPoint *current, const CLBoundingBox *pBB)
 
QPointF normalizePoint (const QPointF &vector)
 
void transform (QGraphicsItem *item, const CLTransformation2D *trans, const CLGroup *group)
 

Function Documentation

void addLineEndingToItem ( QGraphicsPathItem *  item,
const CLLineEnding ending,
const CLGroup group,
const CLRenderResolver resolver,
QPointF  point,
QPointF  second,
QGraphicsItemGroup *  itemGroup 
)

Definition at line 604 of file CQRenderConverter.cpp.

References applyRotationalMapping(), CLGraphicalPrimitive2D::EVENODD, CLLineEnding::getBoundingBox(), getBrush(), CLGroup::getElement(), CLGraphicalPrimitive2D::getFillRule(), CLLineEnding::getGroup(), CLGroup::getNumElements(), getPath(), getPen(), CLGraphicalPrimitive2D::isSetFill(), CLGraphicalPrimitive2D::isSetFillRule(), and CLGraphicalPrimitive2D::NONZERO.

Referenced by CQRenderConverter::applyStyle(), and fillItemFromRenderCurve().

605 {
606  const CLGroup* lineGroup = ending->getGroup();
607 
608  for (size_t i = 0; i < lineGroup->getNumElements(); ++i)
609  {
610  const CLPolygon* poly = dynamic_cast<const CLPolygon*>(lineGroup->getElement(i));
611  const CLRenderCurve* rcurve = dynamic_cast<const CLRenderCurve*>(lineGroup->getElement(i));
612  const CLEllipse* ellipse = dynamic_cast<const CLEllipse*>(lineGroup->getElement(i));
613  const CLRectangle* rect = dynamic_cast<const CLRectangle*>(lineGroup->getElement(i));
614 
615  if (rcurve != NULL)
616  {
617  QPainterPath path = item->path();
618  QSharedPointer<QPainterPath> linePath = getPath(rcurve, ending->getBoundingBox());
619  applyRotationalMapping(*linePath, ending, point, second);
620  linePath->translate(point);
621  path.addPath(*linePath.data());
622  item->setPath(path);
623  }
624  else if (poly != NULL)
625  {
626  QPainterPath path = item->path();
627  QSharedPointer<QPainterPath> linePath = getPath(poly, ending->getBoundingBox());
628  applyRotationalMapping(*linePath, ending, point, second);
629  linePath->translate(point);
630  path.addPath(*linePath);
631  item->setPath(path);
632 
633  if (poly->isSetFill() || group->isSetFill())
634  {
635  QSharedPointer<QBrush> brush = getBrush(poly, ending->getGroup(), resolver, ending->getBoundingBox());
636  QSharedPointer<QPen> pen = getPen(poly, ending->getGroup(), resolver, ending->getBoundingBox());
637 
638  linePath->setFillRule(Qt::WindingFill);
639 
640  if (poly->isSetFillRule())
641  {
642  switch (poly->getFillRule())
643  {
645  linePath->setFillRule(Qt::OddEvenFill);
646  break;
647 
649  default:
650  linePath->setFillRule(Qt::WindingFill);
651  break;
652  }
653  }
654 
655  if (group->isSetFillRule())
656  {
657  switch (group->getFillRule())
658  {
660  linePath->setFillRule(Qt::OddEvenFill);
661  break;
662 
664  default:
665  linePath->setFillRule(Qt::WindingFill);
666  break;
667  }
668  }
669 
670  QGraphicsPathItem* outline = new QGraphicsPathItem(*linePath);
671 
672  outline->setPen(*pen);
673  outline->setBrush(*brush);
674  itemGroup->addToGroup(outline);
675  }
676  }
677  else if (ellipse != NULL)
678  {
679  QPainterPath path = item->path();
680  QSharedPointer<QPainterPath> linePath = getPath(ellipse, ending->getBoundingBox());
681  applyRotationalMapping(*linePath, ending, point, second);
682  linePath->translate(point);
683  path.addPath(*linePath);
684  item->setPath(path);
685 
686  if (ellipse->isSetFill() || group->isSetFill())
687  {
688  QSharedPointer<QBrush> brush = getBrush(ellipse, ending->getGroup(), resolver, ending->getBoundingBox());
689  QSharedPointer<QPen> pen = getPen(ellipse, ending->getGroup(), resolver, ending->getBoundingBox());
690  QGraphicsPathItem* outline = new QGraphicsPathItem(*linePath);
691  outline->setPen(*pen);
692  outline->setBrush(*brush);
693  itemGroup->addToGroup(outline);
694  }
695  }
696  else if (rect != NULL)
697  {
698  QPainterPath path = item->path();
699  QSharedPointer<QPainterPath> linePath = getPath(rect, ending->getBoundingBox());
700  applyRotationalMapping(*linePath, ending, point, second);
701  linePath->translate(point);
702  path.addPath(*linePath);
703  item->setPath(path);
704 
705  if (rect->isSetFill() || group->isSetFill())
706  {
707  QSharedPointer<QBrush> brush = getBrush(rect, ending->getGroup(), resolver, ending->getBoundingBox());
708  QSharedPointer<QPen> pen = getPen(rect, ending->getGroup(), resolver, ending->getBoundingBox());
709  QGraphicsPathItem* outline = new QGraphicsPathItem(*linePath);
710  outline->setPen(*pen);
711  outline->setBrush(*brush);
712  itemGroup->addToGroup(outline);
713  }
714  }
715  }
716 }
QSharedPointer< QPen > getPen(const CLGraphicalPrimitive1D *item, const CLGroup *group, const CLRenderResolver *resolver, const CLBoundingBox *)
void applyRotationalMapping(QPainterPath &linePath, const CLLineEnding *ending, QPointF point, QPointF second)
QSharedPointer< QBrush > getBrush(const CLGraphicalPrimitive2D *item, const CLGroup *group, const CLRenderResolver *resolver, const CLBoundingBox *pBB)
CCopasiObject * getElement(size_t n)
Definition: CLGroup.cpp:409
const CLGroup * getGroup() const
CLBoundingBox * getBoundingBox()
QSharedPointer< QPainterPath > getPath(const CLPolygon *pCurve, const CLBoundingBox *pBB)
size_t getNumElements() const
Definition: CLGroup.cpp:384
void addToPath ( QPainterPath &  path,
const CLRenderCubicBezier cubic,
const CLBoundingBox pBB 
)

Definition at line 441 of file CQRenderConverter.cpp.

References CLRenderCubicBezier::basePoint1_X(), CLRenderCubicBezier::basePoint1_Y(), CLRenderCubicBezier::basePoint2_X(), CLRenderCubicBezier::basePoint2_Y(), CLRelAbsVector::getAbsoluteValue(), CLBoundingBox::getDimensions(), CLDimensions::getHeight(), CLBoundingBox::getPosition(), CLRelAbsVector::getRelativeValue(), CLDimensions::getWidth(), CLPoint::getX(), CLRenderPoint::getXOffset(), CLPoint::getY(), and CLRenderPoint::getYOffset().

Referenced by getPath().

442 {
443  path.cubicTo(
444  pBB->getPosition().getX() + cubic->basePoint1_X().getAbsoluteValue() + cubic->basePoint1_X().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth(),
445  pBB->getPosition().getY() + cubic->basePoint1_Y().getAbsoluteValue() + cubic->basePoint1_Y().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight(),
446  pBB->getPosition().getX() + cubic->basePoint2_X().getAbsoluteValue() + cubic->basePoint2_X().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth(),
447  pBB->getPosition().getY() + cubic->basePoint2_Y().getAbsoluteValue() + cubic->basePoint2_Y().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight(),
448  pBB->getPosition().getX() + cubic->getXOffset().getAbsoluteValue() + cubic->getXOffset().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth(),
449  pBB->getPosition().getY() + cubic->getYOffset().getAbsoluteValue() + cubic->getYOffset().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight()
450  );
451 }
const CLRelAbsVector & basePoint1_X() const
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
const CLRelAbsVector & basePoint2_Y() const
double getRelativeValue() const
const CLRelAbsVector & basePoint2_X() const
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
const CLPoint & getPosition() const
Definition: CLBase.h:265
const CLRelAbsVector & getXOffset() const
const CLRelAbsVector & getYOffset() const
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
double getAbsoluteValue() const
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
const CLRelAbsVector & basePoint1_Y() const
void addToPath ( QPainterPath &  path,
const CLRenderPoint current,
const CLBoundingBox pBB 
)

Definition at line 453 of file CQRenderConverter.cpp.

References CLRelAbsVector::getAbsoluteValue(), CLBoundingBox::getDimensions(), CLDimensions::getHeight(), CLBoundingBox::getPosition(), CLRelAbsVector::getRelativeValue(), CLDimensions::getWidth(), CLPoint::getX(), CLRenderPoint::getXOffset(), CLPoint::getY(), and CLRenderPoint::getYOffset().

454 {
455  path.lineTo(
456  pBB->getPosition().getX() + current->getXOffset().getAbsoluteValue() + current->getXOffset().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth(),
457  pBB->getPosition().getY() + current->getYOffset().getAbsoluteValue() + current->getYOffset().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight()
458  );
459 }
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
double getRelativeValue() const
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
const CLPoint & getPosition() const
Definition: CLBase.h:265
const CLRelAbsVector & getXOffset() const
const CLRelAbsVector & getYOffset() const
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
double getAbsoluteValue() const
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
void adjustPosition ( QGraphicsTextItem *  item,
const CLBoundingBox pBB,
const CLText pText,
const CLGroup group 
)

Definition at line 805 of file CQRenderConverter.cpp.

References CLText::ANCHOR_BOTTOM, CLText::ANCHOR_END, CLText::ANCHOR_MIDDLE, CLText::ANCHOR_START, CLText::ANCHOR_TOP, CLBoundingBox::getDimensions(), CLDimensions::getHeight(), CLBoundingBox::getPosition(), CLGroup::getTextAnchor(), CLText::getTextAnchor(), CLGroup::getVTextAnchor(), CLText::getVTextAnchor(), CLDimensions::getWidth(), CLPoint::getX(), CLPoint::getY(), CLGroup::isSetTextAnchor(), CLText::isSetTextAnchor(), CLGroup::isSetVTextAnchor(), and CLText::isSetVTextAnchor().

Referenced by CQRenderConverter::applyStyle(), and fillItemFromText().

806 {
807  qreal width = item->boundingRect().width();
808  qreal height = item->boundingRect().height();
809  double bbWidth = pBB->getDimensions().getWidth();
810  double bbHeight = pBB->getDimensions().getHeight();
811 
812  if (group != NULL && (group->isSetTextAnchor() || group->isSetVTextAnchor()))
813  {
814  QPointF pos = item->pos();
815 
816  if (group->isSetTextAnchor() && width > 0)
817  {
818  switch (group->getTextAnchor())
819  {
821  pos.setX(pBB->getPosition().getX() + (bbWidth - width) / 2.0);
822  break;
823 
824  case CLText::ANCHOR_END:
825  pos.setX(pBB->getPosition().getX() + bbWidth - width);
826  break;
827 
829  default:
830  break;
831  }
832  }
833 
834  if (group->isSetVTextAnchor() && height > 0)
835  {
836  switch (group->getVTextAnchor())
837  {
839  pos.setY(pBB->getPosition().getY() + (bbHeight - height) / 2.0);
840  break;
841 
843  pos.setY(pBB->getPosition().getY() + (bbHeight - height));
844  break;
845 
846  case CLText::ANCHOR_TOP:
847  default:
848  break;
849  }
850  }
851 
852  item->setPos(pos);
853  }
854 
855  if (pText != NULL && (pText->isSetTextAnchor() || pText->isSetVTextAnchor()))
856  {
857  QPointF pos = item->pos();
858 
859  if (pText->isSetTextAnchor() && width > 0)
860  {
861  switch (pText->getTextAnchor())
862  {
864  pos.setX(pBB->getPosition().getX() + (bbWidth - width) / 2.0);
865  break;
866 
867  case CLText::ANCHOR_END:
868  pos.setX(pBB->getPosition().getX() + bbWidth - width);
869  break;
870 
872  default:
873  break;
874  }
875  }
876 
877  if (pText->isSetVTextAnchor() && height > 0)
878  {
879  switch (pText->getVTextAnchor())
880  {
882  pos.setY(pBB->getPosition().getY() + (bbHeight - height) / 2.0);
883  break;
884 
886  pos.setY(pBB->getPosition().getY() + bbHeight - height);
887  break;
888 
889  case CLText::ANCHOR_TOP:
890  default:
891  break;
892  }
893  }
894 
895  item->setPos(pos);
896  }
897 }
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
bool isSetVTextAnchor() const
Definition: CLText.cpp:422
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
const CLPoint & getPosition() const
Definition: CLBase.h:265
bool isSetTextAnchor() const
Definition: CLGroup.cpp:775
CLText::TEXT_ANCHOR getVTextAnchor() const
Definition: CLGroup.cpp:360
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
bool isSetTextAnchor() const
Definition: CLText.cpp:414
TEXT_ANCHOR getVTextAnchor() const
Definition: CLText.cpp:350
CLText::TEXT_ANCHOR getTextAnchor() const
Definition: CLGroup.cpp:352
TEXT_ANCHOR getTextAnchor() const
Definition: CLText.cpp:342
bool isSetVTextAnchor() const
Definition: CLGroup.cpp:783
void applyRotationalMapping ( QPainterPath &  linePath,
const CLLineEnding ending,
QPointF  point,
QPointF  second 
)

Definition at line 577 of file CQRenderConverter.cpp.

References CLLineEnding::getIsEnabledRotationalMapping(), and normalizePoint().

Referenced by addLineEndingToItem().

578 {
579  if (!ending->getIsEnabledRotationalMapping())
580  return;
581 
582  QPointF directionVector(point.x() - second.x(), point.y() - second.y());
583  directionVector = normalizePoint(directionVector);
584 
585  if (directionVector.x() == 0 && directionVector.y() == 0)
586  return;
587 
588  QPointF orthogonlVector;
589 
590  if (directionVector.x() == 0)
591  orthogonlVector = QPointF(directionVector.y(), 0);
592  else
593  orthogonlVector = QPointF(-directionVector.y() * directionVector.x(),
594  1 - directionVector.y() * directionVector.y());
595 
596  orthogonlVector = normalizePoint(orthogonlVector);
597 
598  QTransform rotateMatrix(directionVector.x(), directionVector.y(), orthogonlVector.x(),
599  orthogonlVector.y(), 0, 0);
600 
601  linePath = rotateMatrix.map(linePath);
602 }
QPointF normalizePoint(const QPointF &vector)
bool getIsEnabledRotationalMapping() const
void fillItemFromCurve ( QGraphicsItemGroup *  item,
const CLBoundingBox pBB,
const CLCurve pCurve,
const CLGroup group,
const CLRenderResolver resolver 
)

Definition at line 381 of file CQRenderConverter.cpp.

References CLLineSegment::getBase1(), CLLineSegment::getBase2(), CLLineSegment::getEnd(), CLCurve::getListOfPoints(), CLCurve::getNumCurveSegments(), getPen(), CLCurve::getSegmentAt(), CLLineSegment::getStart(), CLPoint::getX(), CLPoint::getY(), CLLineSegment::isBezier(), and CLCurve::isContinuous().

Referenced by fillItemFromGroup().

382 {
383  QPainterPath path;
384 
385  if (!pCurve->isContinuous())
386  {
387  for (size_t i = 0; i < pCurve->getNumCurveSegments(); ++i)
388  {
389  const CLLineSegment* current = pCurve->getSegmentAt(i);
390  path.moveTo(current->getStart().getX(), current->getStart().getY());
391 
392  if (current->isBezier())
393  {
394  path.cubicTo(
395  current->getBase1().getX(), current->getBase1().getY(),
396  current->getBase2().getX(), current->getBase2().getY(),
397  current->getEnd().getX(), current->getEnd().getY());
398  }
399  else
400  {
401  path.lineTo(
402  current->getEnd().getX(), current->getEnd().getY());
403  }
404  }
405  }
406  else if (pCurve->getListOfPoints().size() > 0)
407  {
408  for (size_t i = 0; i < pCurve->getNumCurveSegments(); ++i)
409  {
410  const CLLineSegment* current = pCurve->getSegmentAt(i);
411 
412  if (i == 0)
413  path.moveTo(current->getStart().getX(), current->getStart().getY());
414 
415  if (current->isBezier())
416  {
417  path.cubicTo(
418  current->getBase1().getX(), current->getBase1().getY(),
419  current->getBase2().getX(), current->getBase2().getY(),
420  current->getEnd().getX(), current->getEnd().getY());
421  }
422  else
423  {
424  path.lineTo(
425  current->getEnd().getX(), current->getEnd().getY());
426  }
427  }
428  }
429  else return;
430 
431  QGraphicsPathItem *pathItem = new QGraphicsPathItem(path);
432  QSharedPointer<QPen> pen = getPen(NULL, group, resolver, pBB);
433  pathItem->setPen(*pen);
434 
435  //QBrush *brush = getBrush(NULL, group, resolver, pBB);
436  //pathItem->setBrush(*brush);
437  //delete brush;
438  item->addToGroup(pathItem);
439 }
const CLPoint & getBase1() const
Definition: CLCurve.h:82
QSharedPointer< QPen > getPen(const CLGraphicalPrimitive1D *item, const CLGroup *group, const CLRenderResolver *resolver, const CLBoundingBox *)
const CLPoint & getBase2() const
Definition: CLCurve.h:83
const CLPoint & getEnd() const
Definition: CLCurve.h:75
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
std::vector< CLPoint > getListOfPoints() const
Definition: CLCurve.cpp:130
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
bool isBezier() const
Definition: CLCurve.h:90
const CLLineSegment * getSegmentAt(size_t i) const
Definition: CLCurve.h:156
size_t getNumCurveSegments() const
Definition: CLCurve.h:168
bool isContinuous() const
Definition: CLCurve.cpp:117
const CLPoint & getStart() const
Definition: CLCurve.h:74
void fillItemFromEllipse ( QGraphicsItemGroup *  item,
const CLBoundingBox pBB,
const CLEllipse pEllipse,
const CLGroup group,
const CLRenderResolver resolver 
)

Definition at line 362 of file CQRenderConverter.cpp.

References CLRelAbsVector::getAbsoluteValue(), getBrush(), CLEllipse::getCX(), CLEllipse::getCY(), CLBoundingBox::getDimensions(), CLDimensions::getHeight(), getPen(), CLBoundingBox::getPosition(), CLRelAbsVector::getRelativeValue(), CLEllipse::getRX(), CLEllipse::getRY(), CLDimensions::getWidth(), CLPoint::getX(), CLPoint::getY(), and transform().

Referenced by fillItemFromGroup().

363 {
364  double x = pBB->getPosition().getX() + pEllipse->getCX().getAbsoluteValue() + pEllipse->getCX().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth();
365  double y = pBB->getPosition().getY() + pEllipse->getCY().getAbsoluteValue() + pEllipse->getCY().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight();
366  double rx = pEllipse->getRX().getAbsoluteValue() + pEllipse->getRX().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth();
367  double ry = pEllipse->getRY().getAbsoluteValue() + pEllipse->getRY().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight();
368 
369  QGraphicsEllipseItem* ellipseItem = new QGraphicsEllipseItem(
370  x - rx, y - ry, rx * 2, ry * 2);
371  QSharedPointer<QPen> pen = getPen(pEllipse, group, resolver, pBB);
372  ellipseItem->setPen(*pen);
373 
374  QSharedPointer<QBrush> brush = getBrush(pEllipse, group, resolver, pBB);
375  ellipseItem->setBrush(*brush);
376 
377  transform(ellipseItem, pEllipse, group);
378  item->addToGroup(ellipseItem);
379 }
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
double getRelativeValue() const
const CLRelAbsVector & getRX() const
Definition: CLEllipse.cpp:151
QSharedPointer< QPen > getPen(const CLGraphicalPrimitive1D *item, const CLGroup *group, const CLRenderResolver *resolver, const CLBoundingBox *)
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
const CLRelAbsVector & getCY() const
Definition: CLEllipse.cpp:135
QSharedPointer< QBrush > getBrush(const CLGraphicalPrimitive2D *item, const CLGroup *group, const CLRenderResolver *resolver, const CLBoundingBox *pBB)
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
const CLPoint & getPosition() const
Definition: CLBase.h:265
void transform(QGraphicsItem *item, const CLTransformation2D *trans, const CLGroup *group)
const CLRelAbsVector & getRY() const
Definition: CLEllipse.cpp:159
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
double getAbsoluteValue() const
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
const CLRelAbsVector & getCX() const
Definition: CLEllipse.cpp:127
void fillItemFromGroup ( QGraphicsItemGroup *  item,
const CLBoundingBox bounds,
const CLGroup group,
const CLRenderResolver resolver 
)

Definition at line 983 of file CQRenderConverter.cpp.

References fillItemFromCurve(), fillItemFromEllipse(), fillItemFromImage(), fillItemFromPolygon(), fillItemFromRectangle(), fillItemFromRenderCurve(), fillItemFromText(), CLGroup::getElement(), CLGroup::getNumElements(), and transform().

Referenced by CQRenderConverter::fillGroupFromStyle().

984 {
985  if (group == NULL)
986  return;
987 
988  size_t numElements = group->getNumElements();
989 
990  if (numElements == 0)
991  {
992  return;
993  }
994 
995  for (size_t i = 0; i < numElements; ++i)
996  {
997  const CCopasiObject* object = group->getElement(i);
998  const CLEllipse* ellipse = dynamic_cast<const CLEllipse*>(object);
999  const CLRectangle* rect = dynamic_cast<const CLRectangle*>(object);
1000  const CLPolygon* poly = dynamic_cast<const CLPolygon*>(object);
1001  const CLCurve* curve = dynamic_cast<const CLCurve*>(object);
1002  const CLRenderCurve* rcurve = dynamic_cast<const CLRenderCurve*>(object);
1003  const CLText* text = dynamic_cast<const CLText*>(object);
1004  const CLImage* image = dynamic_cast<const CLImage*>(object);
1005  const CLGroup* childGroup = dynamic_cast<const CLGroup*>(object);
1006 
1007  if (ellipse != NULL)
1008  {
1009  fillItemFromEllipse(item, bounds, ellipse, group, resolver);
1010  }
1011  else if (rect != NULL)
1012  {
1013  fillItemFromRectangle(item, bounds, rect, group, resolver);
1014  }
1015  else if (text != NULL)
1016  {
1017  fillItemFromText(item, bounds, text, group, resolver);
1018  }
1019  else if (curve != NULL)
1020  {
1021  fillItemFromCurve(item, bounds, curve, group, resolver);
1022  }
1023  else if (rcurve != NULL)
1024  {
1025  fillItemFromRenderCurve(item, bounds, rcurve, group, resolver);
1026  }
1027  else if (poly != NULL)
1028  {
1029  fillItemFromPolygon(item, bounds, poly, group, resolver);
1030  }
1031  else if (image != NULL)
1032  {
1033  fillItemFromImage(item, bounds, image, group, resolver);
1034  }
1035  else if (childGroup != NULL)
1036  {
1037  fillItemFromGroup(item, bounds, childGroup, resolver);
1038  }
1039  }
1040 
1041  transform(item, group, NULL);
1042 }
void fillItemFromImage(QGraphicsItemGroup *item, const CLBoundingBox *pBB, const CLImage *pImage, const CLGroup *group, const CLRenderResolver *)
Definition: CLText.h:27
CCopasiObject * getElement(size_t n)
Definition: CLGroup.cpp:409
void fillItemFromGroup(QGraphicsItemGroup *item, const CLBoundingBox *bounds, const CLGroup *group, const CLRenderResolver *resolver)
void transform(QGraphicsItem *item, const CLTransformation2D *trans, const CLGroup *group)
void fillItemFromText(QGraphicsItemGroup *item, const CLBoundingBox *pBB, const CLText *pText, const CLGroup *group, const CLRenderResolver *resolver)
void fillItemFromRenderCurve(QGraphicsItemGroup *item, const CLBoundingBox *pBB, const CLRenderCurve *pCurve, const CLGroup *group, const CLRenderResolver *resolver)
void fillItemFromRectangle(QGraphicsItemGroup *item, const CLBoundingBox *pBB, const CLRectangle *pRect, const CLGroup *group, const CLRenderResolver *resolver)
size_t getNumElements() const
Definition: CLGroup.cpp:384
void fillItemFromPolygon(QGraphicsItemGroup *item, const CLBoundingBox *pBB, const CLPolygon *pPoly, const CLGroup *group, const CLRenderResolver *resolver)
void fillItemFromCurve(QGraphicsItemGroup *item, const CLBoundingBox *pBB, const CLCurve *pCurve, const CLGroup *group, const CLRenderResolver *resolver)
void fillItemFromEllipse(QGraphicsItemGroup *item, const CLBoundingBox *pBB, const CLEllipse *pEllipse, const CLGroup *group, const CLRenderResolver *resolver)
void fillItemFromImage ( QGraphicsItemGroup *  item,
const CLBoundingBox pBB,
const CLImage pImage,
const CLGroup group,
const CLRenderResolver  
)

Definition at line 929 of file CQRenderConverter.cpp.

References CLRelAbsVector::getAbsoluteValue(), CCopasiRootContainer::getDatamodelList(), CLBoundingBox::getDimensions(), CLImage::getHeight(), CLDimensions::getHeight(), CLImage::getImageReference(), CLBoundingBox::getPosition(), CLRelAbsVector::getRelativeValue(), CLImage::getWidth(), CLDimensions::getWidth(), CLPoint::getX(), CLImage::getX(), CLPoint::getY(), CLImage::getY(), and transform().

Referenced by fillItemFromGroup().

930 {
931  double x = pBB->getPosition().getX() + pImage->getX().getAbsoluteValue() + pImage->getX().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth();
932  double y = pBB->getPosition().getY() + pImage->getY().getAbsoluteValue() + pImage->getY().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight();
933  double w = pImage->getWidth().getAbsoluteValue() + pImage->getWidth().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth();
934  double h = pImage->getHeight().getAbsoluteValue() + pImage->getHeight().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight();
935 
936  QFile *fileName = new QFile(pImage->getImageReference().c_str());
937 
938  if (!fileName->exists())
939  {
940  delete fileName;
941  std::string file = ((*CCopasiRootContainer::getDatamodelList())[0])->getReferenceDirectory() + "/" + pImage->getImageReference();
942  fileName = new QFile(file.c_str());
943  }
944 
945  if (!fileName->exists())
946  {
947  delete fileName;
948  return;
949  }
950 
951  QPixmap pixmap(fileName->fileName());
952  pixmap = pixmap.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
953  delete fileName;
954  QGraphicsPixmapItem* result = new QGraphicsPixmapItem(
955  pixmap);
956  result->setPos(x, y);
957  transform(result, pImage, group);
958 
959  item->addToGroup(result);
960 }
CLRelAbsVector & getX()
Definition: CLImage.cpp:198
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
const CLRelAbsVector & getHeight() const
Definition: CLImage.cpp:116
CLRelAbsVector & getY()
Definition: CLImage.cpp:206
double getRelativeValue() const
const std::string & getImageReference() const
Definition: CLImage.cpp:132
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
const CLPoint & getPosition() const
Definition: CLBase.h:265
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
void transform(QGraphicsItem *item, const CLTransformation2D *trans, const CLGroup *group)
const CLRelAbsVector & getWidth() const
Definition: CLImage.cpp:108
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
double getAbsoluteValue() const
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
void fillItemFromPolygon ( QGraphicsItemGroup *  item,
const CLBoundingBox pBB,
const CLPolygon pPoly,
const CLGroup group,
const CLRenderResolver resolver 
)

Definition at line 759 of file CQRenderConverter.cpp.

References CLGraphicalPrimitive2D::EVENODD, getBrush(), CLGraphicalPrimitive2D::getFillRule(), getPath(), getPen(), CLGraphicalPrimitive2D::isSetFillRule(), CLGraphicalPrimitive2D::NONZERO, and transform().

Referenced by fillItemFromGroup().

760 {
761  QSharedPointer<QPainterPath> path = getPath(pPoly, pBB);
762  path->setFillRule(Qt::WindingFill);
763 
764  if (pPoly->isSetFillRule())
765  {
766  switch (pPoly->getFillRule())
767  {
769  path->setFillRule(Qt::OddEvenFill);
770  break;
771 
773  default:
774  path->setFillRule(Qt::WindingFill);
775  break;
776  }
777  }
778 
779  if (group->isSetFillRule())
780  {
781  switch (group->getFillRule())
782  {
784  path->setFillRule(Qt::OddEvenFill);
785  break;
786 
788  default:
789  path->setFillRule(Qt::WindingFill);
790  break;
791  }
792  }
793 
794  QGraphicsPathItem *pathItem = new QGraphicsPathItem(*path);
795  QSharedPointer<QPen> pen = getPen(pPoly, group, resolver, pBB);
796  pathItem->setPen(*pen);
797  QSharedPointer<QBrush> brush = getBrush(pPoly, group, resolver, pBB);
798  pathItem->setBrush(*brush);
799 
800  transform(pathItem, pPoly, group);
801 
802  item->addToGroup(pathItem);
803 }
QSharedPointer< QPen > getPen(const CLGraphicalPrimitive1D *item, const CLGroup *group, const CLRenderResolver *resolver, const CLBoundingBox *)
QSharedPointer< QBrush > getBrush(const CLGraphicalPrimitive2D *item, const CLGroup *group, const CLRenderResolver *resolver, const CLBoundingBox *pBB)
void transform(QGraphicsItem *item, const CLTransformation2D *trans, const CLGroup *group)
QSharedPointer< QPainterPath > getPath(const CLPolygon *pCurve, const CLBoundingBox *pBB)
void fillItemFromRectangle ( QGraphicsItemGroup *  item,
const CLBoundingBox pBB,
const CLRectangle pRect,
const CLGroup group,
const CLRenderResolver resolver 
)

Definition at line 962 of file CQRenderConverter.cpp.

References CLRelAbsVector::getAbsoluteValue(), getBrush(), CLBoundingBox::getDimensions(), CLRectangle::getHeight(), CLDimensions::getHeight(), getPen(), CLBoundingBox::getPosition(), CLRectangle::getRadiusX(), CLRectangle::getRadiusY(), CLRelAbsVector::getRelativeValue(), CLRectangle::getWidth(), CLDimensions::getWidth(), CLPoint::getX(), CLRectangle::getX(), CLPoint::getY(), CLRectangle::getY(), and transform().

Referenced by fillItemFromGroup().

963 {
964  double x = pBB->getPosition().getX() + pRect->getX().getAbsoluteValue() + pRect->getX().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth();
965  double y = pBB->getPosition().getY() + pRect->getY().getAbsoluteValue() + pRect->getY().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight();
966  double w = pRect->getWidth().getAbsoluteValue() + pRect->getWidth().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth();
967  double h = pRect->getHeight().getAbsoluteValue() + pRect->getHeight().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight();
968  double rx = pRect->getRadiusX().getAbsoluteValue() + pRect->getRadiusX().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth();
969  double ry = pRect->getRadiusY().getAbsoluteValue() + pRect->getRadiusY().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight();
970 
971  QGraphicsRectItem* result = new CQRoundedRect(
972  x, y, w, h, rx, ry);
973  QSharedPointer<QPen> pen = getPen(pRect, group, resolver, pBB);
974  result->setPen(*pen);
975 
976  QSharedPointer<QBrush> brush = getBrush(pRect, group, resolver, pBB);
977  result->setBrush(*brush);
978 
979  transform(result, pRect, group);
980  item->addToGroup(result);
981 }
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
const CLRelAbsVector & getRadiusY() const
const CLRelAbsVector & getWidth() const
double getRelativeValue() const
const CLRelAbsVector & getX() const
QSharedPointer< QPen > getPen(const CLGraphicalPrimitive1D *item, const CLGroup *group, const CLRenderResolver *resolver, const CLBoundingBox *)
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
const CLRelAbsVector & getY() const
const CLRelAbsVector & getRadiusX() const
QSharedPointer< QBrush > getBrush(const CLGraphicalPrimitive2D *item, const CLGroup *group, const CLRenderResolver *resolver, const CLBoundingBox *pBB)
const CLRelAbsVector & getHeight() const
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
const CLPoint & getPosition() const
Definition: CLBase.h:265
void transform(QGraphicsItem *item, const CLTransformation2D *trans, const CLGroup *group)
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
double getAbsoluteValue() const
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
void fillItemFromRenderCurve ( QGraphicsItemGroup *  item,
const CLBoundingBox pBB,
const CLRenderCurve pCurve,
const CLGroup group,
const CLRenderResolver resolver 
)

Definition at line 718 of file CQRenderConverter.cpp.

References addLineEndingToItem(), CLRenderCurve::getEndHead(), CLGroup::getEndHead(), CLLineEnding::getGroup(), CLRenderResolver::getLineEnding(), getPath(), getPen(), CLRenderCurve::getStartHead(), CLGroup::getStartHead(), CLRenderCurve::isSetEndHead(), CLGroup::isSetEndHead(), CLRenderCurve::isSetStartHead(), and transform().

Referenced by fillItemFromGroup().

719 {
720  QSharedPointer<QPainterPath> path = getPath(pCurve, pBB);
721 
722  QGraphicsPathItem *pathItem = new QGraphicsPathItem(*path);
723  QSharedPointer<QPen> pen = getPen(pCurve, group, resolver, pBB);
724  pathItem->setPen(*pen);
725 
726  item->addToGroup(pathItem);
727  //QBrush *brush = getBrush(NULL, group, resolver, pBB);
728  //pathItem->setBrush(*brush);
729  //delete brush;
730 
731  if (path->elementCount() > 1)
732  {
733  if (group -> isSetStartHead())
734  {
735  const CLLineEnding *line = resolver->getLineEnding(group->getStartHead());
736  addLineEndingToItem(pathItem, line, group, resolver, path->elementAt(0), path->elementAt(1), item);
737  }
738  else if (pCurve->isSetStartHead())
739  {
740  const CLLineEnding *line = resolver->getLineEnding(pCurve->getStartHead());
741  addLineEndingToItem(pathItem, line, line->getGroup(), resolver, path->elementAt(0), path->elementAt(1), item);
742  }
743 
744  if (group->isSetEndHead())
745  {
746  const CLLineEnding *line = resolver->getLineEnding(group->getEndHead());
747  addLineEndingToItem(pathItem, line, group, resolver, path->elementAt(path->elementCount() - 1), path->elementAt(path->elementCount() - 2), item);
748  }
749  else if (pCurve->isSetEndHead())
750  {
751  const CLLineEnding *line = resolver->getLineEnding(pCurve->getEndHead());
752  addLineEndingToItem(pathItem, line, line->getGroup(), resolver, path->elementAt(path->elementCount() - 1), path->elementAt(path->elementCount() - 2), item);
753  }
754  }
755 
756  transform(pathItem, pCurve, group);
757 }
const std::string & getStartHead() const
bool isSetEndHead() const
Definition: CLGroup.cpp:560
QSharedPointer< QPen > getPen(const CLGraphicalPrimitive1D *item, const CLGroup *group, const CLRenderResolver *resolver, const CLBoundingBox *)
const std::string & getEndHead() const
const std::string & getStartHead() const
Definition: CLGroup.cpp:368
const CLGroup * getGroup() const
const std::string & getEndHead() const
Definition: CLGroup.cpp:376
void transform(QGraphicsItem *item, const CLTransformation2D *trans, const CLGroup *group)
bool isSetStartHead() const
void addLineEndingToItem(QGraphicsPathItem *item, const CLLineEnding *ending, const CLGroup *group, const CLRenderResolver *resolver, QPointF point, QPointF second, QGraphicsItemGroup *itemGroup)
bool isSetEndHead() const
QSharedPointer< QPainterPath > getPath(const CLPolygon *pCurve, const CLBoundingBox *pBB)
const CLLineEnding * getLineEnding(const std::string &id) const
void fillItemFromText ( QGraphicsItemGroup *  item,
const CLBoundingBox pBB,
const CLText pText,
const CLGroup group,
const CLRenderResolver resolver 
)

Definition at line 899 of file CQRenderConverter.cpp.

References adjustPosition(), CLRelAbsVector::getAbsoluteValue(), getColor(), CLBoundingBox::getDimensions(), getFont(), CLDimensions::getHeight(), CLBoundingBox::getPosition(), CLRelAbsVector::getRelativeValue(), CLGraphicalPrimitive1D::getStroke(), CLText::getText(), CLDimensions::getWidth(), CLPoint::getX(), CLText::getX(), CLPoint::getY(), CLText::getY(), CLGraphicalPrimitive1D::isSetStroke(), and transform().

Referenced by fillItemFromGroup().

900 {
901  double x = pBB->getPosition().getX() + pText->getX().getAbsoluteValue() + pText->getX().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth();
902  double y = pBB->getPosition().getY() + pText->getY().getAbsoluteValue() + pText->getY().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight();
903 
904  QGraphicsTextItem* result = new QGraphicsTextItem(pText->getText().c_str());
905  result ->setPos(x, y);
906 
907  if (pText->isSetStroke())
908  {
909  result->setDefaultTextColor(getColor(pText->getStroke(), resolver));
910  }
911  else if (group->isSetStroke())
912  {
913  result->setDefaultTextColor(getColor(group->getStroke(), resolver));
914  }
915 
916  QSharedPointer<QFont> font = getFont(pText, group, resolver, pBB);
917 
918  if (!font.isNull())
919  {
920  result->setFont(*font);
921 
922  adjustPosition(result, pBB, pText, group);
923  }
924 
925  transform(result, pText, group);
926  item->addToGroup(result);
927 }
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
QSharedPointer< QFont > getFont(const CLText *item, const CLGroup *group, const CLRenderResolver *, const CLBoundingBox *pBB)
const CLRelAbsVector & getY() const
Definition: CLText.cpp:214
double getRelativeValue() const
const std::string & getStroke() const
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
const CLPoint & getPosition() const
Definition: CLBase.h:265
void transform(QGraphicsItem *item, const CLTransformation2D *trans, const CLGroup *group)
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
double getAbsoluteValue() const
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
QColor getColor(const CLColorDefinition *cd)
const std::string & getText() const
Definition: CLText.cpp:358
const CLRelAbsVector & getX() const
Definition: CLText.cpp:206
void adjustPosition(QGraphicsTextItem *item, const CLBoundingBox *pBB, const CLText *pText, const CLGroup *group)
QSharedPointer<QBrush> getBrush ( const CLGraphicalPrimitive2D item,
const CLGroup group,
const CLRenderResolver resolver,
const CLBoundingBox pBB 
)

Definition at line 272 of file CQRenderConverter.cpp.

References getColor(), CLGraphicalPrimitive2D::getFillColor(), getGradient(), CLRenderResolver::getGradientBase(), and CLGraphicalPrimitive2D::isSetFill().

Referenced by addLineEndingToItem(), fillItemFromEllipse(), fillItemFromPolygon(), and fillItemFromRectangle().

273 {
274  QColor color;
275 
276  if (item != NULL && item->isSetFill())
277  {
278  const CLGradientBase* base = resolver->getGradientBase(item->getFillColor());
279 
280  if (base != NULL)
281  {
282  return QSharedPointer<QBrush>(new QBrush(*getGradient(base, pBB, resolver)));
283  }
284 
285  return QSharedPointer<QBrush>(new QBrush(getColor(item->getFillColor(), resolver)));
286  }
287  else if (group != NULL && group->isSetFill())
288  {
289  const CLGradientBase* base = resolver->getGradientBase(group->getFillColor());
290 
291  if (base != NULL)
292  {
293  return QSharedPointer<QBrush>(new QBrush(*getGradient(base, pBB, resolver)));
294  }
295 
296  return QSharedPointer<QBrush>(new QBrush(getColor(group->getFillColor(), resolver)));
297  }
298 
299  return QSharedPointer<QBrush>(new QBrush());
300 }
QSharedPointer< QGradient > getGradient(const CLGradientBase *base, const CLBoundingBox *bounds, const CLRenderResolver *resolver)
const std::string & getFillColor() const
QColor getColor(const CLColorDefinition *cd)
const CLGradientBase * getGradientBase(const std::string &id) const
QColor getColor ( const CLColorDefinition cd)
QColor getColor ( const std::string &  color,
const CLRenderResolver resolver 
)

Definition at line 91 of file CQRenderConverter.cpp.

References getColor(), CLRenderResolver::getColorDefinition(), CLRenderResolver::getGradientBase(), and CLColorDefinition::setColorValue().

92 {
93  if (color == "none")
94  return QColor(Qt::transparent);
95 
96  if (resolver->getColorDefinition(color) == NULL && resolver->getGradientBase(color) == NULL)
97  {
98  CLColorDefinition cd; cd.setColorValue(color);
99  return getColor(&cd);
100  }
101 
102  return getColor(resolver->getColorDefinition(color));
103 }
const CLColorDefinition * getColorDefinition(const std::string &id) const
bool setColorValue(const std::string &valueString)
QColor getColor(const CLColorDefinition *cd)
const CLGradientBase * getGradientBase(const std::string &id) const
QSharedPointer<QFont> getFont ( const CLText item,
const CLGroup group,
const CLRenderResolver ,
const CLBoundingBox pBB 
)

Definition at line 193 of file CQRenderConverter.cpp.

References CLRelAbsVector::getAbsoluteValue(), CLBoundingBox::getDimensions(), CLGroup::getFontFamily(), CLText::getFontFamily(), CLGroup::getFontSize(), CLText::getFontSize(), CLGroup::getFontStyle(), CLText::getFontStyle(), CLGroup::getFontWeight(), CLText::getFontWeight(), CLDimensions::getHeight(), CLRelAbsVector::getRelativeValue(), CLText::isSetFontFamily(), CLGroup::isSetFontFamily(), CLText::isSetFontSize(), CLGroup::isSetFontSize(), CLText::isSetFontStyle(), CLGroup::isSetFontStyle(), CLText::isSetFontWeight(), CLGroup::isSetFontWeight(), CLText::STYLE_ITALIC, CLText::WEIGHT_BOLD, and CLText::WEIGHT_NORMAL.

Referenced by CQRenderConverter::applyStyle(), fillItemFromText(), and CopasiUI3Window::slotFontSelection().

194 {
195  QString font("Verdana"); double fontSize = 10, weight = 50; bool italic = false;
196 
197  if (item != NULL && item->isSetFontFamily())
198  font = item->getFontFamily().c_str();
199  else if (group != NULL && group->isSetFontFamily())
200  font = group->getFontFamily().c_str();
201 
202  if (item != NULL && item->isSetFontSize())
203  fontSize = item->getFontSize().getAbsoluteValue() + item->getFontSize().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight();
204  else if (group != NULL && group->isSetFontSize())
205  fontSize = group->getFontSize().getAbsoluteValue() + group->getFontSize().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight();
206 
207  if (item != NULL && item->isSetFontWeight())
208  switch (item->getFontWeight())
209  {
210  case CLText::WEIGHT_BOLD:
211  weight = QFont::Bold;
212  break;
213 
215  default:
216  weight = QFont::Normal;
217  break;
218  }
219  else if (group != NULL && group->isSetFontWeight())
220  switch (group->getFontWeight())
221  {
222  case CLText::WEIGHT_BOLD:
223  weight = QFont::Bold;
224  break;
225 
227  default:
228  weight = QFont::Normal;
229  break;
230  }
231 
232  if (item != NULL && item->isSetFontStyle())
233  switch (item->getFontStyle())
234  {
236  italic = true;
237  break;
238 
239  default:
240  break;
241  }
242  else if (group != NULL && group->isSetFontStyle())
243  switch (group->getFontStyle())
244  {
246  italic = true;
247  break;
248 
249  default:
250  break;
251  }
252 
253  QSharedPointer<QFont> result = QSharedPointer<QFont>(new QFont(font, -1, weight, italic));
254  result->setPixelSize(fontSize);
255 
256  if (font == "serif")
257  {
258  result->setStyleHint(QFont::Serif);
259  }
260  else if (font == "sans-serif" || font == "sans")
261  {
262  result->setStyleHint(QFont::SansSerif);
263  }
264  else if (font == "monospace")
265  {
266  result->setStyleHint(QFont::Monospace);
267  }
268 
269  return result;
270 }
bool isSetFontWeight() const
Definition: CLGroup.cpp:584
bool isSetFontFamily() const
Definition: CLGroup.cpp:568
bool isSetFontSize() const
Definition: CLGroup.cpp:576
double getRelativeValue() const
bool isSetFontStyle() const
Definition: CLText.cpp:406
const std::string & getFontFamily() const
Definition: CLGroup.cpp:312
const CLRelAbsVector & getFontSize() const
Definition: CLText.cpp:318
bool isSetFontSize() const
Definition: CLText.cpp:390
CLRelAbsVector & getFontSize()
Definition: CLGroup.cpp:320
bool isSetFontFamily() const
Definition: CLText.cpp:382
FONT_STYLE getFontStyle() const
Definition: CLText.cpp:334
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
bool isSetFontStyle() const
Definition: CLGroup.cpp:592
CLText::FONT_STYLE getFontStyle() const
Definition: CLGroup.cpp:344
CLText::FONT_WEIGHT getFontWeight() const
Definition: CLGroup.cpp:336
double getAbsoluteValue() const
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
const std::string & getFontFamily() const
Definition: CLText.cpp:302
bool isSetFontWeight() const
Definition: CLText.cpp:398
FONT_WEIGHT getFontWeight() const
Definition: CLText.cpp:326
QSharedPointer<QGradient> getGradient ( const CLGradientBase base,
const CLBoundingBox bounds,
const CLRenderResolver resolver 
)

Definition at line 178 of file CQRenderConverter.cpp.

References getLinearGradient(), getRadialGradient(), and linear().

Referenced by getBrush().

179 {
180  const CLLinearGradient* linear = dynamic_cast<const CLLinearGradient*>(base);
181 
182  if (linear != NULL)
183  return getLinearGradient(linear, bounds, resolver);
184 
185  const CLRadialGradient* radial = dynamic_cast<const CLRadialGradient*>(base);
186 
187  if (radial != NULL)
188  return getRadialGradient(radial, bounds, resolver);
189 
190  return QSharedPointer<QGradient>();
191 }
qreal linear(qreal a, qreal b, qreal t)
QSharedPointer< QRadialGradient > getRadialGradient(const CLRadialGradient *radial, const CLBoundingBox *bounds, const CLRenderResolver *resolver)
QSharedPointer< QLinearGradient > getLinearGradient(const CLLinearGradient *linear, const CLBoundingBox *bounds, const CLRenderResolver *resolver)
QSharedPointer<QLinearGradient> getLinearGradient ( const CLLinearGradient linear,
const CLBoundingBox bounds,
const CLRenderResolver resolver 
)

Definition at line 105 of file CQRenderConverter.cpp.

References CLRelAbsVector::getAbsoluteValue(), getColor(), CLBoundingBox::getDimensions(), CLGradientBase::getGradientStop(), CLDimensions::getHeight(), CLGradientBase::getNumGradientStops(), CLGradientStop::getOffset(), CLBoundingBox::getPosition(), CLRelAbsVector::getRelativeValue(), CLGradientBase::getSpreadMethod(), CLGradientStop::getStopColor(), CLDimensions::getWidth(), CLPoint::getX(), CLLinearGradient::getXPoint1(), CLLinearGradient::getXPoint2(), CLPoint::getY(), CLLinearGradient::getYPoint1(), CLLinearGradient::getYPoint2(), CLGradientBase::PAD, CLGradientBase::REFLECT, and CLGradientBase::REPEAT.

Referenced by getGradient().

106 {
107  double x1 = bounds->getPosition().getX() + linear->getXPoint1().getAbsoluteValue() + (linear->getXPoint1().getRelativeValue() / 100.0 * bounds->getDimensions().getWidth());
108  double y1 = bounds->getPosition().getY() + linear->getYPoint1().getAbsoluteValue() + (linear->getYPoint1().getRelativeValue() / 100.0 * bounds->getDimensions().getHeight());
109  double x2 = bounds->getPosition().getX() + linear->getXPoint2().getAbsoluteValue() + (linear->getXPoint2().getRelativeValue() / 100.0 * bounds->getDimensions().getWidth());
110  double y2 = bounds->getPosition().getY() + linear->getYPoint2().getAbsoluteValue() + (linear->getYPoint2().getRelativeValue() / 100.0 * bounds->getDimensions().getHeight());
111 
112  QSharedPointer<QLinearGradient> result = QSharedPointer<QLinearGradient>(new QLinearGradient(x1, y1, x2, y2));
113 
114  switch (linear->getSpreadMethod())
115  {
117  result->setSpread(QGradient::ReflectSpread);
118  break;
119 
121  result->setSpread(QGradient::RepeatSpread);
122  break;
123 
124  case CLGradientBase::PAD:
125  result->setSpread(QGradient::PadSpread);
126  break;
127 
128  default:
129  break;
130  }
131 
132  for (size_t i = 0; i < linear->getNumGradientStops(); ++i)
133  {
134  const CLGradientStop* stop = linear->getGradientStop(i);
135  result->setColorAt(stop->getOffset().getAbsoluteValue() + stop->getOffset().getRelativeValue() / 100.0, getColor(stop->getStopColor(), resolver));
136  }
137 
138  return result;
139 }
const CLRelAbsVector & getYPoint1() const
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
double getRelativeValue() const
CLGradientStop * getGradientStop(size_t i)
const CLRelAbsVector & getXPoint2() const
size_t getNumGradientStops() const
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
const std::string & getStopColor() const
const CLRelAbsVector & getOffset() const
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
const CLPoint & getPosition() const
Definition: CLBase.h:265
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
double getAbsoluteValue() const
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
QColor getColor(const CLColorDefinition *cd)
SPREADMETHOD getSpreadMethod() const
const CLRelAbsVector & getYPoint2() const
const CLRelAbsVector & getXPoint1() const
QSharedPointer<QPainterPath> getPath ( const CLPolygon pCurve,
const CLBoundingBox pBB 
)

Definition at line 468 of file CQRenderConverter.cpp.

References addToPath(), CLPolygon::getListOfElements(), and moveToPoint().

Referenced by addLineEndingToItem(), fillItemFromPolygon(), and fillItemFromRenderCurve().

469 {
470  QSharedPointer<QPainterPath> path = QSharedPointer<QPainterPath>(new QPainterPath());
471 
472  const std::vector<CLRenderPoint*>& elements = *pCurve->getListOfElements();
473  std::vector<CLRenderPoint*>::const_iterator it = elements.begin();
474  bool first = true;
475 
476  for (; it != elements.end(); ++it)
477  {
478  const CLRenderPoint* current = *it;
479  const CLRenderCubicBezier* cubic = dynamic_cast<const CLRenderCubicBezier*>(current);
480 
481  if (first)
482  {
483  moveToPoint(*path, current, pBB);
484  first = false;
485  continue;
486  }
487 
488  if (cubic != NULL)
489  {
490  addToPath(*path, cubic, pBB);
491  }
492  else
493  {
494  addToPath(*path, current, pBB);
495  }
496  }
497 
498  path->closeSubpath();
499 
500  return path;
501 }
void moveToPoint(QPainterPath &path, const CLRenderPoint *current, const CLBoundingBox *pBB)
void addToPath(QPainterPath &path, const CLRenderCubicBezier *cubic, const CLBoundingBox *pBB)
std::vector< CLRenderPoint * > * getListOfElements()
Definition: CLPolygon.cpp:108
QSharedPointer<QPainterPath> getPath ( const CLRectangle pRect,
const CLBoundingBox pBB 
)

Definition at line 503 of file CQRenderConverter.cpp.

References CLRelAbsVector::getAbsoluteValue(), CLBoundingBox::getDimensions(), CLRectangle::getHeight(), CLDimensions::getHeight(), CLBoundingBox::getPosition(), CLRectangle::getRadiusX(), CLRectangle::getRadiusY(), CLRelAbsVector::getRelativeValue(), CLRectangle::getWidth(), CLDimensions::getWidth(), CLPoint::getX(), CLRectangle::getX(), CLPoint::getY(), and CLRectangle::getY().

504 {
505 
506  double x = pBB->getPosition().getX() + pRect->getX().getAbsoluteValue() + pRect->getX().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth();
507  double y = pBB->getPosition().getY() + pRect->getY().getAbsoluteValue() + pRect->getY().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight();
508  double w = pRect->getWidth().getAbsoluteValue() + pRect->getWidth().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth();
509  double h = pRect->getHeight().getAbsoluteValue() + pRect->getHeight().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight();
510  double rx = pRect->getRadiusX().getAbsoluteValue() + pRect->getRadiusX().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth();
511  double ry = pRect->getRadiusY().getAbsoluteValue() + pRect->getRadiusY().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight();
512 
513  QSharedPointer<QPainterPath> path = QSharedPointer<QPainterPath>(new QPainterPath());
514 
515  path->addRoundedRect(x, y, w, h, rx, ry);
516 
517  return path;
518 }
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
const CLRelAbsVector & getRadiusY() const
const CLRelAbsVector & getWidth() const
double getRelativeValue() const
const CLRelAbsVector & getX() const
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
const CLRelAbsVector & getY() const
const CLRelAbsVector & getRadiusX() const
const CLRelAbsVector & getHeight() const
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
const CLPoint & getPosition() const
Definition: CLBase.h:265
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
double getAbsoluteValue() const
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
QSharedPointer<QPainterPath> getPath ( const CLEllipse pEllipse,
const CLBoundingBox pBB 
)

Definition at line 520 of file CQRenderConverter.cpp.

References CLRelAbsVector::getAbsoluteValue(), CLEllipse::getCX(), CLEllipse::getCY(), CLBoundingBox::getDimensions(), CLDimensions::getHeight(), CLBoundingBox::getPosition(), CLRelAbsVector::getRelativeValue(), CLEllipse::getRX(), CLEllipse::getRY(), CLDimensions::getWidth(), CLPoint::getX(), and CLPoint::getY().

521 {
522 
523  double x = pBB->getPosition().getX() + pEllipse->getCX().getAbsoluteValue() + pEllipse->getCX().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth();
524  double y = pBB->getPosition().getY() + pEllipse->getCY().getAbsoluteValue() + pEllipse->getCY().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight();
525  double rx = pEllipse->getRX().getAbsoluteValue() + pEllipse->getRX().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth();
526  double ry = pEllipse->getRY().getAbsoluteValue() + pEllipse->getRY().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight();
527 
528  QSharedPointer<QPainterPath> path = QSharedPointer<QPainterPath>(new QPainterPath());
529 
530  path->addEllipse(x - rx, y - ry, 2 * rx, 2 * ry);
531 
532  return path;
533 }
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
double getRelativeValue() const
const CLRelAbsVector & getRX() const
Definition: CLEllipse.cpp:151
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
const CLRelAbsVector & getCY() const
Definition: CLEllipse.cpp:135
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
const CLPoint & getPosition() const
Definition: CLBase.h:265
const CLRelAbsVector & getRY() const
Definition: CLEllipse.cpp:159
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
double getAbsoluteValue() const
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
const CLRelAbsVector & getCX() const
Definition: CLEllipse.cpp:127
QSharedPointer<QPainterPath> getPath ( const CLRenderCurve pCurve,
const CLBoundingBox pBB 
)

Definition at line 535 of file CQRenderConverter.cpp.

References addToPath(), CLRenderCurve::getListOfCurveElements(), and moveToPoint().

536 {
537  QSharedPointer<QPainterPath> path = QSharedPointer<QPainterPath>(new QPainterPath());
538 
539  const std::vector<CLRenderPoint*>& elements = *pCurve->getListOfCurveElements();
540  std::vector<CLRenderPoint*>::const_iterator it = elements.begin();
541  bool first = true;
542 
543  for (; it != elements.end(); ++it)
544  {
545  const CLRenderPoint* current = *it;
546  const CLRenderCubicBezier* cubic = dynamic_cast<const CLRenderCubicBezier*>(current);
547 
548  if (first)
549  {
550  moveToPoint(*path, current, pBB);
551  first = false;
552  continue;
553  }
554 
555  if (cubic != NULL)
556  {
557  addToPath(*path, cubic, pBB);
558  }
559  else
560  {
561  addToPath(*path, current, pBB);
562  }
563  }
564 
565  return path;
566 }
void moveToPoint(QPainterPath &path, const CLRenderPoint *current, const CLBoundingBox *pBB)
void addToPath(QPainterPath &path, const CLRenderCubicBezier *cubic, const CLBoundingBox *pBB)
const std::vector< CLRenderPoint * > * getListOfCurveElements() const
QSharedPointer<QPen> getPen ( const CLGraphicalPrimitive1D item,
const CLGroup group,
const CLRenderResolver resolver,
const CLBoundingBox  
)

Definition at line 302 of file CQRenderConverter.cpp.

References getColor(), CLGraphicalPrimitive1D::getDashArray(), CLGraphicalPrimitive1D::getStroke(), CLGraphicalPrimitive1D::getStrokeWidth(), CLGraphicalPrimitive1D::isSetDashArray(), CLGraphicalPrimitive1D::isSetStroke(), and CLGraphicalPrimitive1D::isSetStrokeWidth().

Referenced by addLineEndingToItem(), CQRenderConverter::applyStyle(), fillItemFromCurve(), fillItemFromEllipse(), fillItemFromPolygon(), fillItemFromRectangle(), and fillItemFromRenderCurve().

303 {
304  QColor color; double width;
305 
306  if (item != NULL && item->isSetStroke())
307  {
308  color = getColor(item->getStroke(), resolver);
309  }
310  else if (group != NULL && group->isSetStroke())
311  {
312  color = getColor(group->getStroke(), resolver);
313  }
314  else return QSharedPointer<QPen>(new QPen(Qt::transparent));
315 
316  if (item != NULL && item->isSetStrokeWidth())
317  {
318  width = item->getStrokeWidth();
319  }
320  else if (group != NULL && group->isSetStrokeWidth())
321  {
322  width = group->getStrokeWidth();
323  }
324  else return QSharedPointer<QPen>(new QPen(Qt::transparent));
325 
326  QSharedPointer<QPen> result = QSharedPointer<QPen>(new QPen(color, width));
327  result->setCapStyle(Qt::RoundCap);
328  result->setJoinStyle(Qt::RoundJoin);
329 
330  if (item != NULL && item->isSetDashArray())
331  {
332  const std::vector<unsigned int>& raw = item->getDashArray();
333  std::vector<unsigned int>::const_iterator start = raw.begin();
334  QVector<qreal> pattern;
335 
336  while (start != raw.end())
337  {
338  pattern << *start;
339  ++start;
340  }
341 
342  result->setDashPattern(pattern);
343  }
344  else if (group != NULL && group->isSetDashArray())
345  {
346  const std::vector<unsigned int>& raw = group->getDashArray();
347  std::vector<unsigned int>::const_iterator start = raw.begin();
348  QVector<qreal> pattern;
349 
350  while (start != raw.end())
351  {
352  pattern << *start;
353  ++start;
354  }
355 
356  result->setDashPattern(pattern);
357  }
358 
359  return result;
360 }
const std::string & getStroke() const
QColor getColor(const CLColorDefinition *cd)
const std::vector< unsigned int > & getDashArray() const
QSharedPointer<QRadialGradient> getRadialGradient ( const CLRadialGradient radial,
const CLBoundingBox bounds,
const CLRenderResolver resolver 
)

Definition at line 141 of file CQRenderConverter.cpp.

References CLRelAbsVector::getAbsoluteValue(), CLRadialGradient::getCenterX(), CLRadialGradient::getCenterY(), getColor(), CLBoundingBox::getDimensions(), CLRadialGradient::getFocalPointX(), CLRadialGradient::getFocalPointY(), CLGradientBase::getGradientStop(), CLDimensions::getHeight(), CLGradientBase::getNumGradientStops(), CLGradientStop::getOffset(), CLBoundingBox::getPosition(), CLRadialGradient::getRadius(), CLRelAbsVector::getRelativeValue(), CLGradientBase::getSpreadMethod(), CLGradientStop::getStopColor(), CLDimensions::getWidth(), CLPoint::getX(), CLPoint::getY(), CLGradientBase::PAD, CLGradientBase::REFLECT, and CLGradientBase::REPEAT.

Referenced by getGradient().

142 {
143  double cx = bounds->getPosition().getX() + radial->getCenterX().getAbsoluteValue() + radial->getCenterX().getRelativeValue() / 100.0 * bounds->getDimensions().getWidth();
144  double cy = bounds->getPosition().getY() + radial->getCenterY().getAbsoluteValue() + radial->getCenterY().getRelativeValue() / 100.0 * bounds->getDimensions().getHeight();
145  double fx = bounds->getPosition().getX() + radial->getFocalPointX().getAbsoluteValue() + radial->getFocalPointX().getRelativeValue() / 100.0 * bounds->getDimensions().getWidth();
146  double fy = bounds->getPosition().getY() + radial->getFocalPointY().getAbsoluteValue() + radial->getFocalPointY().getRelativeValue() / 100.0 * bounds->getDimensions().getHeight();
147  double r = radial->getRadius().getAbsoluteValue() + radial->getRadius().getRelativeValue() / 100.0 * bounds->getDimensions().getWidth();
148 
149  QSharedPointer<QRadialGradient> result = QSharedPointer<QRadialGradient>(new QRadialGradient(cx, cy, r, fx, fy));
150 
151  switch (radial->getSpreadMethod())
152  {
154  result->setSpread(QGradient::ReflectSpread);
155  break;
156 
158  result->setSpread(QGradient::RepeatSpread);
159  break;
160 
161  case CLGradientBase::PAD:
162  result->setSpread(QGradient::PadSpread);
163  break;
164 
165  default:
166  break;
167  }
168 
169  for (size_t i = 0; i < radial->getNumGradientStops(); ++i)
170  {
171  const CLGradientStop* stop = radial->getGradientStop(i);
172  result->setColorAt(stop->getOffset().getAbsoluteValue() + stop->getOffset().getRelativeValue() / 100.0, getColor(stop->getStopColor(), resolver));
173  }
174 
175  return result;
176 }
const CLRelAbsVector & getRadius() const
const CLRelAbsVector & getCenterY() const
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
const CLRelAbsVector & getCenterX() const
double getRelativeValue() const
CLGradientStop * getGradientStop(size_t i)
size_t getNumGradientStops() const
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
const std::string & getStopColor() const
const CLRelAbsVector & getOffset() const
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
const CLRelAbsVector & getFocalPointY() const
const CLPoint & getPosition() const
Definition: CLBase.h:265
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
double getAbsoluteValue() const
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
QColor getColor(const CLColorDefinition *cd)
const CLRelAbsVector & getFocalPointX() const
SPREADMETHOD getSpreadMethod() const
void moveToPoint ( QPainterPath &  path,
const CLRenderPoint current,
const CLBoundingBox pBB 
)

Definition at line 460 of file CQRenderConverter.cpp.

References CLRelAbsVector::getAbsoluteValue(), CLBoundingBox::getDimensions(), CLDimensions::getHeight(), CLBoundingBox::getPosition(), CLRelAbsVector::getRelativeValue(), CLDimensions::getWidth(), CLPoint::getX(), CLRenderPoint::getXOffset(), CLPoint::getY(), and CLRenderPoint::getYOffset().

Referenced by getPath().

461 {
462  path.moveTo(
463  pBB->getPosition().getX() + current->getXOffset().getAbsoluteValue() + current->getXOffset().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth(),
464  pBB->getPosition().getY() + current->getYOffset().getAbsoluteValue() + current->getYOffset().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight()
465  );
466 }
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
double getRelativeValue() const
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
const CLPoint & getPosition() const
Definition: CLBase.h:265
const CLRelAbsVector & getXOffset() const
const CLRelAbsVector & getYOffset() const
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
double getAbsoluteValue() const
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
QPointF normalizePoint ( const QPointF &  vector)

Definition at line 568 of file CQRenderConverter.cpp.

Referenced by applyRotationalMapping().

569 {
570  qreal length = (qreal) sqrt(vector.x() * vector.x() + vector.y() * vector.y());
571 
572  if (length == 0) length = 1;
573 
574  return QPointF(vector.x() / length, vector.y() / length);
575 }
void transform ( QGraphicsItem *  item,
const CLTransformation2D trans,
const CLGroup group 
)

Definition at line 36 of file CQRenderConverter.cpp.

References CLTransformation2D::getMatrix2D(), and CLTransformation::isSetMatrix().

Referenced by CCellDesignerImporter::classToEnum(), CCellDesignerImporter::connectionPolicyToEnum(), CLSimpleImageTexturizer::create_texture_for_image(), CCellDesignerImporter::directionToEnum(), fillItemFromEllipse(), fillItemFromGroup(), fillItemFromImage(), fillItemFromPolygon(), fillItemFromRectangle(), fillItemFromRenderCurve(), fillItemFromText(), CCellDesignerImporter::modificationLinkTypeToEnum(), CCellDesignerImporter::modificationTypeToEnum(), CQQtImageTexturizer::operator()(), CCellDesignerImporter::paintSchemeToEnum(), CCellDesignerImporter::parseLine(), CCellDesignerImporter::parsePaint(), CCellDesignerImporter::parseProteins(), CCellDesignerImporter::positionToCompartmentToEnum(), CCellDesignerImporter::positionToEnum(), CCellDesignerImporter::reactionTypeToEnum(), and CCellDesignerImporter::speciesModificationTypeToEnum().

37 {
38  if (trans != NULL && trans->isSetMatrix())
39  {
40  QRectF pathRect = item->boundingRect();
41  QTransform transform(
42  trans->getMatrix2D()[0],
43  trans->getMatrix2D()[1],
44  trans->getMatrix2D()[2],
45  trans->getMatrix2D()[3],
46  trans->getMatrix2D()[4],
47  trans->getMatrix2D()[5]
48  );
49 
50  QTransform matrix;
51  matrix = matrix.translate(pathRect.x(), pathRect.y());
52  matrix = matrix.inverted();
53  matrix = matrix * transform;
54 
55  QTransform translate;
56  translate = translate.translate(pathRect.x(), pathRect.y());
57  matrix = matrix * translate;
58  item->setTransform(matrix, true);
59  }
60  else if (group != NULL && group->isSetMatrix())
61  {
62  QRectF pathRect = item->boundingRect();
63  QTransform transform(
64  group->getMatrix2D()[0],
65  group->getMatrix2D()[1],
66  group->getMatrix2D()[2],
67  group->getMatrix2D()[3],
68  group->getMatrix2D()[4],
69  group->getMatrix2D()[5]
70  );
71 
72  QTransform matrix;
73  matrix = matrix.translate(pathRect.x(), pathRect.y());
74  matrix = matrix.inverted();
75  matrix = matrix * transform;
76 
77  QTransform translate;
78  translate = translate.translate(pathRect.x(), pathRect.y());
79  matrix = matrix * translate;
80  item->setTransform(matrix, true);
81  }
82 }
void transform(QGraphicsItem *item, const CLTransformation2D *trans, const CLGroup *group)
const double * getMatrix2D() const
bool isSetMatrix() const