/*************************************************************************** * Copyright (C) 2006-2007 by Rajko Albrecht * * ral@alwins-world.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "graphtreelabel.h" #include "graphtree_defines.h" #include GraphTreeLabel::GraphTreeLabel(const TQString&text, const TQString&_nodename,const TQRect&r,TQCanvas*c) : TQCanvasRectangle(r,c),StoredDrawParams() { m_Nodename = _nodename; m_SourceNode = TQString(); setText(0,text); setPosition(0, DrawParams::TopCenter); drawFrame(true); } GraphTreeLabel::~GraphTreeLabel() { } const TQString&GraphTreeLabel::nodename()const { return m_Nodename; } int GraphTreeLabel::rtti()const { return GRAPHTREE_LABEL; } void GraphTreeLabel::setBgColor(const TQColor&c) { _backColor=c; } void GraphTreeLabel::drawShape(TQPainter& p) { TQRect r = rect(); /* p.setPen(blue); p.drawRect(r); */ RectDrawing d(r); d.drawBack(&p,this); d.drawField(&p, 0, this); d.drawField(&p, 1, this); } void GraphTreeLabel::setSelected(bool s) { TQCanvasRectangle::setSelected(s); StoredDrawParams::setSelected(s); update(); } const TQString&GraphTreeLabel::source()const { return m_SourceNode; } void GraphTreeLabel::setSource(const TQString&_s) { m_SourceNode=_s; } GraphEdge::GraphEdge(TQCanvas*c) : TQCanvasSpline(c) { } GraphEdge::~GraphEdge() { } void GraphEdge::drawShape(TQPainter& p) { p.drawPolyline(poly); } TQPointArray GraphEdge::areaPoints() const { int minX = poly[0].x(), minY = poly[0].y(); int maxX = minX, maxY = minY; int i; if (0) tqDebug("GraphEdge::areaPoints\n P 0: %d/%d", minX, minY); int len = poly.count(); for (i=1;i maxX) maxX = poly[i].x(); if (poly[i].y() > maxY) maxY = poly[i].y(); if (0) tqDebug(" P %d: %d/%d", i, poly[i].x(), poly[i].y()); } TQPointArray a = poly.copy(), b = poly.copy(); if (minX == maxX) { a.translate(-2, 0); b.translate(2, 0); } else { a.translate(0, -2); b.translate(0, 2); } a.resize(2*len); for (i=0;iv2) { r.setRect(r.x()-d, r.y()-d, r.width()+2*d, r.height()+2*d); v /= f; } _p = new TQPixmap(r.size()); _p->fill(TQt::white); TQPainter p(_p); p.setPen(TQt::NoPen); r.moveBy(-r.x(), -r.y()); while (vwidth(), _p->height()); move(n->rect().center().x()-_p->width()/2, n->rect().center().y()-_p->height()/2); } GraphMark::~ GraphMark() { } bool GraphMark::hit(const TQPoint&)const { return false; } int GraphMark::rtti()const { return GRAPHTREE_MARK; } void GraphMark::drawShape(TQPainter&p) { p.drawPixmap( int(x()), int(y()), *_p ); }