|
From: Darius S. <dst...@us...> - 2001-07-22 23:21:41
|
Update of /cvsroot/kuml/kuml/kuml_gui/src/ige/common/manipulators
In directory usw-pr-cvs1:/tmp/cvs-serv2714/common/manipulators
Modified Files:
AbstractViewManipulator.cpp AbstractViewManipulator.h
RectangleViewResizer.cpp RectangleViewResizer.h
ViewManipulator.h ViewResizer.h ViewSelector.h
Log Message:
Added more basic implementation for user interaction
Index: AbstractViewManipulator.cpp
===================================================================
RCS file: /cvsroot/kuml/kuml/kuml_gui/src/ige/common/manipulators/AbstractViewManipulator.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** AbstractViewManipulator.cpp 2001/06/20 19:21:26 1.1.1.1
--- AbstractViewManipulator.cpp 2001/07/22 23:21:38 1.2
***************
*** 16,24 ****
* *
***************************************************************************/
#include "AbstractViewManipulator.h"
! AbstractViewManipulator::~AbstractViewManipulator(){}
! class View;
! void AbstractViewManipulator::mouseRelease(QMouseEvent* e){}
! AbstractViewManipulator::AbstractViewManipulator(){}
--- 16,52 ----
* *
***************************************************************************/
+ class SelectionHandle;
+ class View;
+
+ #include <qevent.h>
#include "AbstractViewManipulator.h"
! View* AbstractViewManipulator::getTarget(){
! return target;
! }
! void AbstractViewManipulator::setHandle(SelectionHandle* handle){
! this->handle = handle;
! }
! SelectionHandle* AbstractViewManipulator::getHandle(){
! return handle;
! }
! void AbstractViewManipulator::handlePressEvent(SelectionHandle * handle, QMouseEvent * event){
! oldMousePos = event->pos();
! }
! void AbstractViewManipulator::handleMoveEvent(SelectionHandle * handle, QMouseEvent * event){
! oldMousePos = event->pos();
! }
! void AbstractViewManipulator::mouseRMBPress(QMouseEvent * e){
! oldMousePos = e->pos();
! }
! void AbstractViewManipulator::mouseLMBPress(QMouseEvent * e){
! oldMousePos = e->pos();
! }
! AbstractViewManipulator::~AbstractViewManipulator(){
! }
! AbstractViewManipulator::AbstractViewManipulator(View * target){
! CHECK_PTR(target);
! handle = 0;
! this->target = target;
! }
Index: AbstractViewManipulator.h
===================================================================
RCS file: /cvsroot/kuml/kuml/kuml_gui/src/ige/common/manipulators/AbstractViewManipulator.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** AbstractViewManipulator.h 2001/06/20 19:21:25 1.1.1.1
--- AbstractViewManipulator.h 2001/07/22 23:21:38 1.2
***************
*** 20,39 ****
#define ABSTRACTVIEWMANIPULATOR_H
#include "ViewManipulator.h"
class View;
class AbstractViewManipulator : public ViewManipulator {
public:
! AbstractViewManipulator();
virtual ~AbstractViewManipulator();
virtual void mousePress(QMouseEvent* e){}
virtual void mouseMove(QMouseEvent* e){}
! virtual void mouseRelease(QMouseEvent* e);
! virtual void mouseDblCLick(QMouseEvent* e){}
};
#endif //ABSTRACTVIEWMANIPULATOR_H
--- 20,121 ----
#define ABSTRACTVIEWMANIPULATOR_H
#include "ViewManipulator.h"
+
+ #include <qpoint.h>
+
class View;
+ class SelectionHandle;
+ class Viewer;
+ class RectangleView;
+ //class View;
class AbstractViewManipulator : public ViewManipulator {
public:
! AbstractViewManipulator(View * target);
virtual ~AbstractViewManipulator();
+ /** Implementation of interface EventHandler */
virtual void mousePress(QMouseEvent* e){}
+ /** Implementation of interface EventHandler */
virtual void mouseMove(QMouseEvent* e){}
+
+ /** Implementation of interface EventHandler */
+ virtual void mouseRelease(QMouseEvent* e) {}
+
+ /** Implementation of interface EventHandler */
+ virtual void mouseDblClick(QMouseEvent* e){}
+
+ /** Implementation of interface Paintable */
+ virtual void paint(QPainter * painter){}
+
+ /** Implementation of interface View */
+ virtual QRect & bounds() { }
+
+ /** Implementation of interface View */
+ virtual bool intersects(const QPoint & p) { return false; }
+
+ /** Implementation of interface View */
+ virtual void remove(View * v) {}
+
+ /** Implementation of interface View */
+ virtual void add(View * v) {}
+
+ /** Implementation of interface View */
+ virtual View* getParent() { return 0; }
+
+ /** Implementation of interface View */
+ virtual QPoint getCenter() {}
+
+ /** Implementation of interface View */
+ virtual void setCenter(const QPoint& p) {}
+
+ /** Implementation of interface Observer */
+ virtual void update() {}
+
+ /** Implementation of interface Observer */
+ virtual void changed() {}
+
+ /** Left mouse button clicked
+ */
+ virtual void mouseLMBPress(QMouseEvent * e);
+
+ /** Right mouse button clicked
+ */
+ virtual void mouseRMBPress(QMouseEvent * e);
+
+ virtual void setViewer(Viewer *v) {}
+
+ virtual Viewer* getViewer() { return 0; }
+
+ /**
+ * This method will be called when a handle has been clicked
+ *
+ */
+ virtual void handlePressEvent(SelectionHandle * handle, QMouseEvent * event);
+
+ /**
+ * This method will be called when a handle has been moved
+ *
+ */
+ virtual void handleMoveEvent(SelectionHandle * handle, QMouseEvent * event);
+
+ /**
+ * Gets the last pressed handle if any
+ *
+ */
+ SelectionHandle* getHandle();
+
+ void setHandle(SelectionHandle* handle);
+
+ virtual View* getTarget();
! protected:
! QPoint oldMousePos;
! private:
! SelectionHandle* handle;
! View* target;
};
#endif //ABSTRACTVIEWMANIPULATOR_H
Index: RectangleViewResizer.cpp
===================================================================
RCS file: /cvsroot/kuml/kuml/kuml_gui/src/ige/common/manipulators/RectangleViewResizer.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** RectangleViewResizer.cpp 2001/06/20 19:21:26 1.1.1.1
--- RectangleViewResizer.cpp 2001/07/22 23:21:38 1.2
***************
*** 18,35 ****
#include "RectangleViewResizer.h"
class RectangleView;
RectangleViewResizer::~RectangleViewResizer(){
}
! RectangleViewResizer::RectangleViewResizer(){
}
!
! void RectangleViewResizer::setTarget(RectangleView* target){
! this->target = target;
}
! RectangleView* RectangleViewResizer::getTarget(){
! return target;
}
! RectangleViewResizer::RectangleViewResizer(RectangleView* v){
}
--- 18,188 ----
#include "RectangleViewResizer.h"
+ #include "ige/common/editors/SelectionLayer.h"
+ #include "ige/common/editors/Viewer.h"
+ #include <qevent.h>
+
class RectangleView;
+ void RectangleViewResizer::handleMoveEvent(SelectionHandle * handle, QMouseEvent * event){
+ int dx = event->x() - oldMousePos.x();
+ int dy = event->y() - oldMousePos.y();
+
+ resizeTarget(handle, dx, dy);
+
+ oldMousePos = event->pos();
+ }
+ void RectangleViewResizer::resizeTarget(SelectionHandle *handle, int diffx, int diffy) {
+ QRect damagedArea = getTarget()->bounds();
+ RectangleView *view = (RectangleView*)getTarget();
+ QRect rect = view->getRectangle();
+
+ int x = rect.x();
+ int y = rect.y();
+ int w = rect.width();
+ int h = rect.height();
+
+ switch(handle->getId()) {
+ case enumTopLeft: x += diffx;
+ y += diffy;
+ w -= diffx;
+ h -= diffy;
+ break;
+ case enumTopRight : y += diffy;
+ w += diffx;
+ h -= diffy;
+ break;
+ case enumBottomLeft: x += diffx;
+ w -= diffx;
+ h += diffy;
+ break;
+ case enumBottomRight: w += diffx;
+ h += diffy;
+ break;
+ case enumMiddleTop: y += diffy;
+ h -= diffy;
+ break;
+ case enumMiddleBottom: h += diffy;
+ break;
+ case enumMiddleLeft: x += diffx;
+ w -= diffx;
+ break;
+ case enumMiddleRight: w += diffx;
+ break;
+
+ }
+
+ // Check min size
+ if((w <= 10) || (h<=10))
+ return;
+
+ QRect temp(x,y,w,h);
+ view->setRectangle(temp);
+ damagedArea = damagedArea.unite(temp);
+
+ placeHandles();
+
+ view->getViewer()->refresh(damagedArea);
+ }
+ RectangleViewResizer::RectangleViewResizer(RectangleView * target) : ViewResizer((View*)target) {
+ // this->target = target;
+ }
RectangleViewResizer::~RectangleViewResizer(){
}
! QRect & RectangleViewResizer::bounds() {
! return getTarget()->bounds();
}
! bool RectangleViewResizer::intersects(const QPoint & p) {
! return getTarget()->intersects(p);
}
! void RectangleViewResizer::placeHandles() {
! View *target = getTarget();
! CHECK_PTR(target);
!
! int left = getTarget()->bounds().left();
! int right = getTarget()->bounds().right();
! int top = getTarget()->bounds().top();
! int bottom = getTarget()->bounds().bottom();
! int height = getTarget()->bounds().height();
! int width = getTarget()->bounds().width();
! int xcenter = getTarget()->bounds().center().x();
! int ycenter = getTarget()->bounds().center().y();
!
!
! // Place top left handle
! HandleVectorIter iter = getHandleIterator();
! SelectionHandle *handle = *iter;
! handle->getRectangle().moveTopLeft(QPoint(left, top));
!
! // Place top right handle
! ++iter;
! handle = *iter;
! handle->getRectangle().moveTopRight(QPoint(right, top));
!
! // Place bottom left handle
! ++iter;
! handle = *iter;
! handle->getRectangle().moveBottomRight(QPoint(right, bottom));
!
! // Place bottom right handle
! ++iter;
! handle = *iter;
! handle->getRectangle().moveBottomLeft(QPoint(left, bottom));
!
! // Place middle top handle
! ++iter;
! handle = *iter;
! handle->getRectangle().moveTopLeft(QPoint(xcenter-(SelectionHandle::SIZE>>1), top));
!
! // Place middle bottom handle
! ++iter;
! handle = *iter;
! handle->getRectangle().moveBottomLeft(QPoint(xcenter-(SelectionHandle::SIZE>>1), bottom));
!
! // Place middle left handle
! ++iter;
! handle = *iter;
! handle->getRectangle().moveTopLeft(QPoint(left, ycenter-(SelectionHandle::SIZE>>1)));
!
! // Place middle right selection handle
! ++iter;
! handle = *iter;
! handle->getRectangle().moveTopRight(QPoint(right, ycenter-(SelectionHandle::SIZE>>1)));
}
! void RectangleViewResizer::createHandles(SelectionLayer *layer) {
! SelectionHandle *handle = 0;
!
! handle = new SelectionHandle(this, enumTopLeft);
! addHandle(handle);
! layer->addHandle(handle);
!
! handle = new SelectionHandle(this, enumTopRight);
! addHandle(handle);
! layer->addHandle(handle);
!
! handle = new SelectionHandle(this, enumBottomRight);
! addHandle(handle);
! layer->addHandle(handle);
!
! handle = new SelectionHandle(this, enumBottomLeft);
! addHandle(handle);
! layer->addHandle(handle);
!
! handle = new SelectionHandle(this, enumMiddleTop);
! addHandle(handle);
! layer->addHandle(handle);
!
! handle = new SelectionHandle(this, enumMiddleBottom);
! addHandle(handle);
! layer->addHandle(handle);
!
! handle = new SelectionHandle(this, enumMiddleLeft);
! addHandle(handle);
! layer->addHandle(handle);
!
! handle = new SelectionHandle(this, enumMiddleRight);
! addHandle(handle);
! layer->addHandle(handle);
!
! placeHandles();
}
Index: RectangleViewResizer.h
===================================================================
RCS file: /cvsroot/kuml/kuml/kuml_gui/src/ige/common/manipulators/RectangleViewResizer.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** RectangleViewResizer.h 2001/06/20 19:21:25 1.1.1.1
--- RectangleViewResizer.h 2001/07/22 23:21:38 1.2
***************
*** 22,44 ****
#include "ige/common/views/RectangleView.h"
class RectangleViewResizer : public ViewResizer {
public:
! RectangleViewResizer(RectangleView* v);
! RectangleViewResizer();
! virtual ~RectangleViewResizer();
! RectangleView* getTarget();
! void setTarget(RectangleView* target);
protected:
! /**
! * The figure to be manipulated.
! * @directed*/
! RectangleView* target;
};
#endif //RECTANGLEVIEWRESIZER_H
--- 22,63 ----
#include "ige/common/views/RectangleView.h"
+ class SelectionHandle;
+
class RectangleViewResizer : public ViewResizer {
public:
! RectangleViewResizer(RectangleView * target);
! virtual ~RectangleViewResizer();
! virtual void createHandles(SelectionLayer *layer);
! virtual void placeHandles();
! /** Implementation of interface View */
! virtual QRect & bounds();
! /** Implementation of interface View */
! virtual bool intersects(const QPoint & p);
! /**
! * This method will be called when a handle has been moved
! *
! */
! virtual void handleMoveEvent(SelectionHandle * handle, QMouseEvent * event);
protected:
+ void resizeTarget(SelectionHandle *handle, int diffx, int diffy);
! enum Handles { enumTopLeft = 1,
! enumTopRight = 2,
! enumBottomLeft = 3,
! enumBottomRight =4,
! enumMiddleTop = 5,
! enumMiddleBottom = 6,
! enumMiddleLeft = 7,
! enumMiddleRight =8
! };
!
!
! private:
};
#endif //RECTANGLEVIEWRESIZER_H
Index: ViewManipulator.h
===================================================================
RCS file: /cvsroot/kuml/kuml/kuml_gui/src/ige/common/manipulators/ViewManipulator.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** ViewManipulator.h 2001/06/20 19:21:25 1.1.1.1
--- ViewManipulator.h 2001/07/22 23:21:38 1.2
***************
*** 19,34 ****
#ifndef VIEWMANIPULATOR_H
#define VIEWMANIPULATOR_H
! #include "ige/common/EventHandler.h"
! #include "ige/common/Paintable.h"
! class View;
! /** @interface */
! class ViewManipulator : public EventHandler, public Paintable {
public:
virtual View* getTarget() = 0;
! virtual void setTarget(View* v) = 0;
private:
--- 19,75 ----
#ifndef VIEWMANIPULATOR_H
#define VIEWMANIPULATOR_H
! //#include "ige/common/EventHandler.h"
! //#include "ige/common/Paintable.h"
! #include "ige/common/views/View.h"
! class SelectionHandle;
! class SelectionLayer;
! //class View;
!
! /**
! * Manipulator means in this context an object that
! * reacts on user actions to modify graphical objects on the
! * screen. These actions are called direct manipulations.
! *
! * Manipulator objects are created by the manipulated
! * objects through the interface Selectable
! * and are associated to them. The manipulators
! * objects will be stored in the ManipulationLayer.
! * The manipulator can create some selection handles
! * that the user can drag to start a direct manipulation.
! * The handles will be stored in the SelectionLayer.
! * A direct manipulation will be started by pressing
! * and holding the mouse button.
! * A manipulator receive mouse events till the
! * user release the button. This is the end of the
! * manipulation.
! *
! * @interface
! */
! class ViewManipulator : public View {
! //class ViewManipulator : public EventHandler, public Paintable, public Pickable {
public:
virtual View* getTarget() = 0;
+
+ virtual void createHandles(SelectionLayer *layer) = 0;
+ virtual void placeHandles() = 0;
+
+ /**
+ * This method will be called when a handle has been clicked
+ *
+ */
+ virtual void handlePressEvent(SelectionHandle * handle, QMouseEvent * event) = 0;
+
+ /**
+ * This method will be called when a handle has been moved
+ *
+ */
+ virtual void handleMoveEvent(SelectionHandle * handle, QMouseEvent * event) = 0;
+
+ virtual SelectionHandle* getHandle() = 0;
! // virtual void setTarget(View* v) = 0;
private:
Index: ViewResizer.h
===================================================================
RCS file: /cvsroot/kuml/kuml/kuml_gui/src/ige/common/manipulators/ViewResizer.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** ViewResizer.h 2001/06/20 19:21:25 1.1.1.1
--- ViewResizer.h 2001/07/22 23:21:38 1.2
***************
*** 23,26 ****
--- 23,39 ----
class ViewResizer : public ViewSelector {
+ public:
+ ViewResizer(View * target);
+ virtual ~ViewResizer();
+
+ /** Left mouse button clicked
+ */
+ virtual void mouseLMBPress(QMouseEvent * e);
+
+ /** Implementation of interface EventHandler */
+ virtual void mouseMove(QMouseEvent* e);
+
+ protected:
+ void moveTarget(int diffx, int diffy);
};
#endif //VIEWRESIZER_H
Index: ViewSelector.h
===================================================================
RCS file: /cvsroot/kuml/kuml/kuml_gui/src/ige/common/manipulators/ViewSelector.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** ViewSelector.h 2001/06/20 19:21:25 1.1.1.1
--- ViewSelector.h 2001/07/22 23:21:38 1.2
***************
*** 21,26 ****
--- 21,48 ----
#include "AbstractViewManipulator.h"
#include "ige/common/views/SelectionHandle.h"
+ #include "ige/typedefs.h"
+ class SelectionLayer;
+
class ViewSelector : public AbstractViewManipulator {
+ public:
+ ViewSelector(View * target);
+ virtual ~ViewSelector();
+
+ // virtual void createHandles(SelectionLayer *layer) = 0;
+ virtual void placeHandles() = 0;
+
+ HandleVectorIter getHandleIterator() {
+ return handles.begin();
+ }
+
+ /** Left mouse button clicked
+ */
+ virtual void mouseLMBPress(QMouseEvent * e);
+
+ protected:
+ void removeAllHandles();
+ void addHandle(SelectionHandle *handle);
+
private:
|