# HG changeset patch # User insilmaril # Date 1113806268 0 # Node ID 598768200cfa4cb65971e2b810fedfa9a0e1ba5c # Parent f688a9913724df3138558299d687cc7dfe63e5ce Removed linkobj.* diff -r f688a9913724 -r 598768200cfa linkobj.cpp --- a/linkobj.cpp Mon Apr 18 06:17:00 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,215 +0,0 @@ -#include "linkobj.h" -#include "branchobj.h" - - -///////////////////////////////////////////////////////////////// -// LinkObj -///////////////////////////////////////////////////////////////// - -LinkObj::LinkObj ():MapObj() -{ - // cout << "Const LinkObj ()\n"; - init(); -} - -LinkObj::LinkObj (QCanvas* c):MapObj(c) -{ - // cout << "Const LinkObj (c) called from MapCenterObj (c)\n"; - init(); -} - - -LinkObj::~LinkObj () -{ - // cout << "Destr LinkObj\n"; - if (linkState!=undefinedLink) - deactivate(); - delete (line); -} - -void LinkObj::init () -{ - beginBranch=NULL; - endBranch=NULL; - visBranch=NULL; - linkState=undefinedLink; - - line=new QCanvasLine (canvas); - line->setPoints (0,0,200,200); - line->setPen (QPen(QColor(200,200,200), 1)); - - setVisibility (false); -} - -void LinkObj::copy (LinkObj* other) -{ - // FIXME copy not used yet - cout << "LO::copy called\n"; - MapObj::copy (other); - setVisibility (other->visible); - beginBranch=other->beginBranch; - endBranch=other->endBranch; -} - -void LinkObj::setBegin (BranchObj *bo) -{ - if (bo) - { - linkState=initLink; - beginBranch=bo; - beginPos=beginBranch->getChildPos(); - } -} - -void LinkObj::setEnd (BranchObj *bo) -{ - if (bo) - { - linkState=initLink; - endBranch=bo; - endPos=endBranch->getChildPos(); - } -} - -void LinkObj::setEnd (QPoint p) -{ - endPos=p; -} - -bool LinkObj::activate () -{ - if (beginBranch && endBranch) - { - linkState=activeLink; - beginBranch->addLink (this); - endBranch->addLink (this); - setVisibility (true); - return true; - } else - return false; -} - -void LinkObj::deactivate () -{ - if (beginBranch) - beginBranch->removeLinkRef (this); - beginBranch=NULL; - if (endBranch) - endBranch->removeLinkRef (this); - endBranch=NULL; - visBranch=NULL; - linkState=undefinedLink; - - line->hide(); -} - -bool LinkObj::isUsed() -{ - if (beginBranch || endBranch || linkState!=undefinedLink) - return true; - else - return false; -} - -void LinkObj::updateLink() -{ - QPoint a,b; - if (visBranch) - { - // Only one of the linked branches is visible - a=b=visBranch->getChildPos(); - if (visBranch->getOrientation()==OrientRightOfCenter) - b.setX (b.x()+25); - else - b.setX (b.x()-25); - } else - { - // Both linked branches are visible - if (beginBranch) - // If a link is just drawn in the editor, - // we have already a beginBranch - a=beginBranch->getChildPos(); - else - // This shouldn't be reached normally... - a=beginPos; - if (linkState==activeLink && endBranch) - b=endBranch->getChildPos(); - else - b=endPos; - } - - - if (line->startPoint()==a && line->endPoint()==b && !visBranch) - { - // update is called from both branches, so only - // update if needed - cout <<"LO__updateL returnung...\n"; - return; - } - else - { - beginPos=a; - endPos=b; - line->setPoints (a.x(), a.y(), b.x(), b.y()); - } -} - -BranchObj* LinkObj::otherBranch(BranchObj* thisBranch) -{ - if (!beginBranch && !endBranch) - return NULL; - if (thisBranch==beginBranch) - return endBranch; - else - return beginBranch; -} - -void LinkObj::positionBBox() -{ -} - -void LinkObj::calcBBoxSize() -{ -} - -void LinkObj::setVisibility (bool b) -{ - MapObj::setVisibility (b); - if (b) - { - line->show(); - } - else - { - line->hide(); - } -} - -void LinkObj::setVisibility () -{ - if (beginBranch && endBranch) - { - if(beginBranch->isVisibleObj() && endBranch->isVisibleObj()) - { // Both ends are visible - setVisibility (true); - visBranch=NULL; - } else - { - if(!beginBranch->isVisibleObj() && !endBranch->isVisibleObj()) - { //None of the ends is visible - setVisibility (false); - visBranch=NULL; - } else - { // Just one end is visible, draw a symbol that shows - // that there is a link to a scrolled branch - setVisibility (true); - if (beginBranch->isVisibleObj()) - visBranch=beginBranch; - else - visBranch=endBranch; - - } - } - } -} - diff -r f688a9913724 -r 598768200cfa linkobj.h --- a/linkobj.h Mon Apr 18 06:17:00 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -#ifndef LINKOBJ_H -#define LINKOBJ_H - -#include "linkablemapobj.h" - -enum LinkState {undefinedLink,initLink,activeLink,deleteLink}; - -///////////////////////////////////////////////////////////////////////////// -class LinkObj:public MapObj { -public: - LinkObj (); - LinkObj (QCanvas*); - ~LinkObj (); - virtual void init (); - virtual void copy (LinkObj*); - void setBegin (BranchObj*); - void setEnd (BranchObj*); - void setEnd (QPoint); - bool activate (); // Sets pointers in branchObjects - void deactivate(); // removes those pointers - bool isUsed(); // true, if at least on branch uses it - void updateLink(); - BranchObj* otherBranch (BranchObj*); - void positionBBox(); - void calcBBoxSize(); - void setVisibility (bool); - void setVisibility (); - -private: - QCanvasLine *line; - BranchObj *beginBranch; - BranchObj *endBranch; - BranchObj *visBranch; // the "visible" part of a partially scrolled link - LinkState linkState; // init during drawing or active - QPoint beginPos; - QPoint endPos; -}; - -#endif