Esempio n. 1
0
void ComponentDiagramView::contentsMousePressEvent(QMouseEvent * e) {
  if (!window()->frozen()) {
    UmlCode action = window()->buttonOn();
    
    switch (action) {
    case UmlComponent:
      {
	history_protected = TRUE;
	unselect_all();
	window()->selectOn();
	history_save();
	
	BrowserNode * b = 
	  BrowserComponent::get_component(((BrowserNode *) window()->browser_diagram()->parent()));
	
	if (b != 0) {
	  ComponentCanvas * c = 
	    new ComponentCanvas(b, the_canvas(), e->x(), e->y());
	  
	  c->show();
	  c->upper();
	  window()->package_modified();
	}
	canvas()->update();
	history_protected = FALSE;
      }
      break;
    default:
      DiagramView::contentsMousePressEvent(e);
      break;
    }
  }
  else
    DiagramView::contentsMousePressEvent(e);
}
Esempio n. 2
0
void ClassDiagramView::contentsMousePressEvent(QMouseEvent * e) {
  if (!window()->frozen()) {
    switch (window()->buttonOn()) {
    case UmlClass:
      {
	history_protected = TRUE;
	unselect_all();
	window()->selectOn();
	history_save();
	
	BrowserNode * parent = 
	  ((BrowserNode *) window()->browser_diagram()->parent());
	BrowserNode * b = BrowserClass::get_class(parent);
	
	if (b != 0) {
	  CdClassCanvas * cl = 
	    new CdClassCanvas(b, the_canvas(), e->x(), e->y());
	  
	  cl->show();
	  cl->upper();
	  window()->package_modified();
	}
	canvas()->update();
	history_protected = FALSE;
      }
      break;
    default:
      DiagramView::contentsMousePressEvent(e);
      break;
    }
  }
  else
    DiagramView::contentsMousePressEvent(e);
}
Esempio n. 3
0
void SeqDiagramView::menu(const QPoint &)
{
    QMenu m(0);

    MenuFactory::createTitle(m, tr("Sequence diagram menu"));

    if ((((UmlCanvas *) canvas())->browser_diagram())->is_writable()) {
        BrowserSeqDiagram * sd = (BrowserSeqDiagram *) window()->browser_diagram();
        bool overlapping = sd->is_overlapping_bars();

        MenuFactory::addItem(m, (overlapping) ? tr("Transform to flat activity bars")
                                              : tr("Transform to overlapping activity bars"),
                             29);
        m.addSeparator();

        switch (default_menu(m, 30)) {
        case EDIT_DRAWING_SETTING_CMD:
            ((BrowserSeqDiagram *) the_canvas()->browser_diagram())->edit_settings();
            return;

        case RELOAD_CMD:
            // pure drawing modifications are lost
            // mark the diagram modified because the undid modifications
            // may be saved in the file are not saved in memory
            load("Sequence");
            window()->package_modified();
            break;

        case 29:
            unselect_all();
            sd->set_overlapping_bars(!overlapping);

            if (overlapping)
                toFlat();
            else
                toOverlapping();

            canvas()->update();
            window()->package_modified();
            break;
        }
    }
    else
        (void) default_menu(m, 30);
}
Esempio n. 4
0
void CL_TabHeader_Impl::on_process_message(CL_GUIMessage &msg)
{
	if(component->is_enabled())
	{
		if (msg.is_type(CL_GUIMessage_Input::get_type_name()))
		{
			CL_GUIMessage_Input input_msg = msg;
			CL_InputEvent e = input_msg.get_event();
			CL_Point pos = e.mouse_pos;

			if (e.type == CL_InputEvent::pressed && e.id == CL_MOUSE_LEFT)
			{
				std::vector<Handle>::iterator it;
				for (it = tabs.begin(); it != tabs.end(); ++it)
				{
					bool inside = (*it).rect.contains(pos);
					if (inside)
					{
						unselect_all();
						(*it).part.set_state(CssStr::selected, true);
						(*it).part.set_state(CssStr::normal, false);

						component->request_repaint();
						if (!func_page_selected.is_null())
							func_page_selected.invoke((*it).tab_page);
					}
				}
				msg.set_consumed();
			}
			else if (e.type == CL_InputEvent::pointer_moved)
			{
				std::vector<Handle>::iterator it;
				for (it = tabs.begin(); it != tabs.end(); ++it)
				{
					bool inside = (*it).rect.contains(pos);
					if (inside)
					{
						if ((*it).part.get_state(CssStr::selected))
							return;
						(*it).part.set_state(CssStr::hot, true);
						(*it).part.set_state(CssStr::normal, false);
						component->request_repaint();
						msg.set_consumed();
					}
					else if ((*it).part.get_state(CssStr::hot))
					{
						(*it).part.set_state(CssStr::hot, false);
						(*it).part.set_state(CssStr::normal, true);						
						component->request_repaint();
						msg.set_consumed();
					}
				}
			}
			else if (e.type == CL_InputEvent::pressed && e.id == CL_KEY_LEFT)
			{
				int next_page = selected_page - 1;
				if (next_page < 0)
					next_page = tabs.size()-1;

				unselect_all();
				select_page(next_page);

				if (!func_page_selected.is_null())
					func_page_selected.invoke(tabs[next_page].tab_page);

				component->select_page(next_page);
				msg.set_consumed();
			}
			else if (e.type == CL_InputEvent::pressed && e.id == CL_KEY_RIGHT)
			{
				int next_page = selected_page + 1;
				if (next_page >= tabs.size())
					next_page = 0;

				unselect_all();
				select_page(next_page);

				if (!func_page_selected.is_null())
					func_page_selected.invoke(tabs[next_page].tab_page);

				component->request_repaint();
				msg.set_consumed();
			}
			else if (e.type == CL_InputEvent::pressed && (e.id == CL_KEY_UP || e.id == CL_KEY_DOWN))
			{
				// block focus switching with up/down when in tab header.
				msg.set_consumed();
			}
		}
		else if (msg.is_type(CL_GUIMessage_Pointer::get_type_name()))
		{
			CL_GUIMessage_Pointer pointer = msg;
			if (pointer.get_pointer_type() == CL_GUIMessage_Pointer::pointer_leave)
			{
				std::vector<Handle>::iterator it;
				for (it = tabs.begin(); it != tabs.end(); ++it)
				{
					(*it).part.set_state(CssStr::hot, false);
					(*it).part.set_state(CssStr::normal, true);
				}
				component->request_repaint();
			}
		}
		else if (msg.is_type(CL_GUIMessage_FocusChange::get_type_name()))
		{
			CL_GUIMessage_FocusChange focus_msg = msg;
			if (focus_msg.get_focus_type() == CL_GUIMessage_FocusChange::gained_focus)
			{
				part_background.set_state(CssStr::focused, true);
				component->request_repaint();
			}
			else 
			{
				part_background.set_state(CssStr::focused, false);
				component->request_repaint();
			}
			msg.set_consumed();
		}
	}
}
Esempio n. 5
0
void StateDiagramView::mousePressEvent(QMouseEvent * e)
{
    QPoint diagramPoint(e->x(), e->y());
    QPointF scenePoint = mapToScene(diagramPoint);
    if (!window()->frozen()) {
        UmlCode action = window()->buttonOn();

        switch (action) {
        case UmlState: {
            history_protected = TRUE;
            unselect_all();
            window()->selectOn();
            history_save();

            QGraphicsItem * ci = the_canvas()->collision(scenePoint.toPoint());
            DiagramItem * di;
            bool specified = ((ci != 0) &&
                              ((di = QCanvasItemToDiagramItem(ci)) != 0) &&
                              (di->typeUmlCode() == UmlState) &&
                              ((BrowserState *)((StateCanvas *) di)->get_bn())->may_contains(action));
            BrowserNode * parent;

            if (specified) {
                if ((parent = ((StateCanvas *) di)->pointed_region(scenePoint.toPoint())) == 0)
                    parent = ((StateCanvas *) di)->get_bn();
            }
            else
                parent = (BrowserNode *) window()->browser_diagram()->parent();

            BrowserNode * b = BrowserState::get_state(parent);

            if (b != 0) {
                if (the_canvas()->already_drawn(b)) {
                    msg_information("Douml", TR("already drawn"));
                    history_protected = FALSE;
                    return;
                }

                // may be added in a the state's region rather than the state
                StateCanvas * c = new StateCanvas(b, the_canvas(), scenePoint.x(), scenePoint.y());

                c->show();
                c->upper();
                canvas()->update();
                StateCanvas::force_inside(c, TRUE);
                canvas()->update();
                history_protected = FALSE;
                window()->package_modified();
                return; // canvas already updated
            }
        }
        break;

        case UmlRegion: {
            history_protected = TRUE;
            unselect_all();
            window()->selectOn();
            history_save();

            QGraphicsItem * ci = the_canvas()->collision(scenePoint.toPoint());
            DiagramItem * di;

            if ((ci != 0) &&
                ((di = QCanvasItemToDiagramItem(ci)) != 0) &&
                (di->typeUmlCode() == UmlState) &&
                ((BrowserState *)((StateCanvas *) di)->get_bn())->may_contains(action)) {
                BrowserRegion::add_region(((StateCanvas *) di)->get_bn());
                window()->package_modified();
            }
        }
        break;

        case InitialPS:
        case EntryPointPS:
        case FinalPS:
        case TerminatePS:
        case ExitPointPS:
        case DeepHistoryPS:
        case ShallowHistoryPS:
        case JunctionPS:
        case ChoicePS:
        case ForkPS:
        case JoinPS: {
            history_protected = TRUE;
            unselect_all();
            window()->selectOn();
            history_save();

            QGraphicsItem * ci = the_canvas()->collision(scenePoint.toPoint());
            DiagramItem * di;
            bool specified = ((ci != 0) &&
                              ((di = QCanvasItemToDiagramItem(ci)) != 0) &&
                              (di->typeUmlCode() == UmlState) &&
                              ((BrowserState *)((StateCanvas *) di)->get_bn())->may_contains(action));
            BrowserNode * parent;

            if (specified) {
                if ((parent = ((StateCanvas *) di)->pointed_region(scenePoint.toPoint())) == 0)
                    parent = ((StateCanvas *) di)->get_bn();
            }
            else
                parent = (BrowserNode *) window()->browser_diagram()->parent();

            BrowserNode * b = BrowserPseudoState::get_pseudostate(parent, action);

            if (b != 0) {
                PseudoStateCanvas * c =
                    // may be added in a the state's region rather than the state
                    new PseudoStateCanvas(b, the_canvas(), scenePoint.x(), scenePoint.y());

                c->show();
                c->upper();
                StateCanvas::force_inside(c, FALSE);
                window()->package_modified();
            }
        }
        break;

        case UmlStateAction:
        case UmlSignalIn:
        case UmlSignalOut: {
            history_protected = TRUE;
            unselect_all();
            window()->selectOn();
            history_save();

            QGraphicsItem * ci = the_canvas()->collision(scenePoint.toPoint());
            DiagramItem * di;
            bool specified = ((ci != 0) &&
                              ((di = QCanvasItemToDiagramItem(ci)) != 0) &&
                              (di->typeUmlCode() == UmlState) &&
                              ((BrowserState *)((StateCanvas *) di)->get_bn())->may_contains(UmlStateAction));
            BrowserNode * parent;

            if (specified) {
                if ((parent = ((StateCanvas *) di)->pointed_region(scenePoint.toPoint())) == 0)
                    parent = ((StateCanvas *) di)->get_bn();
            }
            else
                parent = (BrowserNode *) window()->browser_diagram()->parent();

            BrowserNode * b = BrowserStateAction::add_stateaction(parent);

            switch (action) {
            case UmlSignalIn:
                ((StateActionData *) b->get_data())->set_stereotype("receive-signal");
                break;

            case UmlSignalOut:
                ((StateActionData *) b->get_data())->set_stereotype("send-signal");
                break;

            default:	// to avoid warning
                break;
            }

            StateActionCanvas * c =
                // may be added in a the state's region rather than the state
                new StateActionCanvas(b, the_canvas(), scenePoint.x(), scenePoint.y());

            c->show();
            c->upper();
            StateCanvas::force_inside(c, FALSE);
            window()->package_modified();
        }
        break;

        default:
            DiagramView::mousePressEvent(e);
            return;
        }

        canvas()->update();
        history_protected = FALSE;
    }
    else
        DiagramView::mousePressEvent(e);
}
Esempio n. 6
0
void TabHeader_Impl::on_process_message(std::shared_ptr<GUIMessage> &msg)
{
	if(component->is_enabled())
	{
		std::shared_ptr<GUIMessage_Input> input_msg = std::dynamic_pointer_cast<GUIMessage_Input>(msg);
		if (input_msg)
		{
			
			const InputEvent &e = input_msg->input_event;
			Point pos = e.mouse_pos;

			if (e.type == InputEvent::pressed && e.id == mouse_left)
			{
				std::vector<Handle>::iterator it;
				for (it = tabs.begin(); it != tabs.end(); ++it)
				{
					bool inside = (*it).rect.contains(pos);
					if (inside)
					{
						unselect_all();
						(*it).part.set_pseudo_class(CssStr::selected, true);
						(*it).part.set_pseudo_class(CssStr::normal, false);

						component->request_repaint();
						if (!func_page_selected.is_null())
							func_page_selected.invoke((*it).tab_page);
					}
				}
				msg->consumed = true;
			}
			else if (e.type == InputEvent::pointer_moved)
			{
				std::vector<Handle>::iterator it;
				for (it = tabs.begin(); it != tabs.end(); ++it)
				{
					bool inside = (*it).rect.contains(pos);
					if (inside)
					{
						if ((*it).part.get_pseudo_class(CssStr::selected))
							return;
						(*it).part.set_pseudo_class(CssStr::hover, true);
						(*it).part.set_pseudo_class(CssStr::normal, false);
						component->request_repaint();
						msg->consumed = true;
					}
					else if ((*it).part.get_pseudo_class(CssStr::hover))
					{
						(*it).part.set_pseudo_class(CssStr::hover, false);
						(*it).part.set_pseudo_class(CssStr::normal, true);						
						component->request_repaint();
						msg->consumed = true;
					}
				}
			}
			else if (e.type == InputEvent::pressed && e.id == keycode_left)
			{
				int next_page = selected_page - 1;
				if (next_page < 0)
					next_page = tabs.size()-1;

				unselect_all();
				select_page(next_page);

				if (!func_page_selected.is_null())
					func_page_selected.invoke(tabs[next_page].tab_page);

				component->select_page(next_page);
				msg->consumed = true;
			}
			else if (e.type == InputEvent::pressed && e.id == keycode_right)
			{
				int next_page = selected_page + 1;
				if (next_page >= tabs.size())
					next_page = 0;

				unselect_all();
				select_page(next_page);

				if (!func_page_selected.is_null())
					func_page_selected.invoke(tabs[next_page].tab_page);

				component->request_repaint();
				msg->consumed = true;
			}
			else if (e.type == InputEvent::pressed && (e.id == keycode_up || e.id == keycode_down))
			{
				// block focus switching with up/down when in tab header.
				msg->consumed = true;
			}
		}
		std::shared_ptr<GUIMessage_Pointer> pointer = std::dynamic_pointer_cast<GUIMessage_Pointer>(msg);
		if (pointer)
		{
			
			if (pointer->pointer_type == GUIMessage_Pointer::pointer_leave)
			{
				std::vector<Handle>::iterator it;
				for (it = tabs.begin(); it != tabs.end(); ++it)
				{
					(*it).part.set_pseudo_class(CssStr::hover, false);
					(*it).part.set_pseudo_class(CssStr::normal, true);
				}
				component->request_repaint();
			}
		}
		std::shared_ptr<GUIMessage_FocusChange> focus_change_msg = std::dynamic_pointer_cast<GUIMessage_FocusChange>(msg);
		if (focus_change_msg)
		{
			
			if (focus_change_msg->focus_type == GUIMessage_FocusChange::gained_focus)
			{
				component->set_pseudo_class(CssStr::focused, true);
				component->request_repaint();
			}
			else 
			{
				component->set_pseudo_class(CssStr::focused, false);
				component->request_repaint();
			}
			msg->consumed = true;
		}
	}
}
void ObjectDiagramView::mousePressEvent(QMouseEvent * e)
{
    if (!window()->frozen()) {
        QPoint diagramPoint(e->x(), e->y());
        QPointF scenePoint = mapToScene(diagramPoint);
        if (e->button() == ::Qt::RightButton)
            DiagramView::mousePressEvent(e);
        else {
            UmlCode c = window()->buttonOn();

            switch (c) {
            case UmlClass: {
                history_protected = FALSE;
                unselect_all();
                window()->selectOn();
                history_save();

                BrowserNode * parent =
                    ((BrowserNode *) window()->browser_diagram()->parent());
                BrowserClass * b =
                    BrowserClass::get_class(parent);

                if (b != 0) {
                    BrowserClassInstance * i =
                        new BrowserClassInstance("", b, parent);
                    OdClassInstCanvas * cl =
                        new OdClassInstCanvas(i, the_canvas(), scenePoint.x(), scenePoint.y(), 0);

                    cl->show();
                    cl->upper();
                    window()->package_modified();
                }
            }

            canvas()->update();
            break;

            case UmlClassInstance: {
                history_protected = TRUE;
                unselect_all();
                window()->selectOn();
                history_save();

                BrowserNode * parent =
                    ((BrowserNode *) window()->browser_diagram()->parent());
                BrowserClassInstance * b =
                    BrowserClassInstance::get_classinstance(parent);

                if (b != 0) {
                    OdClassInstCanvas * cl =
                        new OdClassInstCanvas(b, the_canvas(), scenePoint.x(), scenePoint.y(), 0);

                    cl->show();
                    cl->upper();
                    window()->package_modified();
                }
            }

            canvas()->update();
            history_protected = FALSE;
            break;

            default:
                DiagramView::mousePressEvent(e);
                break;
            }
        }
    }
    else
        DiagramView::mousePressEvent(e);
}
Esempio n. 8
0
void UseCaseDiagramView::contentsMousePressEvent(QMouseEvent * e) {
  if (!window()->frozen()) {
    UmlCode action = window()->buttonOn();
    
    switch (action) {
    case UmlClass:
      {
	history_protected = TRUE;
	unselect_all();
	window()->selectOn();
	history_save();
	
	BrowserNode * b = 
	  BrowserClass::get_class(((BrowserNode *) window()->browser_diagram()->parent()),
				  "actor");
	
	if (b != 0) {
	  UcClassCanvas * uc = 
	    new UcClassCanvas(b, the_canvas(), e->x(), e->y(), 0);
	  
	  uc->show();
	  uc->upper();
	  window()->package_modified();
	}
      }
      break;
    case UmlUseCase:
      {
	history_protected = TRUE;
	unselect_all();
	window()->selectOn();
	history_save();
	
	BrowserNode * b = 
	  BrowserUseCase::get_use_case(((BrowserNode *) window()->browser_diagram()->parent()));
	
	if (b != 0) {
	  UcUseCaseCanvas * uc = 
	    new UcUseCaseCanvas(b, the_canvas(), e->x(), e->y(), 0);
	  uc->show();
	  uc->upper();
	  window()->package_modified();
	}
      }
      break;
      case UmlSubject:
	{
	  unselect_all();
	  window()->selectOn();
	  history_save();
	  
	  SubjectCanvas * f = 
	    new SubjectCanvas(the_canvas(), e->x(), e->y(), 0);
	  
	  f->show();
	  f->upper();
	  window()->package_modified();
	}
	break;
    default:
      DiagramView::contentsMousePressEvent(e);
      return;
    }
    
    canvas()->update();
    history_protected = FALSE;
  }
  else
    DiagramView::contentsMousePressEvent(e);
}
Esempio n. 9
0
void DeploymentDiagramView::contentsMousePressEvent(QMouseEvent * e) {
  if (!window()->frozen()) {
    UmlCode action = window()->buttonOn();
    
    switch (action) {
    case UmlDeploymentNode:
      {
	history_protected = TRUE;
	unselect_all();
	window()->selectOn();
	history_save();
	
	BrowserNode * b = 
	  BrowserDeploymentNode::get_deploymentnode(((BrowserNode *) window()->browser_diagram()->parent()));
	
	if (b != 0) {
	  DeploymentNodeCanvas * d = 
	    new DeploymentNodeCanvas(b, the_canvas(), e->x(), e->y(), 0);
	  
	  d->show();
	  d->upper();
	  window()->package_modified();
	}
      }
      break;
    case UmlComponent:
      {
	history_protected = TRUE;
	unselect_all();
	window()->selectOn();
	history_save();
	
	BrowserNode * b = 
	  BrowserComponent::get_component(((BrowserNode *) window()->browser_diagram()->parent()),
					  TRUE);
	
	if (b != 0) {
	  ComponentCanvas * c = 
	    new ComponentCanvas(b, the_canvas(), e->x(), e->y());
	  
	  c->show();
	  c->upper();
	  window()->package_modified();
	}
      }
      break;
    case UmlArtifact:
      {
	history_protected = TRUE;
	unselect_all();
	window()->selectOn();
	history_save();
	
	BrowserNode * b = 
	  BrowserArtifact::get_artifact(((BrowserNode *) window()->browser_diagram()->parent()),
					 TRUE);
	
	if (b != 0) {
	  ArtifactCanvas * c = 
	    new ArtifactCanvas(b, the_canvas(), e->x(), e->y());
	  
	  c->show();
	  c->upper();
	  window()->package_modified();
	}
      }
      break;
    case UmlHub:
      {
	history_protected = TRUE;
	unselect_all();
	window()->selectOn();
	history_save();
	
	HubCanvas * h = new HubCanvas(the_canvas(), e->x(), e->y(), 0);
	
	h->show();
	h->upper();
	window()->package_modified();
      }
      break;
    default:
      DiagramView::contentsMousePressEvent(e);
      return;
    }
    
    canvas()->update();
    history_protected = FALSE;
  }
  else
    DiagramView::contentsMousePressEvent(e);
}
Esempio n. 10
0
void ToolBar_Impl::on_process_message(std::shared_ptr<GUIMessage> &msg)
{
    if (!toolbar->is_enabled())
        return;

    std::shared_ptr<GUIMessage_Input> input_msg = std::dynamic_pointer_cast<GUIMessage_Input>(msg);
    if (input_msg)
    {

        const InputEvent &e = input_msg->input_event;

        if (e.type == InputEvent::released && e.id == mouse_right)
        {
            int index = find_item_at(e.mouse_pos);
            if (!func_mouse_right_up.is_null())
                func_mouse_right_up.invoke(e.mouse_pos, index);
        }
        else if (mouse_mode == mouse_mode_normal)
        {
            int index = find_item_at(e.mouse_pos);
            if (index == -1)
            {
                if (index_hot_item != -1)
                {
                    index_hot_item = -1;
                    toolbar->request_repaint();
                }
                return;
            }

            if (e.type == InputEvent::pressed && e.id == mouse_left)
            {
                index_hot_item = -1;
                index_pressed_item = index;
                mouse_mode = mouse_mode_pressed;
                toolbar->request_repaint();
                toolbar->capture_mouse(true);
            }
            else
            {
                index_hot_item = index;
                toolbar->request_repaint();
            }
        }
        else if (mouse_mode == mouse_mode_pressed)
        {
            if (e.type == InputEvent::released && e.id == mouse_left)
            {
                toolbar->capture_mouse(false);
                mouse_mode = mouse_mode_normal;

                int index = find_item_at(e.mouse_pos);
                bool perform_click = (index == index_pressed_item);
                bool pressed_state = items[index_pressed_item].is_pressed();

                if (pressed_state == true && single_select_mode)
                {
                    return;
                }

                if (items[index_pressed_item].impl->toggling && perform_click)
                    items[index_pressed_item].impl->pressed = !items[index_pressed_item].impl->pressed;

                index_pressed_item = -1;
                index_hot_item = index;
                toolbar->request_repaint();

                if (perform_click)
                {
                    if (!func_item_clicked.is_null())
                        func_item_clicked.invoke(items[index]);

                    if (items[index].is_toggling() && single_select_mode)
                    {
                        unselect_all(items[index].impl.get());

                        if (!func_item_selected.is_null())
                            func_item_selected.invoke(items[index]);
                    }
                }
            }
        }
    }
    std::shared_ptr<GUIMessage_Pointer> pointer = std::dynamic_pointer_cast<GUIMessage_Pointer>(msg);
    if (pointer)
    {

        if (pointer->pointer_type == GUIMessage_Pointer::pointer_leave)
        {
            if (index_hot_item != -1)
            {
                index_hot_item = -1;
                toolbar->request_repaint();
            }
        }
    }
}
Esempio n. 11
0
void ActivityDiagramView::contentsMousePressEvent(QMouseEvent * e)
{
    if (!window()->frozen()) {
        UmlCode action = window()->buttonOn();

        switch (action) {
        case UmlActivity: {
            history_protected = TRUE;
            unselect_all();
            window()->selectOn();
            history_save();

            BrowserNode * b =
                BrowserActivity::get_activity((BrowserNode *) window()->browser_diagram()->parent()->parent());

            if (b != 0) {
                if (the_canvas()->already_drawn(b)) {
                    msg_information("Douml", TR("already drawn"));
                    history_protected = FALSE;
                    return;
                }

                ActivityCanvas * c =
                    new ActivityCanvas(b, the_canvas(), e->x(), e->y());

                c->show();
                c->upper();
                history_protected = TRUE;
                c->force_sub_inside(TRUE);
                window()->package_modified();
            }
        }
        break;

        case UmlInterruptibleActivityRegion: {
            history_protected = TRUE;
            unselect_all();
            window()->selectOn();
            history_save();

            BrowserNode * parent = container(e->pos());
            BrowserNode * b =
                BrowserInterruptibleActivityRegion::get_interruptibleactivityregion(parent);

            if (b != 0) {
                if (the_canvas()->already_drawn(b)) {
                    msg_information("Douml", TR("already drawn"));
                    history_protected = FALSE;
                    return;
                }

                InterruptibleActivityRegionCanvas * c =
                    new InterruptibleActivityRegionCanvas(b, the_canvas(), e->x(), e->y());
                bool rz;

                c->show();
                history_protected = TRUE;
                rz = !ActivityContainerCanvas::force_inside(c, FALSE);
                history_protected = TRUE;
                c->force_sub_inside(rz);
                window()->package_modified();
            }
        }
        break;

        case UmlExpansionRegion: {
            history_protected = TRUE;
            unselect_all();
            window()->selectOn();
            history_save();

            BrowserNode * parent = container(e->pos());
            BrowserNode * b =
                BrowserExpansionRegion::get_expansionregion(parent);

            if (b != 0) {
                if (the_canvas()->already_drawn(b)) {
                    msg_information("Douml", TR("already drawn"));
                    history_protected = FALSE;
                    return;
                }

                ExpansionRegionCanvas * c =
                    new ExpansionRegionCanvas(b, the_canvas(), e->x(), e->y());
                bool rz;

                c->show();
                history_protected = TRUE;
                rz = !ActivityContainerCanvas::force_inside(c, FALSE);
                history_protected = TRUE;
                c->force_sub_inside(rz);
                window()->package_modified();
            }
        }
        break;

        case InitialAN:
        case ActivityFinalAN:
        case FlowFinalAN:
        case DecisionAN:
        case MergeAN:
        case ForkAN:
        case JoinAN: {
            history_protected = TRUE;
            unselect_all();
            window()->selectOn();
            history_save();

            BrowserNode * parent = container(e->pos());
            BrowserNode * b = BrowserActivityNode::get_activitynode(parent, action);

            if (b != 0) {
                // a new element, don't check already drawn
                ActivityNodeCanvas * c =
                    new ActivityNodeCanvas(b, the_canvas(), e->x(), e->y());

                c->show();
                (void) ActivityContainerCanvas::force_inside(c, FALSE);
                history_protected = TRUE;
                window()->package_modified();
            }
        }
        break;

        case UmlActivityAction: {
            history_protected = TRUE;
            unselect_all();
            window()->selectOn();
            history_save();

            BrowserNode * parent = container(e->pos());
            BrowserNode * b = BrowserActivityAction::get_activityaction(parent);

            if (b != 0) {
                history_protected = TRUE;

                if (the_canvas()->already_drawn(b)) {
                    msg_information("Douml", TR("already drawn"));
                    history_protected = FALSE;
                    return;
                }

                ActivityActionCanvas * c =
                    new ActivityActionCanvas(b, the_canvas(), e->x(), e->y());

                c->show();
                (void) ActivityContainerCanvas::force_inside(c, FALSE);
                history_protected = TRUE;
                c->upper();
                window()->package_modified();
            }
        }
        break;

        case UmlActivityObject: {
            history_protected = TRUE;
            unselect_all();
            window()->selectOn();
            history_save();

            BrowserNode * parent = container(e->pos());
            BrowserNode * b = BrowserActivityObject::get_activityobject(parent);

            if (b != 0) {
                if (the_canvas()->already_drawn(b)) {
                    msg_information("Douml", TR("already drawn"));
                    history_protected = FALSE;
                    return;
                }

                history_protected = TRUE;

                ActivityObjectCanvas * c =
                    new ActivityObjectCanvas(b, the_canvas(), e->x(), e->y());

                c->show();
                (void) ActivityContainerCanvas::force_inside(c, FALSE);
                history_protected = TRUE;
                c->upper();
                window()->package_modified();
            }
        }
        break;

        case UmlActivityPartition: {
            history_protected = TRUE;
            unselect_all();
            window()->selectOn();
            history_save();

            BrowserNode * parent = container(e->pos(), TRUE);
            BrowserNode * b =
                BrowserActivityPartition::get_activitypartition(parent);

            if (b != 0) {
                if (the_canvas()->already_drawn(b)) {
                    msg_information("Douml", TR("already drawn"));
                    history_protected = FALSE;
                    return;
                }

                ActivityPartitionCanvas * c =
                    new ActivityPartitionCanvas(b, the_canvas(), e->x(), e->y());
                bool rz;

                c->show();
                history_protected = TRUE;
                rz = !ActivityContainerCanvas::force_inside(c, TRUE);
                history_protected = TRUE;
                c->force_sub_inside(rz);
                window()->package_modified();
            }
        }
        break;

        default:
            DiagramView::contentsMousePressEvent(e);
            return;
        }

        canvas()->update();
        history_protected = FALSE;
    }
    else
        DiagramView::contentsMousePressEvent(e);
}
Esempio n. 12
0
void ColDiagramView::contentsMousePressEvent(QMouseEvent * e)
{
    if (!window()->frozen()) {
        if (e->button() == ::Qt::RightButton)
            DiagramView::contentsMousePressEvent(e);
        else {
            UmlCode c = window()->buttonOn();

            switch (c) {
            case UmlClass: {
                history_protected = FALSE;
                unselect_all();
                window()->selectOn();
                history_save();

                BrowserNode * parent =
                    ((BrowserNode *) window()->browser_diagram()->parent());
                BrowserClass * b =
                    BrowserClass::get_class(parent);

                if (b != 0) {
                    CodClassInstCanvas * cl =
                        new CodClassInstCanvas(b, the_canvas(),
                                               e->x(), e->y(), 0);

                    cl->show();
                    cl->upper();
                    window()->package_modified();
                }
            }

            canvas()->update();
            break;

            case UmlClassInstance: {
                history_protected = TRUE;
                unselect_all();
                window()->selectOn();
                history_save();

                BrowserNode * parent =
                    ((BrowserNode *) window()->browser_diagram()->parent());
                BrowserClassInstance * b =
                    BrowserClassInstance::get_classinstance(parent);

                if (b != 0) {
                    CodClassInstCanvas * cl =
                        new CodClassInstCanvas(b, the_canvas(),
                                               e->x(), e->y(), 0);

                    cl->show();
                    cl->upper();
                    window()->package_modified();
                }
            }

            canvas()->update();
            history_protected = FALSE;
            break;

            case UmlSelfLink: {
                history_protected = TRUE;
                window()->selectOn();
                history_save();

                Q3CanvasItem * ci = the_canvas()->collision(e->pos());

                if (ci != 0) {
                    DiagramItem * i = QCanvasItemToDiagramItem(ci);

                    if (i != 0) {
                        QString err = i->may_start(c);

                        if (!err.isEmpty())
                            msg_critical("Douml", err);
                        else {
                            i->connexion(c, i, e->pos(), e->pos());
                            window()->package_modified();
                        }
                    }
                }
            }

            canvas()->update();
            history_protected = FALSE;
            break;

            default:
                DiagramView::contentsMousePressEvent(e);
                break;
            }
        }
    }
    else
        DiagramView::contentsMousePressEvent(e);
}
Esempio n. 13
0
void SeqDiagramView::mousePressEvent(QMouseEvent * e)
{
    if (!window()->frozen()) {
        if (e->button() == ::Qt::RightButton)
            DiagramView::mousePressEvent(e);
        else {
            QPoint diagramPoint(e->x(), e->y());
            QPointF scenePoint = mapToScene(diagramPoint);
            UmlCode c = window()->buttonOn();

            switch (c) {
            case UmlClass: {
                history_protected = FALSE;
                unselect_all();
                window()->selectOn();
                history_save();

                BrowserNode * parent =
                        ((BrowserNode *) window()->browser_diagram()->parent());
                BrowserClass * b =
                        BrowserClass::get_class(parent);
                if (b != 0) {
                    SdClassInstCanvas * cli =
                            new SdClassInstCanvas(b, the_canvas(), scenePoint.x(), 0);

                    cli->show();
                    cli->moveBy(scenePoint.x() - cli->center().x(), 0);
                    cli->upper();
                    window()->package_modified();
                }
            }
                break;

            case UmlClassInstance: {
                history_protected = TRUE;
                unselect_all();
                window()->selectOn();
                history_save();

                BrowserNode * parent =
                        ((BrowserNode *) window()->browser_diagram()->parent());
                BrowserClassInstance * b =
                        BrowserClassInstance::get_classinstance(parent);
                if (b != 0) {
                    SdClassInstCanvas * cli =
                            new SdClassInstCanvas(b, the_canvas(), scenePoint.x(), 0);

                    cli->show();
                    cli->moveBy(scenePoint.x() - cli->center().x(), 0);
                    cli->upper();
                    window()->package_modified();
                }
            }
                break;

            case UmlSyncSelfMsg:
            case UmlAsyncSelfMsg:
            case UmlSelfReturnMsg: {
                history_protected = TRUE;
                unselect_all();
                window()->selectOn();
                history_save();

                QGraphicsItem * ci = the_canvas()->collision(scenePoint.toPoint());

                if (ci != 0) {
                    DiagramItem * i = QCanvasItemToDiagramItem(ci);

                    if (i != 0) {
                        QString err = i->may_start(c);

                        if (!err.isEmpty())
                            msg_critical("Douml" , err);
                        else {
                            i->connexion(c, i, scenePoint.toPoint(), scenePoint.toPoint());
                            window()->package_modified();
                        }
                    }
                }
            }
                break;

            case UmlContinuation: {
                history_protected = TRUE;
                unselect_all();
                window()->selectOn();
                history_save();
                SdContinuationCanvas * cont =
                        new SdContinuationCanvas(the_canvas(), scenePoint.x(), scenePoint.y(), 0);
                cont->show();
                cont->upper();
                window()->package_modified();
            }
                break;

            default:
                DiagramView::mousePressEvent(e);
                return;
            }

            canvas()->update();
            history_protected = FALSE;
        }
    }
    else
        DiagramView::mousePressEvent(e);
}