From: Darius S. <dst...@us...> - 2001-07-22 23:21:41
|
Update of /cvsroot/kuml/kuml/kuml_gui/src/ige/common/tools In directory usw-pr-cvs1:/tmp/cvs-serv2714/common/tools Modified Files: AbstractTool.cpp AbstractTool.h SelectionTool.cpp SelectionTool.h Tool.h Log Message: Added more basic implementation for user interaction Index: AbstractTool.cpp =================================================================== RCS file: /cvsroot/kuml/kuml/kuml_gui/src/ige/common/tools/AbstractTool.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -r1.1.1.1 -r1.2 *** AbstractTool.cpp 2001/06/20 19:21:23 1.1.1.1 --- AbstractTool.cpp 2001/07/22 23:21:38 1.2 *************** *** 1,23 **** - /*************************************************************************** - AbstractTool.cpp - description - ------------------- - begin : Wed Jun 20 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 "AbstractTool.h" class Editor; void AbstractTool::setIcon(QPixmap& icon){ this->icon = icon; --- 1,17 ---- #include "AbstractTool.h" + #include <qevent.h> + + void AbstractTool::shutdown(){ + } + void AbstractTool::init(){ + } class Editor; + void AbstractTool::mouseRMBPress(QMouseEvent* e, Editor *editor){ + } + void AbstractTool::mouseLMBPress(QMouseEvent* e, Editor *editor){ + } void AbstractTool::setIcon(QPixmap& icon){ this->icon = icon; *************** *** 30,39 **** } ! void AbstractTool::setEditor(Editor* editor){ this->editor = editor; } Editor* AbstractTool::getEditor(){ return editor; ! } void AbstractTool::paint(QPainter* p){ } --- 24,33 ---- } ! /*void AbstractTool::setEditor(Editor* editor){ this->editor = editor; } Editor* AbstractTool::getEditor(){ return editor; ! }*/ void AbstractTool::paint(QPainter* p){ } *************** *** 42,51 **** AbstractTool::AbstractTool(){ } ! void AbstractTool::mouseDblClick(QMouseEvent* e){ } ! void AbstractTool::mouseMove(QMouseEvent* e){ } ! void AbstractTool::mouseRelease(QMouseEvent* e){ } ! void AbstractTool::mousePress(QMouseEvent* e){ } --- 36,50 ---- AbstractTool::AbstractTool(){ } ! void AbstractTool::mouseDblClick(QMouseEvent* e, Editor *editor){ } ! void AbstractTool::mouseMove(QMouseEvent* e, Editor *editor){ } ! void AbstractTool::mouseRelease(QMouseEvent* e, Editor *editor){ } ! void AbstractTool::mousePress(QMouseEvent* e, Editor *editor){ ! if(Qt::LeftButton == e->button()) ! mouseLMBPress(e, editor); ! else ! if(Qt::RightButton == e->button()) ! mouseRMBPress(e, editor); } Index: AbstractTool.h =================================================================== RCS file: /cvsroot/kuml/kuml/kuml_gui/src/ige/common/tools/AbstractTool.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -r1.1.1.1 -r1.2 *** AbstractTool.h 2001/06/20 19:21:22 1.1.1.1 --- AbstractTool.h 2001/07/22 23:21:38 1.2 *************** *** 29,45 **** virtual ~AbstractTool(); ! virtual void mousePress(QMouseEvent* e); ! virtual void mouseRelease(QMouseEvent* e); ! virtual void mouseMove(QMouseEvent* e); ! virtual void mouseDblClick(QMouseEvent* e); virtual void paint(QPainter* p); ! virtual Editor* getEditor(); ! virtual void setEditor(Editor* editor); virtual string getDescription(); --- 29,45 ---- virtual ~AbstractTool(); ! virtual void mouseMove(QMouseEvent * e, Editor *editor); ! virtual void mouseRelease(QMouseEvent * e, Editor *editor); ! virtual void mouseDblClick(QMouseEvent * e, Editor *editor); ! virtual void mousePress(QMouseEvent* e, Editor *editor); virtual void paint(QPainter* p); ! /* virtual Editor* getEditor(); ! virtual void setEditor(Editor* editor);*/ virtual string getDescription(); *************** *** 48,51 **** --- 48,63 ---- virtual void setIcon(QPixmap& icon); + + virtual void mouseLMBPress(QMouseEvent* e, Editor *editor); + + virtual void mouseRMBPress(QMouseEvent* e, Editor *editor); + + /** + * This method should be called before usage of the tool. + * It initializes some variables. + */ + virtual void init(); + + virtual void shutdown(); private: Index: SelectionTool.cpp =================================================================== RCS file: /cvsroot/kuml/kuml/kuml_gui/src/ige/common/tools/SelectionTool.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -r1.1.1.1 -r1.2 *** SelectionTool.cpp 2001/06/20 19:21:23 1.1.1.1 --- SelectionTool.cpp 2001/07/22 23:21:38 1.2 *************** *** 18,21 **** --- 18,61 ---- #include "SelectionTool.h" + #include "ige/common/documents/Document.h" + #include "ige/common/editors/SelectionLayer.h" + #include "ige/common/editors/Viewer.h" + #include "ige/common/views/SelectableView.h" + #include "ige/common/editors/AbstractEditor.h" + //#include "ige/common/editors/Viewer.h" + + class ViewManipulator; + + #include <qcursor.h> + #include <qpopupmenu.h> + + void SelectionTool::init(){ + _LMBPressed = false; + _RMBPressed = false; + forwardEvents = 0; + } + void SelectionTool::mouseLMBPress(QMouseEvent* e, Editor *editor) { + _LMBPressed = true; + + Layer *layer = editor->getViewer()->getLayer(); + View *view = 0; + ViewManipulator *manipulator = 0; + + view = layer->pick(e->pos()); + forwardEvents = view; + + if(view) { + // Let the view process the event itself. The SelectableView's default implemention will create a popup menu + view->mouseLMBPress(e); + } else { + editor->unselectAll(); + } + + /* slayer->startMultiSelection(e->pos().x(), e->pos().y()); + DataLayer *dlayer = editor->getViewer()->getDataLayer(); + return;*/ + + } + string SelectionTool::getDescription(){ return "SelectionTool"; *************** *** 29,38 **** SelectionTool * SelectionTool::instance= 0; SelectionTool::SelectionTool(){} ! void SelectionTool::mouseDblClick(QMouseEvent* e){ ! } ! void SelectionTool::mouseMove(QMouseEvent* e){ } ! void SelectionTool::mouseRelease(QMouseEvent* e){ } ! void SelectionTool::mousePress(QMouseEvent* e){ } --- 69,106 ---- SelectionTool * SelectionTool::instance= 0; SelectionTool::SelectionTool(){} ! void SelectionTool::mouseDblClick(QMouseEvent* e, Editor *editor){ } ! void SelectionTool::mouseMove(QMouseEvent* e, Editor *editor){ ! qDebug("SelectionTool::mouseMoveEvent"); ! ! if(forwardEvents) ! forwardEvents->mouseMove(e); ! ! SelectionLayer *slayer = ((AbstractEditor*)editor)->getSelectionLayer(); ! slayer->continueMultiSelection(e->pos().x(), e->pos().y()); } ! void SelectionTool::mouseRelease(QMouseEvent* e, Editor *editor){ ! _RMBPressed = false; ! _LMBPressed = false; ! ! SelectionLayer *slayer = ((AbstractEditor*)editor)->getSelectionLayer(); ! slayer->endMultiSelection(); ! } ! void SelectionTool::mouseRMBPress(QMouseEvent* e, Editor *editor) { ! _RMBPressed = true; ! ! Layer *layer = editor->getViewer()->getLayer(); ! View *view = 0; ! ! view = layer->pick(e->pos()); ! ! if(view) ! // Let the view process the event itself. The SelectableView's default implemention will create a popup menu ! view->mouseRMBPress(e); ! else { ! QPopupMenu *menu; ! menu = editor->getDocument()->createPopupMenu(); ! menu->exec(QCursor::pos()); ! delete menu; ! } } Index: SelectionTool.h =================================================================== RCS file: /cvsroot/kuml/kuml/kuml_gui/src/ige/common/tools/SelectionTool.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -r1.1.1.1 -r1.2 *** SelectionTool.h 2001/06/20 19:21:22 1.1.1.1 --- SelectionTool.h 2001/07/22 23:21:38 1.2 *************** *** 21,24 **** --- 21,25 ---- #include "Tool.h" #include "AbstractTool.h" + class Editor; class ViewManipulator; /** *************** *** 32,42 **** public: - virtual void mousePress(QMouseEvent* e); ! virtual void mouseRelease(QMouseEvent* e); ! virtual void mouseMove(QMouseEvent* e); ! virtual void mouseDblClick(QMouseEvent* e); static SelectionTool * getInstance(); --- 33,42 ---- public: ! virtual void mouseRelease(QMouseEvent* e, Editor *editor); ! virtual void mouseMove(QMouseEvent* e, Editor *editor); ! virtual void mouseDblClick(QMouseEvent* e, Editor *editor); static SelectionTool * getInstance(); *************** *** 44,49 **** --- 44,73 ---- virtual string getDescription(); + virtual void mouseRMBPress(QMouseEvent* e, Editor *editor); + + virtual void mouseLMBPress(QMouseEvent* e, Editor *editor); + + bool isLMBPressed() { + return _LMBPressed; + } + + bool isRMBPressed() { + return _RMBPressed; + } + + /** + * This method should be called before usage of the tool. + * It initializes some variables. + */ + virtual void init(); + private: static SelectionTool * instance; + + bool _LMBPressed; + bool _RMBPressed; + + View *forwardEvents; + }; #endif //SELECTIONTOOL_H Index: Tool.h =================================================================== RCS file: /cvsroot/kuml/kuml/kuml_gui/src/ige/common/tools/Tool.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -r1.1.1.1 -r1.2 *** Tool.h 2001/06/20 19:21:22 1.1.1.1 --- Tool.h 2001/07/22 23:21:38 1.2 *************** *** 20,24 **** #ifndef TOOL_H #define TOOL_H ! #include "ige/common/EventHandler.h" #include "ige/common/Paintable.h" --- 20,24 ---- #ifndef TOOL_H #define TOOL_H ! //#include "ige/common/EventHandler.h" #include "ige/common/Paintable.h" *************** *** 28,32 **** class Editor; ! /* * A tool defines a mode of the editor. --- 28,32 ---- class Editor; ! class QMouseEvent; /* * A tool defines a mode of the editor. *************** *** 37,51 **** * @interface */ ! ! class Tool : public Paintable , public EventHandler{ public: ! virtual void setEditor(Editor * e) = 0; ! virtual Editor* getEditor() = 0; virtual string getDescription() = 0; QPixmap& getIcon(); }; #endif //TOOL_H --- 37,66 ---- * @interface */ ! class Tool : public Paintable /* , public EventHandler */ { public: + + virtual void mouseMove(QMouseEvent * e, Editor *editor) = 0; + + virtual void mousePress(QMouseEvent * e, Editor *editor) = 0; ! virtual void mouseRelease(QMouseEvent * e, Editor *editor) = 0; ! virtual void mouseDblClick(QMouseEvent * e, Editor *editor) = 0; + /* virtual void setEditor(Editor * e) = 0; + + virtual Editor* getEditor() = 0;*/ + virtual string getDescription() = 0; QPixmap& getIcon(); + + /** + * This method should be called before usage of the tool. + * It initializes some variables. + */ + virtual void init() =0; + + virtual void shutdown() =0; }; #endif //TOOL_H |