[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kuml-devel
Subject:    Events
From:       Darius Stachow <dstachow () ngi ! de>
Date:       2000-04-04 18:16:18
[Download RAW message or body]

Hi,

I have thought a little bit about the event handling (paint and mouse
events) in kuml and how the processing can be made more flexible.
The CreationHelper classes are the only classes who can process events. Till
now this was ok but I think this should be made more flexible in the future.

I have attached a kuml class diagram of my idea.

To enable other classes process events we need a common interface like
this:

class EventProxy {
protected:
	virtual void mouseMoveEvent(QMouseEvent*) = 0;
	virtual void mousePressEvent(QMouseEvent*) = 0;
	virtual void mouseReleaseEvent(QMouseEvent*) = 0;
	virtual void paintEvent(QPaintEvent*) = 0;
};

Every class that needs to process events have to implement this interface.

The DrawingArea class gets a new pointer variable of type EventProxy storing
the actual used event proxy. 

The incoming event calls will be delegated to an installed event proxy:

DrawingArea::mouseMoveEvent(QMouseEvent e) {
  if(eventProxy) eventProxy->mouseMoveEvent(e);
}
DrawingArea::paintEvent(QPaintEvent e) {
  if(eventProxy) eventProxy->paintEvent(e);
}

I have a SelectionManager class in mind that is responsible for painting and
moving the selection rectangle (finding all items within this rectangle),
process the mouse events and do the selection management. To get easy access to
all selected items the class should provide an iterator over all selected
objects.  To be able to move and paint the selection rectangle the
SelectionManager must process the paint and mouse events (like the
CreationHelper). For this the SelectionManager have to implement the EventProxy
interface:

The diagram -> bitmap feature shouldn't just allow to make a snapshot of the
whole diagram but also a rectangular selection. At the moment the code for
the selection rectangle support used for a selection of a group of items (by the
way: what is the correct englich word for this selection rectangle ?) isn't
flexibly. You can just select items within the rectangle. You can't use
the painted selection rectangle for other things :-(

The usage of the event proxies could look like this:
If the editor is in idle mode (you can select items, resize them or popup the
context menu) the SelectionManager object is installed as event proxy.
If you click on an item it will become selected. If you click the right button
on the diagram's background the rectangle selection will be initiated.

Now, if you want to add an item to diagram (e.g. the user clicks on the textnote
icon in the toolbar) the corresponding CreationHelper will be installed as event
proxy so it can do the placing of the item. After this the selection manager
will be set back again as event proxy.

The event proxy stuff will give control over the painting area and allow to
wait for user (mouse) interaction. This could used to paint additional graphics
or something else on the diagram to help the user or react on mouse events.

As I am working on other parts I can't do this myself. Is there a volunteer for
this feature ?
Comments on my idea are very welcome !


On Mon, 03 Apr 2000, you wrote:
>Here the actual problem I want to correct:
>A creationhelper shall receive mouse move events with unpressed buttons, 
>but the events disappear somewhere.
>
>Caused by:
>In DrawingArea::mouseMoveEvent(..)
><code>
>// filter out all Events, which have no mouse button pressed
>if (!mouseButtonPressed)
> return;
>//
></code>
>
>The return does not allow to reach the  if(creationhelper) further down.
>
>Proposed solution:
>Replace to code snippet above by
>
><code>
>if (creationhelper){
> creationhelper->MouseMoveEvent( p );
> return;
>};
></code>
>
>This makes sense because in presence of a creationhelper ALL mouse events 
>sould be sent to it.
>
>
>						Albert
-- 
Open your mind ...
Darius Stachow





["sm2.kuml" (text/english)]

classdiagram {
   diagram Class Diagram 1 {
      Path = /home/darius/sm2.kuml;
      GridX = 25;
      GridY = 25;
      GridStyle = 3;
      drawingtext Item 5 {
         Outline = true;
         Text = DrawingArea will delegate all events to an installed event proxy.;
         drawingrect {
            X = 358;
            Y = 45;
            Width = 214;
            Height = 53;
            Shadow = true;
            drawingitem {
               Backgroundcolor = 255 255 255;
               Stereotype = ;
               Linecolor = 0 0 0;
               Linewidth = 1;
               Font = Gothic 10 50 0 0;
            }
         }
      }
      drawingtext Item 7 {
         Outline = true;
         Text = The CreationHelper classes and the SelectionManager class have to \
implement the EventProxy interface.;  drawingrect {
            X = 57;
            Y = 37;
            Width = 173;
            Height = 73;
            Shadow = true;
            drawingitem {
               Backgroundcolor = 255 255 255;
               Stereotype = ;
               Linecolor = 0 0 0;
               Linewidth = 1;
               Font = Gothic 10 50 0 0;
            }
         }
      }
      drawingtext Item 9 {
         Outline = true;
         Text = The SelectionManager provides access to the last selected items. It \
also provides information on the position of the selection rectangle. This can be \
used to make a partially snapshot (bitmap) of the diagram. It does the painting and \
resizing of the selection rectangle.;  drawingrect {
            X = 70;
            Y = 465;
            Width = 311;
            Height = 89;
            Shadow = true;
            drawingitem {
               Backgroundcolor = 255 255 255;
               Stereotype = ;
               Linecolor = 0 0 0;
               Linewidth = 1;
               Font = Gothic 10 50 0 0;
            }
         }
      }
   }
   drawingclass SelectionManager {
      class {
         properties {
         }
         operation getSelectedItemsIterator {
            Type = Iterator;
            Parameter = ;
            properties {
               Public = true;
            }
         }
         operation getLastSelectionBounds {
            Type = QRect;
            Parameter = ;
            properties {
               Public = true;
            }
         }
         operation findSelectedItems {
            Type = void;
            Parameter = QRect;
            properties {
               Public = true;
            }
         }
         attribute selectionRect {
            Type = QRect;
            properties {
               Private = true;
            }
         }
      }
      drawingrect {
         X = 162;
         Y = 349;
         Width = 202;
         Height = 103;
         Shadow = true;
         drawingitem {
            Backgroundcolor = 255 255 255;
            Stereotype = ;
            Linecolor = 0 0 0;
            Linewidth = 1;
            Font = Gothic 10 50 0 0;
         }
      }
   }
   drawingclass EventProxy {
      class {
         properties {
         }
         operation paintEvent {
            Type = void;
            Parameter = Event;
            properties {
               Abstract = true;
               Protected = true;
            }
         }
         operation mouseMoveEvent {
            Type = void;
            Parameter = Event;
            properties {
               Abstract = true;
               Protected = true;
            }
         }
         operation mousePressEvent {
            Type = void;
            Parameter = Event;
            properties {
               Abstract = true;
               Protected = true;
            }
         }
         operation mouseReleaseEvent {
            Type = void;
            Parameter = Event;
            properties {
               Abstract = true;
               Protected = true;
            }
         }
      }
      drawingrect {
         X = 37;
         Y = 132;
         Width = 217;
         Height = 100;
         Shadow = true;
         drawingitem {
            Backgroundcolor = 255 255 255;
            Stereotype = ;
            Linecolor = 0 0 0;
            Linewidth = 1;
            Font = Gothic 10 50 0 0;
         }
      }
   }
   drawingclass DrawingArea {
      class {
         properties {
         }
         operation paintEvent {
            Type = void;
            Parameter = Event;
            properties {
               Protected = true;
            }
         }
         operation mouseMoveEvent {
            Type = void;
            Parameter = Event;
            properties {
               Protected = true;
            }
         }
         operation mousePressEvent {
            Type = void;
            Parameter = Event;
            properties {
               Protected = true;
            }
         }
         operation mouseReleaseEvent {
            Type = void;
            Parameter = Event;
            properties {
               Protected = true;
            }
         }
         attribute eventProxy {
            Type = EventProxy;
            properties {
               Private = true;
            }
         }
      }
      drawingrect {
         X = 358;
         Y = 127;
         Width = 198;
         Height = 109;
         Shadow = true;
         drawingitem {
            Backgroundcolor = 255 255 255;
            Stereotype = ;
            Linecolor = 0 0 0;
            Linewidth = 1;
            Font = Gothic 10 50 0 0;
         }
      }
   }
   drawingclass CreationHelper {
      class {
         properties {
         }
      }
      drawingrect {
         X = 35;
         Y = 348;
         Width = 100;
         Height = 100;
         Shadow = true;
         drawingitem {
            Backgroundcolor = 255 255 255;
            Stereotype = ;
            Linecolor = 0 0 0;
            Linewidth = 1;
            Font = Gothic 10 50 0 0;
         }
      }
   }
   drawinggeneralization implements1 {
      drawingconnection {
         Source = CreationHelper;
         Destination = EventProxy;
         Linetype = 0;
         drawingitem {
            Backgroundcolor = 255 255 255;
            Stereotype = ;
            Linecolor = 0 0 0;
            Linewidth = 1;
            Font = Gothic 10 50 0 0;
         }
      }
   }
   drawinggeneralization implements2 {
      drawingconnection {
         Source = SelectionManager;
         Destination = EventProxy;
         Linetype = 0;
         drawingitem {
            Backgroundcolor = 255 255 255;
            Stereotype = ;
            Linecolor = 0 0 0;
            Linewidth = 1;
            Font = Gothic 10 50 0 0;
         }
      }
   }
}



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic