16 # define _USE_MATH_DEFINES
19 #include <QtCore/QCoreApplication>
20 #include <QtCore/QEvent>
21 #include <QtCore/QFileInfo>
22 #include <QtCore/QList>
23 #include <QtCore/QPoint>
24 #include <QtCore/QRect>
25 #include <QtCore/QSize>
26 #include <QtCore/QString>
27 #include <QtCore/QTimer>
29 #include <QtGui/QAction>
30 #include <QtGui/QBitmap>
31 #include <QtGui/QContextMenuEvent>
32 #include <QtGui/QFontDatabase>
33 #include <QtGui/QFontInfo>
34 #include <QtGui/QGraphicsScene>
35 #include <QtGui/QGraphicsTextItem>
36 #include <QtGui/QMenu>
37 #include <QtGui/QPainter>
38 #include <QtGui/QPixmap>
39 #include <QtGui/QProgressDialog>
40 #include <QtOpenGL/QGLFramebufferObject>
52 #if (defined WIN32 && !defined log2)
54 {
return log(__x) / M_LN2;}
96 1.0f, 0.0f, 0.0f, 0.0f
97 , 0.0f, -1.0f, 0.0f, 0.0f
98 , 0.0f, 0.0f, 1.0f, 0.0f
99 , 0.0f, 0.0f, 0.0f, 1.0f
104 -1.0f, 0.0f, 0.0f, 0.0f
105 , 0.0f, 1.0f, 0.0f, 0.0f
106 , 0.0f, 0.0f, 1.0f, 0.0f
107 , 0.0f, 0.0f, 0.0f, 1.0f
113 : QGLWidget(format, parent),
114 mIsInitialized(false)
125 delete[] it->second->textureData;
146 glBegin(GL_TRIANGLE_FAN);
147 glColor3fv(compartmentColor_080);
149 glColor3f(1.0f, 1.0f, 1.0f);
155 glColor3fv(compartmentColor_080);
159 glColor3fv(compartmentColor_080);
169 glDisable(GL_DEPTH_TEST);
170 glBegin(GL_LINE_STRIP);
177 glEnable(GL_DEPTH_TEST);
183 glTranslatef(0.0f, 0.5f, 0.0f);
194 glColor3f(1.0f, 1.0f, 1.0f);
205 glColor3f(1.0f, 1.0f, 1.0f);
212 glDisable(GL_DEPTH_TEST);
219 glEnable(GL_DEPTH_TEST);
225 glBegin(GL_TRIANGLE_FAN);
226 glColor3fv(speciesColor_080);
228 glColor3f(1.0f, 1.0f, 1.0f);
234 glColor3fv(speciesColor_080);
238 glColor3fv(speciesColor_080);
248 glDisable(GL_DEPTH_TEST);
249 glBegin(GL_LINE_STRIP);
256 glEnable(GL_DEPTH_TEST);
262 glTranslatef(0.0f, 0.5f, 0.0f);
273 glColor3f(1.0f, 1.0f, 1.0f);
284 glColor3f(1.0f, 1.0f, 1.0f);
291 glDisable(GL_DEPTH_TEST);
298 glEnable(GL_DEPTH_TEST);
312 glDisable(GL_DEPTH_TEST);
315 glBegin(GL_LINE_LOOP);
322 glEnable(GL_DEPTH_TEST);
354 glDisable(GL_DEPTH_TEST);
357 glBegin(GL_LINE_LOOP);
364 glEnable(GL_DEPTH_TEST);
371 glBegin(GL_TRIANGLE_FAN);
372 glVertex3f(0.0f, 0.4f, 0.0f);
373 glVertex3f(0.0f, 0.5f, 0.0f);
374 glVertex3f(0.05f, 0.4866f, 0.0f);
375 glVertex3f(0.0866f, 0.45f, 0.0f);
376 glVertex3f(0.1f, 0.4f, 0.0f);
379 glVertex3f(0.0f, 0.4f, 0.0f);
380 glVertex3f(0.1f, 0.4f, 0.0f);
381 glVertex3f(0.1f, 0.0f, 0.0f);
382 glVertex3f(0.0f, 0.0f, 0.0f);
388 glTranslatef(0.0f, 0.5f, 0.0f);
399 glVertex3f(0.0f, 1.0f, 0.0f);
400 glVertex3f(1.0f, 1.0f, 0.0f);
401 glVertex3f(1.0f, 0.0f, 0.0f);
402 glVertex3f(0.0f, 0.0f, 0.0f);
408 float lowerBound = 0.5;
410 glBegin(GL_TRIANGLE_FAN);
424 glDisable(GL_DEPTH_TEST);
426 glBegin(GL_LINE_LOOP);
435 glEnable(GL_DEPTH_TEST);
442 glBegin(GL_TRIANGLE_FAN);
456 glDisable(GL_DEPTH_TEST);
458 glBegin(GL_LINE_LOOP);
467 glEnable(GL_DEPTH_TEST);
474 glBegin(GL_TRIANGLE_FAN);
488 glDisable(GL_DEPTH_TEST);
490 glBegin(GL_LINE_LOOP);
499 glEnable(GL_DEPTH_TEST);
505 glBegin(GL_TRIANGLE_FAN);
507 glVertex3f(0.0f, 0.0f, 0.0f);
511 glVertex3f(it->first, it->second, 0.0f);
521 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
522 glEnable(GL_DEPTH_TEST);
524 glEnable(GL_LINE_SMOOTH);
525 glEnable(GL_ALPHA_TEST);
528 glShadeModel(GL_SMOOTH);
538 glViewport(0, 0, (GLint)w, (GLint)h);
540 glMatrixMode(GL_PROJECTION);
546 glMatrixMode(GL_MODELVIEW);
551 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
595 int numberOfInvertedCurves = 0;
601 for (i = 0; i < compartmentNodes.
size(); i++)
603 std::string nKey = (*compartmentNodes[i]).getKey();
604 std::string oKey = (*compartmentNodes[i]).getModelObjectKey();
609 keyMap.insert(std::pair<std::string, std::string>
617 for (i = 0; i < nodes.
size(); i++)
619 std::string nKey = (*nodes[i]).getKey();
620 std::string oKey = (*nodes[i]).getModelObjectKey();
622 nodeMap.insert(std::pair<std::string, CGraphNode>
625 keyMap.insert(std::pair<std::string, std::string>
636 for (i = 0; i < reactions.
size(); i++)
642 edgesToNodesOfReaction = reactions[i]->getListOfMetabReferenceGlyphs();
645 for (j2 = 0; j2 < edgesToNodesOfReaction.
size(); j2++)
648 std::string nodeKey =
"";
650 if (edgesToNodesOfReaction[j2]->getMetabGlyph() != NULL)
652 nodeKey = std::string(edgesToNodesOfReaction[j2]->getMetabGlyph()->getKey());
653 std::map<std::string, CGraphNode>::iterator itNode;
654 itNode =
nodeMap.find(nodeKey);
661 numberOfInvertedCurves++;
668 if (edgesToNodesOfReaction[j2]->getMetabGlyph() != NULL)
676 if (! segments.empty())
683 lastSeg = segments[0];
764 std::map<std::string, CGraphNode>::iterator itNode;
766 for (i = 0; i < labels.
size(); i++)
769 (labels[i]->getKey(),
770 labels[i]->getGraphicalObjectKey()));
771 std::string s1 = labels[i]->
getKey();
772 std::string s2 = labels[i]->getGraphicalObjectKey();
774 itNode =
nodeMap.find(labels[i]->getGraphicalObjectKey());
778 (*itNode).second.setLabelText(labels[i]->getText());
790 bool inverted =
false;
799 if (points.size() > 1)
803 CLPoint e = points[points.size() - 1];
826 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
837 std::map<std::string, CCompartmentGraphNode>::iterator itCompartmentNode;
838 std::map<std::string, CGraphNode>::iterator itNode;
839 std::multimap<std::string, CGraphCurve>::iterator itCurve;
840 std::multimap<std::string, CArrow>::iterator itArrow;
841 std::pair<std::multimap<std::string, CGraphCurve>::iterator, std::multimap<std::string, CGraphCurve>::iterator> curveRangeIt;;
842 std::pair<std::multimap<std::string, CArrow>::iterator, std::multimap<std::string, CArrow>::iterator> arrowRangeIt;
851 drawNode((*itCompartmentNode).second);
860 itCurve = curveRangeIt.first;
863 while (itCurve != curveRangeIt.second)
889 const QFont& mfRef = this->
mf;
890 QFontInfo fontInfo = QFontInfo(mfRef);
913 const std::string& nodeKey =
viewerLabels[i].getGraphicalObjectKey();
915 if (!nodeKey.empty())
917 std::map<std::string, CGraphNode>::iterator itNodeObj;
918 itNodeObj =
nodeMap.find(nodeKey);
920 if (itNodeObj !=
nodeMap.end())
921 nDiam = (*itNodeObj).second.getSize();
923 C_INT32 xNdCenter = (
C_INT32)((*itNodeObj).second.getX() + ((*itNodeObj).second.getWidth() / 2.0));
924 C_INT32 yNdCenter = (
C_INT32)(*itNodeObj).second.getY() + ((*itNodeObj).second.getHeight() / 2.0);
931 else if ((tWid + 4) > nDiam)
934 x = xNdCenter + (nDiam / 2.0) + 2.0 - ((
viewerLabels[i].getWidth() - tWid) / 2.0);
935 y = yNdCenter + (nDiam / 2.0) + 2.0 - ((
viewerLabels[i].getHeight()) / 2.0);
970 QColor col = QColor();
973 double ratio = 455 / 120;
976 for (i = 0; i <= w; i++)
982 col.setRgb(0, 0, (
int)val);
984 else if (val < 400.0)
986 col.setRgb(0, (
int)(val - 200.0), 200);
990 col.setRgb(0, 200 + (
int)(val - 400.0), 200 + (
int)(val - 400.0));
993 QGLWidget::qglColor(col);
996 glVertex2d(i + sx, sy);
997 glVertex2d(i + sx, sy + h);
1009 float translateX = 0.0f;
1010 float scaledWidth = width - (0.2f * height);
1024 glTranslatef(translateX + height * 0.1, y, 0.0f);
1025 glScalef(height, height, 1.0f);
1032 translateX += 0.1 * height;
1033 glTranslatef(translateX, y, 0.0f);
1035 glScalef(scaledWidth, height, 1.0f);
1040 translateX += scaledWidth;
1041 glTranslatef(translateX, y, 0.0f);
1042 glScalef(height, height, 1.0f);
1056 glTranslatef(translateX + height * 0.1, y, 0.0f);
1057 glScalef(height, height, 1.0f);
1064 translateX += 0.1 * height;
1065 glTranslatef(translateX, y, 0.0f);
1067 glScalef(scaledWidth, height, 1.0f);
1071 translateX += scaledWidth;
1072 glTranslatef(translateX, y, 0.0f);
1073 glScalef(height, height, 1.0f);
1117 glScalef(scaledValue, scaledValue, 1.0f);
1123 glTranslatef(tx, ty, 0.0f);
1124 glScalef(scaledValue, scaledValue, 1.0f);
1136 glScalef(scaledValue, scaledValue, 1.0f);
1142 glTranslatef(tx, ty, 0.0f);
1143 glScalef(scaledValue, scaledValue, 1.0f);
1156 glScalef(scaledValue, scaledValue, 1.0f);
1162 glTranslatef(tx, ty, 0.0f);
1163 glScalef(scaledValue, scaledValue, 1.0f);
1172 GLfloat color[3] = {1.0f, 1.0f, 1.0f};
1178 float v = (float)n.
getSize() * 455.0f;
1184 color[2] = v / 255.0f;
1189 color[1] = (v - 200.0f) / 255.0f;
1190 color[2] = 200.0f / 255.0f;
1195 color[1] = (200.0f + (v - 400.0f)) / 255.0f;
1196 color[2] = (200.0f + (v - 400.0f)) / 255.0f;
1221 glScalef(scaledValue, scaledValue, 1.0f);
1229 glTranslatef((
float)tx, (
float)ty, 0.0f);
1230 glScalef(scaledValue, scaledValue, 1.0f);
1231 float lowerBound = 0.5;
1233 glBegin(GL_TRIANGLE_FAN);
1237 glColor4f(color[0]*lowerBound, color[1]*lowerBound, color[2]*lowerBound, 1.0f);
1247 glDisable(GL_DEPTH_TEST);
1249 glBegin(GL_LINE_LOOP);
1267 float scaledWidth = width - (0.2f * height);
1268 float translateX = 0.0f;
1283 glTranslatef(translateX + height * 0.1, y, 0.0f);
1284 glScalef(height, height, 1.0f);
1291 translateX += 0.1 * height;
1292 glTranslatef(translateX, y, 0.0f);
1294 glScalef(scaledWidth, height, 1.0f);
1299 translateX += scaledWidth;
1300 glTranslatef(translateX, y, 0.0f);
1301 glScalef(height, height, 1.0f);
1315 glTranslatef(translateX + height * 0.1, y, 0.0f);
1316 glScalef(height, height, 1.0f);
1323 translateX += 0.1 * height;
1324 glTranslatef(translateX, y, 0.0f);
1326 glScalef(scaledWidth, height, 1.0f);
1330 translateX += scaledWidth;
1331 glTranslatef(translateX, y, 0.0f);
1332 glScalef(height, height, 1.0f);
1349 glDisable(GL_DEPTH_TEST);
1367 GLfloat controlPts[4][3] =
1375 glMap1f(GL_MAP1_VERTEX_3, 0.0f, 20.0f, 3, 4, &controlPts[0][0]);
1376 glEnable(GL_MAP1_VERTEX_3);
1377 glBegin(GL_LINE_STRIP);
1379 for (i = 0; i <= 20; ++i)
1382 glEvalCoord1f((GLfloat)i);
1386 glDisable(GL_MAP1_VERTEX_3);
1391 glBegin(GL_LINE_STRIP);
1405 glEnable(GL_DEPTH_TEST);
1410 double deltaX = endPoint.
getX() - startPoint.
getX();
1411 double deltaY = endPoint.
getY() - startPoint.
getY();
1418 return std::numeric_limits<double>::quiet_NaN();
1427 else if (deltaX == 0.0)
1431 return std::numeric_limits<double>::quiet_NaN();
1446 double slope = deltaY / deltaX;
1447 angle = 180.0 * atan(slope) / M_PI;
1519 glTranslatef(p1.
getX(), p1.
getY(), 0.0f);
1520 glRotatef(angle, 0.0f, 0.0f, 1.0f);
1521 glScalef(3.0f, 3.0f, 1.0f);
1528 glTranslatef(p2.
getX(), p2.
getY(), 0.0f);
1529 glRotatef(angle, 0.0f, 0.0f, 1.0f);
1530 glScalef(3.0f, 3.0f, 1.0f);
1535 glTranslatef(p2.
getX(), p2.
getY(), 0.0f);
1536 glRotatef(angle, 0.0f, 0.0f, 1.0f);
1537 glScalef(3.0f, 3.0f, 1.0f);
1542 glTranslatef(p2.
getX(), p2.
getY(), 0.0f);
1543 glRotatef(angle, 0.0f, 0.0f, 1.0f);
1544 glScalef(3.0f, 3.0f, 1.0f);
1560 if (texSpec == NULL)
1567 glEnable(GL_TEXTURE_2D);
1568 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1570 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
1571 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
1572 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1573 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1574 glTexImage2D(GL_TEXTURE_2D, 0, GL_INTENSITY8, static_cast<int>(texSpec->
textureWidth), static_cast<int>(texSpec->
textureHeight), 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, texSpec->
textureData);
1575 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1576 glTranslated(x, y, 0.5);
1578 double xOffset = (w - texSpec->
textWidth + 2) / 2.0;
1580 xOffset = (xOffset < 0.0) ? 0.0 : xOffset;
1581 yOffset = (yOffset < 0.0) ? 0.0 : yOffset;
1582 double textureXRatio = ((texSpec->
textWidth + 2) / texSpec->
textureWidth) / ((w - xOffset) / w) * 1.02;
1585 glBegin(GL_POLYGON);
1587 glVertex3f(0.0, 0.0, 0.0);
1589 glTexCoord2f(textureXRatio, -yOffset / texSpec->
textureHeight);
1590 glVertex3f(w, 0.0, 0.0);
1592 glTexCoord2f(textureXRatio, textureYRatio);
1593 glVertex3f(w, h, 0.0);
1595 glTexCoord2f(-xOffset / texSpec->
textureWidth, textureYRatio);
1596 glVertex3f(0.0, h, 0.0);
1599 glDisable(GL_TEXTURE_2D);
1605 QFont font(QString(fontName.c_str()), fontSize);
1606 QFontMetrics fontMetrics = QFontMetrics(font);
1608 QRect rect = fontMetrics.boundingRect(QString(text.c_str()));
1609 int width = rect.width();
1616 int exponent =
static_cast<int>(ceil(log2(width + 2.0)));
1623 width =
static_cast<int>(pow(2.0, exponent + 1));
1633 delete[] it->second->textureData;
1653 std::map<std::string, RGTextureSpec*>::iterator it;
1659 texSpec = ((*it).second);
1664 labelTextureMap.insert(std::pair<std::string, RGTextureSpec*>(text, texSpec));
1672 QFont font(QString(fontName.c_str()), fontSize);
1673 QFontMetrics fontMetrics = QFontMetrics(font);
1675 QRect rect = fontMetrics.boundingRect(QString(text.c_str()));
1676 int width = rect.width();
1677 int height = rect.height();
1678 int exponent =
static_cast<int>(ceil(log2(width + 2.0)));
1685 width =
static_cast<int>(pow(2.0, exponent + 1));
1686 exponent =
static_cast<int>(ceil(log2(height + 2.0)));
1693 height =
static_cast<int>(pow(2.0, exponent + 1));
1695 QPixmap pixmap(width, height);
1696 pixmap.fill(QColor(255, 255, 255));
1697 QGraphicsScene scene(0.0, 0.0, width, height);
1698 QGraphicsTextItem* pTextItem = scene.addText(QString(text.c_str()), font);
1699 pTextItem->setDefaultTextColor(QColor(0, 0, 0));
1702 pTextItem->moveBy(1.0, 1.0);
1703 QPainter painter(&pixmap);
1704 scene.render(&painter);
1707 texture->
textureData =
new GLubyte[height * width];
1712 QImage image = pixmap.toImage();
1717 int firstWhitePixel = height;
1721 for (i = 0; i < height; ++i)
1723 for (j = 0; j < width; ++j)
1725 pixel = image.pixel(j, i);
1726 pixelValue =
static_cast<unsigned char>(255 - (qRed(pixel) + qGreen(pixel) + qBlue(pixel)) / 3);
1729 if (pixelValue != 0)
1731 if (firstWhitePixel == height)
1733 firstWhitePixel = i;
1751 QFontMetrics mfm = QFontMetrics(
mf);
1752 QRect bbox = mfm.boundingRect(
FROM_UTF8(s));
1763 const QFont& mfRef =
mf;
1764 QFontMetrics mfm = QFontMetrics(mfRef);
1770 QRect c(0, 0, w2, h2);
1775 QPainter painter2(&pm);
1776 painter2.setPen(Qt::black);
1777 painter2.setFont(
mf);
1778 painter2.drawText(c, Qt::AlignCenter,
FROM_UTF8(s));
1781 QImage img = pm.toImage();
1782 QImage timg = QGLWidget::convertToGLFormat(img);
1784 glTexImage2D(GL_TEXTURE_2D, 0, 3, timg.width(), timg.height(), 0,
1785 GL_RGBA, GL_UNSIGNED_BYTE, timg.bits());
1786 double xoff = (w - w2) / 2.0;
1787 double yoff = (h - h2) / 2.0;
1792 glRasterPos2f(x + xoff, y + h - yoff);
1793 glDrawPixels(w2, h2, GL_RGBA, GL_UNSIGNED_BYTE, timg.bits());
1798 int n = (int)(ceil(d));
1802 while ((p <= maxP) && (n > pow(2.0, p)))
1805 return (
int)pow(2.0, p);
1862 val_new = newMin + ((val_orig - a) / (b - a) * (newMax - newMin));
1867 val_new = (newMax + newMin) / 2.0;
1926 val_new = newMin + ((val_orig - a) / (b - a) * (newMax - newMin));
1931 val_new = (newMax + newMin) / 2.0;
2013 (maxNodeSize - minNodeSize) /
2019 val_new = (maxNodeSize + minNodeSize) / 2.0;
2035 (maxNodeSize - minNodeSize) /
2040 val_new = (maxNodeSize + minNodeSize) / 2.0;
2053 bool loadDataSuccessful =
false;
2068 assert(pDataModel != NULL);
2069 std::vector<CCopasiContainer*> tmpV;
2070 dummyTimeSeries.
compile(tmpV, pDataModel);
2073 pTimeSer = &dummyTimeSeries;
2097 objKey = pTimeSer->
getKey(i);
2098 std::map<std::string, std::string>::iterator iter =
keyMap.find(objKey);
2100 if (iter !=
keyMap.end())
2103 ndKey = (
keyMap.find(objKey))->second;
2142 objKey = pTimeSer->
getKey(i);
2143 std::map<std::string, std::string>::iterator iter =
keyMap.find(objKey);
2145 if (iter !=
keyMap.end())
2148 ndKey = (
keyMap.find(objKey))->second;
2166 scaledVal = minNodeSize +
2167 (((maxNodeSize - minNodeSize) / (maxR - minR))
2170 scaledVal = (maxNodeSize + minNodeSize) / 2.0;
2183 loadDataSuccessful =
true;
2192 if (loadDataSuccessful)
2201 return loadDataSuccessful;
2239 size_t numberOfSteps = 100;
2240 bool animationRunning =
true;
2309 val = (val - a) / (b - a);
2326 std::map<std::string, CGraphNode>::iterator itNodeObj =
nodeMap.find(
viewerNodes[i]);
2328 if (itNodeObj !=
nodeMap.end())
2376 std::map<std::string, CGraphNode>::iterator nodeIt;
2380 (*nodeIt).second.setSize(val);
2388 std::map<std::string, CGraphNode>::iterator nodeIt;
2392 (*nodeIt).second.setSize(val);
2395 std::pair<std::multimap<std::string, CGraphCurve>::iterator, std::multimap<std::string, CGraphCurve>::iterator> curveRangeIt;;
2397 std::multimap<std::string, CGraphCurve>::iterator curveIt;
2398 curveIt = curveRangeIt.first;
2400 while (curveIt != curveRangeIt.second)
2436 CLPoint from =
CLPoint((*nodeIt).second.getX() + ((*nodeIt).second.getWidth() / 2.0), (*nodeIt).second.getY() + ((*nodeIt).second.getHeight() / 2.0));
2439 C_FLOAT64 circleDist = ((*nodeIt).second.getSize() / 2.0) + 4.0;
2466 std::pair<std::multimap<std::string, CGraphCurve>::iterator, std::multimap<std::string, CGraphCurve>::iterator> rangeCurveIt;
2467 std::multimap<std::string, CGraphCurve>::iterator curveIt;
2477 curveIt = rangeCurveIt.first;
2479 while (curveIt != rangeCurveIt.second)
2502 if (fabs(pAngle) < fabs(qAngle))
2527 std::pair<std::multimap<std::string, CGraphCurve>::iterator, std::multimap<std::string, CGraphCurve>::iterator> rangeCurveIt;
2528 std::multimap<std::string, CGraphCurve>::iterator curveIt;
2538 curveIt = rangeCurveIt.first;
2540 while (curveIt != rangeCurveIt.second)
2563 return CLPoint(onPointX, onPointY);
2578 return CLPoint(onPointX, onPointY);
2584 CLLineSegment* pLastSeg = (*it).second.getSegmentAt((*it).second.getNumCurveSegments() - 1);
2592 pLastSeg->
setEnd(pointOnCircle);
2595 if (((*it).second).hasArrowP())
2628 ((*it).first, *ar));
2629 ((*it).second).setArrowP(
true);
2630 ((*it).second).setArrow(*ar);
2638 CLLineSegment* pLastSeg = (*it).second.getSegmentAt((*it).second.getNumCurveSegments() - 1);
2646 pLastSeg->
setEnd(pointOnRect);
2651 if (((*it).second).hasArrowP())
2683 ((*it).first, *ar));
2684 ((*it).second).setArrowP(
true);
2685 ((*it).second).setArrow(*ar);
2726 this->
zoom(zoomFactor);
2751 std::map<std::string, CGraphNode>::iterator nodeIt;
2767 std::pair<std::multimap<std::string, CGraphCurve>::iterator, std::multimap<std::string, CGraphCurve>::iterator> curveRangeIt;
2768 std::multimap<std::string, CGraphCurve>::iterator curveIt;
2771 curveIt = curveRangeIt.first;
2773 while (curveIt != curveRangeIt.second)
2775 ((*curveIt).second).scale(zoomFactor);
2806 std::pair<std::multimap<std::string, CArrow>::iterator, std::multimap<std::string, CArrow>::iterator> arrowRangeIt;
2807 std::multimap<std::string, CArrow>::iterator arrowIt;
2809 arrowIt = arrowRangeIt.first;
2811 while (arrowIt != arrowRangeIt.second)
2813 (*arrowIt).second.scale(zoomFactor);
2842 return this->grabFrameBuffer();
2847 QMenu *pContextMenu =
new QMenu();
2851 pContextMenu->popup(cme->globalPos());
2852 delete pContextMenu;
2858 glTranslatef(10.0f, 10.0f, -1.0f);
2859 glBegin(GL_TRIANGLES);
2860 glColor3f(0.0f, 0.0f, 1.0f);
2861 glVertex3f(0.0f, 10.0f, 0.0f);
2862 glVertex3f(-10.0f, -10.0f, 0.0f);
2863 glVertex3f(10.0f, -10.0f, 0.0f);
2866 glTranslatef(3.0f, 0.0f, 0.0f);
2868 glColor3f(1.0f, 0.0f, 0.0f);
2869 glVertex3f(-1.0f, 1.0f, 0.0f);
2870 glVertex3f(1.0f, 1.0f, 0.0f);
2871 glVertex3f(1.0f, -1.0f, 0.0f);
2872 glVertex3f(-1.0f, -1.0f, 0.0f);
2875 glTranslatef(3.5f, 0.0f, 0.0f);
2876 glBegin(GL_POLYGON);
2878 glColor3f(1.0f, 0.0f, 0.0f);
2879 glVertex3f(-0.5f, 1.5f, 0.0f);
2880 glVertex3f(0.5f, 1.5f, 0.0f);
2882 glColor3f(0.0f, 0.0f, 1.0f);
2883 glVertex3f(1.5f, 0.5f, 0.0f);
2884 glVertex3f(1.5f, -0.5f, 0.0f);
2886 glColor3f(0.0f, 1.0f, 0.0f);
2887 glVertex3f(0.5f, -1.5f, 0.0f);
2888 glVertex3f(-0.5f, -1.5f, 0.0f);
2890 glColor3f(1.0f, 1.0f, 0.0f);
2891 glVertex3f(-1.5f, -0.5f, 0.0f);
2892 glVertex3f(-1.5f, 0.5f, 0.0f);
2991 const QFont& mfRef =
mf;
2992 QFontMetrics mfm = QFontMetrics(mfRef);
2996 QWidget *ancestor = parent->parentWidget();
2998 while (ancestor && dynamic_cast<CQLayoutMainWindow*>(ancestor) == NULL)
3000 ancestor = ancestor->parentWidget();
3003 assert(ancestor != NULL);
3004 connect(
this, SIGNAL(
stepChanged(
int)), ancestor, SLOT(changeStepValue(
int)));
3023 std::map<std::string, CGraphNode>::iterator nodeIt;
3026 while (nodeIt !=
nodeMap.end())
3039 std::string s =
"UNKNOWN";
3040 std::map<std::string, CGraphNode>::iterator itNodeObj =
nodeMap.find(key);
3042 if (itNodeObj !=
nodeMap.end())
3043 s = (*itNodeObj).second.getLabelText();
3059 QStringList families = fdb.families();
3061 for (QStringList::Iterator f = families.begin(); f != families.end(); ++f)
3063 QString family = *f;
3064 QStringList styles = fdb.styles(family);
3066 for (QStringList::Iterator s = styles.begin(); s != styles.end(); ++s)
3069 QString dstyle =
"\t" + style +
" (";
3070 QList<int> smoothies = fdb.smoothSizes(family, style);
3072 for (QList<int>::iterator points = smoothies.begin();
3073 points != smoothies.end(); ++points)
3075 dstyle += QString::number(*points) +
" ";
3078 dstyle = dstyle.left(dstyle.length() - 1) +
")";
3089 if (this->isVisible())
3115 this->
resizeGL(this->width(), this->height());
3117 if (this->isVisible())
3168 double width = max.
getX() - min.
getX();
3169 double height = max.
getY() - min.
getY();
3171 glGetIntegerv(GL_VIEWPORT, vp);
3173 double wRatio = (vp[2] - vp[0]) / width;
3174 double hRatio = (vp[3] - vp[1]) / height;
3176 if (wRatio > hRatio)
3202 std::vector<std::pair<float, float> > result;
3206 for (i = 0; i <= n; ++i)
3208 angle = 2 * M_PI * i / n;
3209 result.push_back(std::pair<float, float>(cos(angle) * 0.5, sin(angle) * 0.5));
3237 bool CQGLNetworkPainter::export_bitmap(
double x,
double y,
double width,
double height,
unsigned int imageWidth,
unsigned int imageHeight,
const QString& filename,
const std::vector<size_t> frames)
3241 if (!filename.isEmpty() && !frames.empty())
3244 QCursor oldCursor = this->cursor();
3245 this->setCursor(Qt::WaitCursor);
3247 QProgressDialog* pProgress =
new QProgressDialog(
"image export",
"Cancel", 0, 100,
this);
3248 QImage* pImage = NULL;
3250 this->makeCurrent();
3252 const unsigned int tileSize = 128;
3253 unsigned int numColumns = imageWidth / tileSize;
3254 unsigned int numRows = imageHeight / tileSize;
3260 GLint oldViewport[4];
3261 bool frameSet =
false;
3264 glMatrixMode(GL_PROJECTION);
3266 glMatrixMode(GL_MODELVIEW);
3268 glGetIntegerv(GL_VIEWPORT, oldViewport);
3270 QGLFramebufferObject fbo(tileSize, tileSize, QGLFramebufferObject::CombinedDepthStencil);
3275 if (fbo.isValid() && fbo.isBound())
3279 pImage =
new QImage(imageWidth, imageHeight, QImage::Format_RGB888);
3287 if (pImage->isNull())
3299 glViewport(0, 0, (GLint)tileSize, (GLint)tileSize);
3301 std::vector<size_t>::const_iterator it = frames.begin(), endit = frames.end();
3327 pProgress->setMaximum(s.size());
3330 std::set<size_t>::const_iterator sit = s.begin(), sendit = s.end();
3331 unsigned int step = 0;
3333 while (sit != sendit)
3339 GLdouble xPos = (GLdouble)x, yPos = (GLdouble)y, w = (GLdouble)(width * (
double)tileSize / (double)imageWidth), h = (GLdouble)height * (
double)tileSize / (double)imageHeight;
3341 if (pProgress->wasCanceled())
3353 for (i = 0; i < numRows; ++i, yPos += h, xPos = (GLdouble)x)
3355 for (j = 0; j < numColumns; ++j)
3358 glMatrixMode(GL_PROJECTION);
3360 gluOrtho2D((GLdouble)xPos,
3361 (GLdouble)(xPos + w),
3362 (GLdouble)(yPos + h),
3364 glMatrixMode(GL_MODELVIEW);
3380 p.drawImage(QPoint(j * tileSize, i * tileSize), fbo.toImage());
3384 if (imageWidth % tileSize != 0)
3388 glMatrixMode(GL_PROJECTION);
3390 gluOrtho2D((GLdouble)xPos,
3391 (GLdouble)(xPos + w),
3392 (GLdouble)(yPos + h),
3394 glMatrixMode(GL_MODELVIEW);
3408 p.drawImage(QPoint(j * tileSize, i * tileSize), fbo.toImage(), QRect(QPoint(0, 0), QSize(imageWidth % tileSize, tileSize)));
3412 if ((imageHeight % tileSize) != 0)
3415 for (j = 0; j < numColumns; ++j, xPos += w)
3418 glMatrixMode(GL_PROJECTION);
3420 gluOrtho2D((GLdouble)xPos,
3421 (GLdouble)(xPos + w),
3422 (GLdouble)(yPos + h),
3424 glMatrixMode(GL_MODELVIEW);
3438 p.drawImage(QPoint(j * tileSize, i * tileSize), fbo.toImage(), QRect(QPoint(0, 0), QSize(tileSize, imageHeight % tileSize)));
3441 if (imageWidth % tileSize != 0)
3445 glMatrixMode(GL_PROJECTION);
3447 gluOrtho2D((GLdouble)xPos,
3448 (GLdouble)(xPos + w),
3449 (GLdouble)(yPos + h),
3451 glMatrixMode(GL_MODELVIEW);
3465 p.drawImage(QPoint(j * tileSize, i * tileSize), fbo.toImage(), QRect(QPoint(0, 0), QSize(imageWidth % tileSize, imageHeight % tileSize)));
3471 QString tmpfilename;
3473 if (frames.size() > 1)
3476 QFileInfo info(filename);
3477 QString completeBaseName = info.completeBaseName();
3478 QString suffix = info.suffix();
3479 QString path = info.path();
3480 assert(suffix ==
"png" || suffix ==
"PNG");
3482 tmpfilename.append(
"/");
3483 tmpfilename.append(completeBaseName);
3486 int length = ceil(log10((
C_FLOAT64) * s.rbegin()) + 1);
3487 tmpfilename.append(QString(
"%1").arg((uint)frame, (
int)length, (
int)10, QLatin1Char(
'0')));
3488 tmpfilename.append(
".");
3489 tmpfilename.append(suffix);
3493 tmpfilename = filename;
3497 pImage->save(tmpfilename,
"PNG");
3500 pProgress->setValue(step);
3501 QCoreApplication::processEvents();
3511 glViewport(oldViewport[0], oldViewport[1], oldViewport[2], oldViewport[3]);
3512 glMatrixMode(GL_MODELVIEW);
3514 glMatrixMode(GL_PROJECTION);
3517 if (oldStep != frame)
3519 this->setVisible(
false);
3521 this->setVisible(
true);
3522 this->
resizeGL(oldViewport[2], oldViewport[3]);
3526 this->
resizeGL(oldViewport[2], oldViewport[3]);
3542 this->setCursor(oldCursor);
const size_t & getRecordedSteps() const
C_FLOAT64 getConcentrationData(const size_t &step, const size_t &variable) const
bool mIsInitialized
flag that indicates whether OpenGL was initialized
void drawNode(CCompartmentGraphNode &n)
const CCopasiVector< CLTextGlyph > & getListOfTextGlyphs() const
const C_FLOAT64 & getWidth() const
void triggerAnimationStep()
CLPoint getPointOnRectangle(CLBoundingBox r, CLPoint p)
virtual bool compile(std::vector< CCopasiContainer * > listOfContainer, const CCopasiDataModel *pDataModel)
const size_t & getNumVariables() const
static const GLfloat MIRROR_X[16]
C_FLOAT64 mCurrentPositionY
int getLabelWindowWidth(int width)
static const float SPECIES_SHADOW_DEPTH
float mSpeciesShadowYOffset
static const GLfloat MIRROR_Y[16]
C_FLOAT64 getMinOverallConcentration()
std::vector< CDataEntity > mDataSets
void setX(const C_FLOAT64 &x)
C_FLOAT64 getMinNodeSize()
std::multimap< std::string, CArrow > nodeArrowMap
GLfloat mInanimatedSpeciesColor[4]
void setMaxNodeSize(C_FLOAT64 minNdSize)
CLMetabReferenceGlyph::Role getRole()
void storeMin(std::string ndKey, C_FLOAT64 minR)
virtual size_t size() const
void storeMax(std::string ndKey, C_FLOAT64 maxR)
std::map< std::string, RGTextureSpec * > labelTextureMap
std::vector< CGraphCurve > curvesWithArrow
void setCurrentPosition(C_FLOAT64 x, C_FLOAT64 y)
GLfloat mCompartmentColor[4]
const C_FLOAT64 & getX() const
unsigned int mNumCirclePoints
const std::vector< CLLineSegment > & getCurveSegments() const
const std::string & getTitle(const size_t &variable) const
std::vector< CGraphCurve > viewerCurves
C_FLOAT64 getMinForSpecies(std::string ndKey)
C_FLOAT64 getValueForSpecies(std::string nodeKey)
void allocate(const size_t &steps)
C_FLOAT64 getOrigValueForSpecies(std::string nodeKey)
CVisParameters::SCALING_MODE mScaleMode
std::vector< std::pair< float, float > > mCirclePoints
void setY(const C_FLOAT64 &y)
void setCurrentPositionY(C_FLOAT64 y)
std::set< std::string > setOfConstantMetabolites
bool getAnimationRunning()
CSimSummaryInfo * pSummaryInfo
static C_INT16 DEFAULT_NODE_SIZE
void setNodeSizeWithoutChangingCurves(std::string key, C_FLOAT64 val)
CQLayoutMainWindow * pParentLayoutWindow
CDataEntity * getDataSetAt(size_t stepNumber)
static const C_INT32 MIN_HEIGHT
C_FLOAT64 getMaxOverallConcentration()
void rescaleNode(std::string key, C_FLOAT64 newMin, C_FLOAT64 newMax, CVisParameters::SCALING_MODE scaleMode)
std::multimap< std::string, CGraphCurve > nodeCurveMap
size_t getCurrentStep() const
const CLPoint & getBase1() const
static const float COMPARTMENT_FRAME_DEPTH
void setConstantNodeSize(std::string key, C_FLOAT64 val)
const CCopasiVector< CLCompartmentGlyph > & getListOfCompartmentGlyphs() const
void insertValueTable(CDataEntity dataSet)
C_FLOAT64 getMaxForSpecies(std::string ndKey)
void printNodeInfoForKey(std::string key)
const std::string & getKey(const size_t &variable) const
const CLDimensions & getDimensions() const
virtual const std::string & getKey() const
static const float COMPARTMENT_SHADOW_DEPTH
static const C_FLOAT64 EPSILON
void mapLabelsToCircles()
void createGraph(CLayout *lP)
void initializeDisplayLists()
void setGraphSize(const CLPoint &min, const CLPoint &max)
const CLPoint & getBase2() const
bool checkCurve(CGraphCurve *curve, CGraphCurve curveR, CLBoundingBox box)
void rescaleDataSets(CVisParameters::SCALING_MODE scaleMode)
const CLPoint & getEnd() const
int getTextWidth(const std::string &text, const std::string &fontName, unsigned int fontSize)
void putOrigValueForSpecies(std::string nodeKey, C_FLOAT64 value)
std::map< std::string, std::string > labelNodeMap
std::map< std::string, CCompartmentGraphNode > compartmentNodeMap
void setCurrentPositionX(C_FLOAT64 x)
std::map< std::string, std::string > keyMap
const C_FLOAT64 & getX() const
const CLPoint & getPosition() const
void setAnimationRunning(bool animationRunningP)
size_t getNumberOfSteps() const
static double calculateAngle(const CLPoint &endPoint, const CLPoint &startPoint)
static const float SPECIES_FRAME_DEPTH
GLfloat mConstantSpeciesColor[4]
const CCopasiVector< CLMetabGlyph > & getListOfMetaboliteGlyphs() const
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
void printAvailableFonts()
std::string getOrigNodeKey()
RGTextureSpec * getTextureForText(const std::string &text, const std::string &fontName, unsigned int fontSize)
CVisParameters::SCALING_MODE getScalingMode()
void setMinNodeSize(C_FLOAT64 minNdSize)
void setScaleMode(CVisParameters::SCALING_MODE scaleMode)
shapeOfLabels mLabelShape
static const float SPECIES_DEPTH
GLfloat mAnimatedSpeciesColor[4]
std::vector< CLPoint > getListOfPoints() const
std::string getNameForNodeKey(std::string key)
C_INT32 getStepsPerSecond()
GLclampf mBackgroundColor[4]
const CTimeSeries & getTimeSeries() const
Header file of class BezierCurve.
RGTextureSpec * RG_createTextureForText(const std::string &text, const std::string &fontName, unsigned int fontSize)
CLPoint getPointOnCircle(CLBoundingBox r, CLPoint p)
C_FLOAT64 getCurrentPositionY() const
float mSpeciesShadowXOffset
const C_FLOAT64 & getWidth() const
float mCompartmentShadowYOffset
const C_FLOAT64 & getY() const
const C_FLOAT64 & getY() const
void endOfAnimationReached()
void setFontSizeForLabels(unsigned int fs)
void RG_drawStringAt(std::string s, C_INT32 x, C_INT32 y, C_INT32 w, C_INT32 h)
void putValueForSpecies(std::string nodeKey, C_FLOAT64 value)
void setNodeSize(std::string key, C_FLOAT64 val)
const C_FLOAT64 & getHeight() const
const CLLineSegment * getSegmentAt(size_t i) const
static const float SPECIESREFERENCE_DEPTH
void createTextureForAllLabels()
void adaptCurveForRectangles(std::multimap< std::string, CGraphCurve >::iterator it, CLBoundingBox box)
bool export_bitmap(double x, double y, double width, double height, unsigned int imageWidth, unsigned int imageHeight, const QString &filename, const std::vector< size_t > frames)
void rescaleDataSetsWithNewMinMax(C_FLOAT64 oldMin, C_FLOAT64 oldMax, C_FLOAT64 newMin, C_FLOAT64 newMax, CVisParameters::SCALING_MODE scaleMode)
const CLPoint & getGraphMax()
void setEnd(const CLPoint &p)
C_FLOAT64 mCurrentPositionX
void zoomGraph(C_FLOAT64 zoomFactor)
void setRole(CLMetabReferenceGlyph::Role r)
std::vector< std::string > viewerNodes
std::vector< std::string > viewerCompartmentNodes
void drawEdge(CGraphCurve &c)
float mCompartmentShadowXOffset
CQGLNetworkPainter(const QGLFormat &format, QWidget *parent=0)
std::string getNodeNameEntry(int i)
GLfloat mSpeciesReferenceColor[4]
C_FLOAT64 getCurrentPositionX() const
static const float COMPARTMENT_DEPTH
QAction * setFontSizeAction
C_FLOAT64 getZoomFactor() const
void zoom(double zoomFactor)
void resizeGL(int w, int h)
void contextMenuEvent(QContextMenuEvent *event)
C_FLOAT64 getMaxNodeSize()
void mapLabelsToRectangles()
void initializeGraphPainter(QWidget *viewportWidget)
void setZoomFactor(C_FLOAT64)
static std::vector< std::pair< float, float > > calculateCirclePoints(unsigned int n)
void setItemAnimated(std::string key, bool animatedP)
void drawArrow(CArrow a, CLMetabReferenceGlyph::Role role)
void invertOrderOfPoints()
bool preserveMinLabelHeightP
void drawStringAt(std::string s, C_FLOAT64 x, C_FLOAT64 y, C_FLOAT64 w, C_FLOAT64 h, QColor bgCol)
virtual void output(const Activity &activity)
const C_FLOAT64 & getHeight() const
size_t getNumCurveSegments() const
CVisParameters::MAPPING_MODE getMappingMode()
std::vector< CLabel > viewerLabels
const CLPoint & getGraphMin()
std::set< std::string > setOfDisabledMetabolites
const CCopasiVector< CLReactionGlyph > & getListOfReactionGlyphs() const
void setConstantNodeSizeForAllSteps(std::string key, C_FLOAT64 midValue)
std::map< std::string, CGraphNode > nodeMap
CLPoint getPointNearCircle(CLBoundingBox r, CLPoint p, C_INT16 d)
void setMaxOverallConcentration(C_FLOAT64 max)
const CLDimensions & getDimensions() const
const CLPoint & getStart() const
void adaptCurveForCircle(std::multimap< std::string, CGraphCurve >::iterator it, CLBoundingBox box)