Update of /cvsroot/kuml/kuml/kuml_gui/src/ige/common/manipulators
In directory usw-pr-cvs1:/tmp/cvs-serv14936
Added Files:
LineViewResizer.h LineViewResizer.cpp
Log Message:
Added file
--- NEW FILE ---
/***************************************************************************
LineViewResizer.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 LINEVIEWRESIZER_H
#define LINEVIEWRESIZER_H
#include "ViewResizer.h"
class SelectionLayer;
class SelectionHandle;
class LineViewResizer : public ViewResizer {
public:
virtual ~LineViewResizer();
LineViewResizer(View * target);
virtual void createHandles(SelectionLayer *layer);
virtual void placeHandles();
protected:
enum Handles { enumStartPoint = 1,
enumEndPoint = 2
};
virtual void resizeTarget(SelectionHandle *handle, int diffx, int diffy);
};
#endif //LINEVIEWRESIZER_H
--- NEW FILE ---
/***************************************************************************
LineViewResizer.cpp - 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 "LineViewResizer.h"
#include "ige/common/editors/SelectionLayer.h"
#include "ige/common/editors/Viewer.h"
#include "ige/common/views/LineView.h"
void LineViewResizer::placeHandles() {
LineView *v = (LineView*)getTarget();
CHECK_PTR(v);
// Place first handle at the start of the line
HandleVectorIter iter = getHandleIterator();
SelectionHandle *handle = *iter;
handle->setCenter(v->getStartPoint());
// Place second handle at the end of the line
++iter;
handle = *iter;
handle->setCenter(v->getEndPoint());
}
void LineViewResizer::createHandles(SelectionLayer *layer) {
SelectionHandle *handle = 0;
selectionLayer = layer;
handle = new SelectionHandle(this, enumStartPoint);
addHandle(handle);
layer->addHandle(handle);
handle = new SelectionHandle(this, enumEndPoint);
addHandle(handle);
layer->addHandle(handle);
placeHandles();
}
void LineViewResizer::resizeTarget(SelectionHandle *handle, int diffx, int diffy) {
QRect damagedArea = getTarget()->bounds();
LineView *view = (LineView*)getTarget();
QPoint newStart = view->getStartPoint();
QPoint newEnd = view->getEndPoint();
switch(handle->getId()) {
case enumStartPoint: newStart = newStart + QPoint(diffx, diffy);
break;
case enumEndPoint: newEnd = newEnd + QPoint(diffx, diffy);
break;
}
view->setStartPoint(newStart);
view->setEndPoint(newEnd);
damagedArea = damagedArea.unite(view->bounds());
damagedArea = damagedArea.unite(this->bounds());
placeHandles();
view->getViewer()->refresh(damagedArea);
}
LineViewResizer::~LineViewResizer(){}
LineViewResizer::LineViewResizer(View * target) : ViewResizer(target) {
}
|