File indexing completed on 2024-05-19 15:27:46

0001 /* This file is part of KGraphViewer.
0002    Copyright (C) 2005-2007 Gael de Chalendar <kleag@free.fr>
0003 
0004    KGraphViewer is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU General Public
0006    License as published by the Free Software Foundation, version 2.
0007 
0008    This program is distributed in the hope that it will be useful,
0009    but WITHOUT ANY WARRANTY; without even the implied warranty of
0010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011    General Public License for more details.
0012 
0013    You should have received a copy of the GNU General Public License
0014    along with this program; if not, write to the Free Software
0015    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0016    02110-1301, USA
0017 */
0018 
0019 /* This file was callgraphview.cpp, part of KCachegrind.
0020    Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
0021 
0022    KCachegrind is free software; you can redistribute it and/or
0023    modify it under the terms of the GNU General Public
0024    License as published by the Free Software Foundation, version 2.
0025 */
0026 
0027 /*
0028  * Callgraph View
0029  */
0030 
0031 #include "canvasnode.h"
0032 #include "FontsCache.h"
0033 #include "dot2qtconsts.h"
0034 #include "dotdefaults.h"
0035 #include "dotgraphview.h"
0036 #include "graphnode.h"
0037 #include "kgraphviewerlib_debug.h"
0038 
0039 #include <iostream>
0040 #include <math.h>
0041 #include <stdlib.h>
0042 
0043 #include <QDebug>
0044 #include <QGraphicsScene>
0045 #include <QPainter>
0046 #include <QPixmap>
0047 #include <QPolygonF>
0048 #include <QStyle>
0049 
0050 #include <klocalizedstring.h>
0051 
0052 namespace KGraphViewer
0053 {
0054 CanvasNode::CanvasNode(DotGraphView *v, GraphNode *s, QGraphicsScene *c, QGraphicsItem *parent)
0055     : CanvasElement(v, (GraphElement *)s, c, parent)
0056 
0057 {
0058     qCDebug(KGRAPHVIEWERLIB_LOG) << s->id();
0059     connect(s, &GraphNode::changed, this, &CanvasNode::modelChanged);
0060 
0061     QString tipStr;
0062     QString id = s->id();
0063     QString label = s->label();
0064     tipStr = i18n("id='%1'\nlabel='%2'", id, label);
0065     //   qCDebug(KGRAPHVIEWERLIB_LOG) << "CanvasEllipseNode setToolTip " << tipStr;
0066     setToolTip(tipStr);
0067 }
0068 
0069 // CanvasHtmlNode::CanvasHtmlNode(
0070 //                                           DotGraphView* v,
0071 //                                           GraphNode* n,
0072 //                                           const DotRenderOp& dro,
0073 //                                           const DotRenderOpVec& dros,
0074 //                                           QGraphicsScene* c,
0075 //                                           double scaleX, double scaleY,
0076 //                                           int xMargin, int yMargin, int gh,
0077 //                                           int wdhcf, int hdvcf
0078 //                                         )
0079 // : KHTMLPart(v->viewport()), CanvasNode(v, n)
0080 // {
0081 //   m_renderOperations = dros;
0082 // //   qCDebug(KGRAPHVIEWERLIB_LOG) << "Creating "<<node()->id()<<" CanvasHtmlNode for" << n
0083 // //     << " with label '" << n->label() << "'";
0084 //
0085 //   QString myHTMLCode = n->label();
0086 //   myHTMLCode = myHTMLCode.mid(1, myHTMLCode.length() - 2);
0087 // //   qCDebug(KGRAPHVIEWERLIB_LOG) << "HTML = " << myHTMLCode;
0088 //   begin(KUrl(QString("file:") + QDir::currentPath() + "/index.html"));
0089 //   setAutoloadImages(true);
0090 //   write(myHTMLCode);
0091 //   qCDebug(KGRAPHVIEWERLIB_LOG) << "HTML written.";
0092 //   end();
0093 //   setStatusMessagesEnabled (false);
0094 // //   view()->setFrameShape ( QFrame::NoFrame );
0095 // //   view()->setFrameShadow ( QFrame::Plain );
0096 // //   view()->setLineWidth ( 0 );
0097 // //   view()->setMidLineWidth ( 0 );
0098 // //   view()->setHScrollBarMode ( Q3ScrollView::AlwaysOff );
0099 // //   view()->setVScrollBarMode ( Q3ScrollView::AlwaysOff );
0100 //   view()->setMarginWidth(0);
0101 //   view()->setMarginHeight(0);
0102 //   m_zoomFactor = m_view->zoom();
0103 //   view()->part()->setZoomFactor(int(m_zoomFactor*100));
0104 //   view()->move(int(n->x()*scaleX*m_zoomFactor), int((gh-n->y())*scaleY*m_zoomFactor));
0105 //   view()->setMinimumSize(int(n->w()*scaleX),int(n->h()*scaleY*m_zoomFactor));
0106 //   view()->setMaximumSize(int(n->w()*scaleX),int(n->h()*scaleY*m_zoomFactor));
0107 //   view()->adjustSize();
0108 //   KHTMLPart::show();
0109 //   CanvasHtmlNode::connect(v, SIGNAL(contentsMoving(int,int)), this, SLOT(move(int,int)));
0110 //   CanvasHtmlNode::connect(v, SIGNAL(zoomed(double)), this, SLOT(zoomed(double)));
0111 // }
0112 //
0113 // CanvasHtmlNode::~CanvasHtmlNode()
0114 // {
0115 //   KHTMLPart::hide();
0116 // }
0117 //
0118 // // void CanvasHtmlNode::paint(QPainter& p)
0119 // // {
0120 // //   view()->drawContents(&p);
0121 // // }
0122 //
0123 // void CanvasHtmlNode::move(int x, int y)
0124 // {
0125 // //   qCDebug(KGRAPHVIEWERLIB_LOG) << "CanvasHtmlNode::move("<<x<<", "<<y<<")";
0126 //   m_xMovedTo = x; m_yMovedTo = y;
0127 //   view()->move(int((node()->x())*m_scaleX*m_zoomFactor - m_xMovedTo), int((m_gh-node()->y())*m_scaleY*m_zoomFactor) - m_yMovedTo);
0128 // //   view()->move(int(x*m_scaleX), int((m_gh-y)*m_scaleY));
0129 // }
0130 //
0131 // void CanvasHtmlNode::zoomed(double factor)
0132 // {
0133 //   m_zoomFactor = factor;
0134 //   view()->part()->setZoomFactor(int(factor*100));
0135 //   view()->move(int(node()->x()*m_scaleX*m_zoomFactor - m_xMovedTo), int((m_gh-node()->y())*m_scaleY*m_zoomFactor - m_yMovedTo));
0136 //   view()->setMinimumSize(int(node()->w()*m_scaleX*m_zoomFactor),int(node()->h()*m_scaleY*m_zoomFactor));
0137 //   view()->setMaximumSize(int(node()->w()*m_scaleX*m_zoomFactor),int(node()->h()*m_scaleY*m_zoomFactor));
0138 //   view()->adjustSize();
0139 // }
0140 
0141 }
0142 
0143 #include "moc_canvasnode.cpp"