From: Darius S. <dst...@us...> - 2001-07-25 12:46:43
|
Update of /cvsroot/kuml/kuml/kuml_gui/src/ige/common/manipulators In directory usw-pr-cvs1:/tmp/cvs-serv1242 Added Files: ChainedLineViewResizer.h ChainedLineViewResizer.cpp Log Message: Added file --- NEW FILE --- /*************************************************************************** ChainedLineViewResizer.h - description ------------------- begin : Tue July 24 2001 copyright : (C) 2001 by the kUML Team author : Darius Stachow email : sta...@in... ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef CHAINEDLINEVIEWRESIZER_H #define CHAINEDLINEVIEWRESIZER_H #include "LineViewResizer.h" #include "ige/common/views/SelectionHandle.h" class SelectionLayer; class ChainedLineViewResizer : public LineViewResizer { public: virtual void createHandles(SelectionLayer *layer); virtual void placeHandles(); protected: virtual void resizeTarget(SelectionHandle *handle, int diffx, int diffy); public: virtual ~ChainedLineViewResizer(); ChainedLineViewResizer(View *target); private: /** @link aggregation */ vector < SelectionHandle * > handles; }; #endif //CHAINEDLINEVIEWRESIZER_H --- NEW FILE --- /*************************************************************************** ChainedLineViewResizer.h - description ------------------- begin : Tue July 24 2001 copyright : (C) 2001 by the kUML Team author : Darius Stachow email : sta...@in... ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include "ChainedLineViewResizer.h" #include "ige/common/views/ChainedLineView.h" #include "ige/common/editors/SelectionLayer.h" #include "ige/common/editors/Viewer.h" void ChainedLineViewResizer::resizeTarget(SelectionHandle *handle, int diffx, int diffy) { QRect damagedArea = getTarget()->bounds(); ChainedLineView *target = (ChainedLineView*)getTarget(); LineView *lineSegment = 0; LineView *lineSegmentSuccessor = 0; int id = handle->getId(); // Move start point if(handle->getId() == 0) { lineSegment = (ChainedLineView*)target->getChild(0); if(lineSegment) { lineSegment->setStartPoint(lineSegment->getStartPoint() + QPoint(diffx, diffy)); } } else if(handle->getId() >= 1) { lineSegment = (ChainedLineView*)target->getChild(handle->getId() - 1); lineSegmentSuccessor = (ChainedLineView*)target->getChild(handle->getId()); if(lineSegment) { lineSegment->setEndPoint(lineSegment->getEndPoint() + QPoint(diffx, diffy)); } if(lineSegmentSuccessor) { lineSegmentSuccessor->setStartPoint(lineSegmentSuccessor->getStartPoint() + QPoint(diffx, diffy)); } } /* if(handle->getId() == 1) { lineSegment = (ChainedLineView*)target->getChild(0); lineSegment->setEndPoint(lineSegment->getEndPoint() + QPoint(diffx, diffy)); } if(handle->getId() >= 2) { lineSegment = (ChainedLineView*)target->getChild(handle->getId() - 1); lineSegment->setEndPoint(lineSegment->getEndPoint() + QPoint(diffx, diffy)); } */ damagedArea = damagedArea.unite(target->bounds()); damagedArea = damagedArea.unite(this->bounds()); placeHandles(); target->getViewer()->refresh(damagedArea); } void ChainedLineViewResizer::placeHandles() { ChainedLineView *v = (ChainedLineView*)getTarget(); CHECK_PTR(v); // Place first handle at the start of the line HandleVectorIter iter = getHandleIterator(); SelectionHandle *handle = *iter; handle->setCenter(((LineView*)v->getChild(0))->getStartPoint()); // Place second handle at the end of the line ++iter; handle = *iter; handle->setCenter(((LineView*)v->getChild(0))->getEndPoint()); for(int i = 1; i < v->getChildCount(); i++) { ++iter; handle = *iter; handle->setCenter(((LineView*)v->getChild(i))->getEndPoint()); } } void ChainedLineViewResizer::createHandles(SelectionLayer *layer) { SelectionHandle *handle = 0; selectionLayer = layer; ChainedLineView *view = (ChainedLineView*)getTarget(); for(int id = 0; id < view->getChildCount() + 1; id++) { handle = new SelectionHandle(this, id); addHandle(handle); layer->addHandle(handle); } placeHandles(); } ChainedLineViewResizer::~ChainedLineViewResizer(){} ChainedLineViewResizer::ChainedLineViewResizer(View *target) : LineViewResizer(target) { } |