void ComponentDiagramView::dropEvent(QDropEvent * e) { BrowserNode * bn; QPoint p = viewportToContents(e->pos()); if ((bn = UmlDrag::decode(e, UmlComponent)) != 0) { history_save(); ComponentCanvas * c = new ComponentCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); c->upper(); canvas()->update(); history_protected = FALSE; window()->package_modified(); } else if ((bn = UmlDrag::decode(e, UmlPackage)) != 0) { history_save(); PackageCanvas * pk = new PackageCanvas(bn, the_canvas(), p.x(), p.y(), 0); history_protected = TRUE; pk->show(); pk->upper(); canvas()->update(); window()->package_modified(); } else if ((bn = UmlDrag::decode(e, UmlSimpleRelations, TRUE)) != 0) { history_save(); history_protected = TRUE; SimpleRelationCanvas::drop(bn, the_canvas()); canvas()->update(); history_protected = FALSE; } else if (((bn = UmlDrag::decode(e, UmlClassDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlUseCaseDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlSeqDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlColDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlObjectDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlComponentDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlDeploymentDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlStateDiagram, TRUE)) != 0) || ((bn = UmlDrag::decode(e, UmlActivityDiagram, TRUE)) != 0)) { history_save(); IconCanvas * ic = new IconCanvas(bn, the_canvas(), p.x(), p.y(), 0); history_protected = TRUE; ic->show(); ic->upper(); canvas()->update(); history_protected = FALSE; window()->package_modified(); } }
void SeqDiagramView::dropEvent(QDropEvent * e) { BrowserNode * bn; QPointF p = mapToScene(e->pos()); if ((bn = UmlDrag::decode(e, UmlClassInstance)) != 0) { history_save(); SdClassInstCanvas * cli = new SdClassInstCanvas((BrowserClassInstance *) bn, the_canvas(), p.x(), 0); history_protected = TRUE; cli->show(); cli->moveBy(p.x() - cli->center().x(), 0); canvas()->update(); history_protected = FALSE; window()->package_modified(); } else if ((bn = UmlDrag::decode(e, UmlClass)) != 0) { history_save(); SdClassInstCanvas * cli = new SdClassInstCanvas(bn, the_canvas(), p.x(), 0); history_protected = TRUE; cli->show(); cli->moveBy(p.x() - cli->center().x(), 0); canvas()->update(); history_protected = FALSE; window()->package_modified(); } else if (((bn = UmlDrag::decode(e, UmlClassDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlUseCaseDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlSeqDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlColDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlObjectDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlComponentDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlDeploymentDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlStateDiagram, TRUE)) != 0) || ((bn = UmlDrag::decode(e, UmlActivityDiagram, TRUE)) != 0)) { history_save(); IconCanvas * ic = new IconCanvas(bn, the_canvas(), p.x(), p.y(), 0); history_protected = TRUE; ic->show(); ic->upper(); canvas()->update(); history_protected = FALSE; window()->package_modified(); } }
IconCanvas * IconCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "iconcanvas")) { int id = read_id(st); BrowserNode * bn = BrowserDiagram::read_diagram_ref(st); IconCanvas * result = new IconCanvas(bn, canvas, 0, 0, id); read_keyword(st, "xyz"); read_xyz(st, result); result->set_center100(); result->show(); return result; } else return 0; }
void StateDiagramView::dropEvent(QDropEvent * e) { BrowserState * mach = BrowserState::get_machine(the_canvas()->browser_diagram()); BrowserNode * bn; QPointF p = mapToScene(e->pos()); if ((bn = UmlDrag::decode(e, UmlState, TRUE)) != 0) { if (the_canvas()->already_drawn(bn)) msg_information("Douml", TR("already drawn")); else if (BrowserState::get_machine(bn) != mach) msg_information("Douml", TR("illegal")); else { history_save(); // mettre des contraintes sur la validite ? StateCanvas * c = new StateCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); c->upper(); canvas()->update(); StateCanvas::force_inside(c, TRUE); canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlPackage)) != 0) { history_save(); PackageCanvas * pk = new PackageCanvas(bn, the_canvas(), p.x(), p.y(), 0); history_protected = TRUE; pk->show(); pk->upper(); canvas()->update(); window()->package_modified(); } else if ((bn = UmlDrag::decode(e, UmlPseudoState, TRUE)) != 0) { if (the_canvas()->already_drawn(bn)) msg_information("Douml", TR("already drawn")); else if (BrowserState::get_machine(bn) != mach) msg_information("Douml", TR("illegal")); else { history_save(); // mettre des contraintes sur la validite ? PseudoStateCanvas * c = new PseudoStateCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); c->upper(); StateCanvas::force_inside(c, FALSE); canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlStateAction, TRUE)) != 0) { if (the_canvas()->already_drawn(bn)) msg_information("Douml", TR("already drawn")); else if (BrowserState::get_machine(bn) != mach) msg_information("Douml", TR("illegal")); else { history_save(); // mettre des contraintes sur la validite ? StateActionCanvas * c = new StateActionCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); c->upper(); StateCanvas::force_inside(c, FALSE); canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlTransition, TRUE)) != 0) { history_save(); history_protected = TRUE; TransitionCanvas::drop(bn, the_canvas()); canvas()->update(); history_protected = FALSE; } else if (((bn = UmlDrag::decode(e, UmlClassDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlUseCaseDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlSeqDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlColDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlObjectDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlStateDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlComponentDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlDeploymentDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlStateDiagram, TRUE)) != 0) || ((bn = UmlDrag::decode(e, UmlActivityDiagram, TRUE)) != 0)) { history_save(); IconCanvas * ic = new IconCanvas(bn, the_canvas(), p.x(), p.y(), 0); history_protected = TRUE; ic->show(); ic->upper(); canvas()->update(); history_protected = FALSE; window()->package_modified(); } }
void ObjectDiagramView::dropEvent(QDropEvent * e) { BrowserNode * bn; QPointF p = mapToScene(e->pos()); if ((bn = UmlDrag::decode(e, UmlClassInstance)) != 0) { history_save(); OdClassInstCanvas * i = new OdClassInstCanvas((BrowserClassInstance *) bn, the_canvas(), p.x(), p.y(), 0); history_protected = TRUE; i->show(); i->upper(); canvas()->update(); history_protected = FALSE; window()->package_modified(); } else if ((bn = UmlDrag::decode(e, UmlClass)) != 0) { history_save(); BrowserNode * parent = ((BrowserNode *) window()->browser_diagram()->parent()); BrowserClassInstance * cli = new BrowserClassInstance("", (BrowserClass *) bn, parent); OdClassInstCanvas * i = new OdClassInstCanvas(cli, the_canvas(), p.x(), p.y(), 0); history_protected = TRUE; i->show(); i->upper(); canvas()->update(); history_protected = FALSE; window()->package_modified(); } else if ((bn = UmlDrag::decode(e, UmlPackage)) != 0) { history_save(); PackageCanvas * pk = new PackageCanvas(bn, the_canvas(), p.x(), p.y(), 0); history_protected = TRUE; pk->show(); pk->upper(); canvas()->update(); window()->package_modified(); } else if (((bn = UmlDrag::decode(e, UmlClassDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlUseCaseDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlSeqDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlObjectDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlComponentDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlDeploymentDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlStateDiagram, TRUE)) != 0) || ((bn = UmlDrag::decode(e, UmlActivityDiagram, TRUE)) != 0)) { history_save(); IconCanvas * ic = new IconCanvas(bn, the_canvas(), p.x(), p.y(), 0); history_protected = TRUE; ic->show(); ic->upper(); canvas()->update(); history_protected = FALSE; window()->package_modified(); } }
void ActivityDiagramView::dropEvent(QDropEvent * e) { BrowserNode * bn; QPoint p = viewportToContents(e->pos()); if ((bn = UmlDrag::decode(e, UmlActivity, TRUE)) != 0) { Q3PopupMenu m(0); MenuFactory::createTitle(m, TR("Choose")); m.insertSeparator(); if (!the_canvas()->already_drawn(bn)) m.insertItem(TR("Draw activity"), 0); m.insertItem(TR("Add a call behavior"), 1); switch (m.exec(QCursor::pos())) { case 0: { history_save(); history_protected = TRUE; ActivityCanvas * c = new ActivityCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); c->upper(); history_protected = TRUE; c->force_sub_inside(TRUE); canvas()->update(); history_protected = FALSE; window()->package_modified(); } break; case 1: { bn = BrowserActivityAction::add_call_behavior(container(p), bn); if (bn != 0) { history_save(); history_protected = TRUE; ActivityActionCanvas * c = new ActivityActionCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } break; default: break; } } else if ((bn = UmlDrag::decode(e, UmlPackage)) != 0) { history_save(); PackageCanvas * pk = new PackageCanvas(bn, the_canvas(), p.x(), p.y(), 0); history_protected = TRUE; pk->show(); pk->upper(); canvas()->update(); history_protected = FALSE; window()->package_modified(); } else if ((bn = UmlDrag::decode(e, UmlActivityNode, TRUE)) != 0) { if (the_canvas()->already_drawn(bn)) msg_information("Douml", TR("already drawn")); else { history_save(); ActivityNodeCanvas * c = new ActivityNodeCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlInterruptibleActivityRegion, TRUE)) != 0) { if (the_canvas()->already_drawn(bn)) msg_information("Douml", TR("already drawn")); else { history_save(); history_protected = TRUE; InterruptibleActivityRegionCanvas * c = new InterruptibleActivityRegionCanvas(bn, the_canvas(), p.x(), p.y()); bool sz; history_protected = TRUE; c->show(); sz = !ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; c->force_sub_inside(sz); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlExpansionRegion, TRUE)) != 0) { if (the_canvas()->already_drawn(bn)) msg_information("Douml", TR("already drawn")); else { history_save(); history_protected = TRUE; ExpansionRegionCanvas * c = new ExpansionRegionCanvas(bn, the_canvas(), p.x(), p.y()); bool sz; history_protected = TRUE; c->show(); sz = !ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; c->force_sub_inside(sz); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlActivityPartition, TRUE)) != 0) { if (the_canvas()->already_drawn(bn)) msg_information("Douml", TR("already drawn")); else { history_save(); history_protected = TRUE; ActivityPartitionCanvas * c = new ActivityPartitionCanvas(bn, the_canvas(), p.x(), p.y()); bool sz; history_protected = TRUE; c->show(); sz = !ActivityContainerCanvas::force_inside(c, TRUE); history_protected = TRUE; c->force_sub_inside(sz); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlActivityAction, TRUE)) != 0) { if (the_canvas()->already_drawn(bn)) msg_information("Douml", TR("already drawn")); else { history_save(); history_protected = TRUE; ActivityActionCanvas * c = new ActivityActionCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlActivityObject, TRUE)) != 0) { if (the_canvas()->already_drawn(bn)) msg_information("Douml", TR("already drawn")); else { history_save(); history_protected = TRUE; ActivityObjectCanvas * c = new ActivityObjectCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlFlow, TRUE)) != 0) { history_save(); history_protected = TRUE; FlowCanvas::drop(bn, the_canvas()); canvas()->update(); history_protected = FALSE; } else if ((bn = UmlDrag::decode(e, UmlSimpleRelations, TRUE)) != 0) { history_save(); history_protected = TRUE; SimpleRelationCanvas::drop(bn, the_canvas()); canvas()->update(); history_protected = FALSE; } else if (((bn = UmlDrag::decode(e, UmlClassDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlUseCaseDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlSeqDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlColDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlObjectDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlActivityDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlComponentDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlDeploymentDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlStateDiagram, TRUE)) != 0) || ((bn = UmlDrag::decode(e, UmlActivityDiagram, TRUE)) != 0)) { history_save(); IconCanvas * ic = new IconCanvas(bn, the_canvas(), p.x(), p.y(), 0); history_protected = TRUE; ic->show(); ic->upper(); canvas()->update(); history_protected = FALSE; window()->package_modified(); } else if ((bn = UmlDrag::decode(e, UmlOperation)) != 0) { bn = BrowserActivityAction::add_call_operation(container(p), (BrowserOperation *) bn); if (bn != 0) { history_save(); history_protected = TRUE; ActivityActionCanvas * c = new ActivityActionCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if (((bn = UmlDrag::decode(e, UmlAttribute)) != 0) || ((bn = UmlDrag::decode(e, UmlRelations, TRUE)) != 0)) { Q3PopupMenu m(0); MenuFactory::createTitle(m, TR("Choose")); m.insertSeparator(); m.insertItem(TR("Add a read variable value action"), 0); m.insertItem(TR("Add a clear variable value action"), 1); m.insertItem(TR("Add a write variable value action"), 2); m.insertItem(TR("Add a add variable value action"), 3); m.insertItem(TR("Add a remove variable value action"), 4); switch (m.exec(QCursor::pos())) { case 0: bn = BrowserActivityAction::add_read_variable_value(container(p), bn); break; case 1: bn = BrowserActivityAction::add_clear_variable_value(container(p), bn); break; case 2: bn = BrowserActivityAction::add_write_variable_value(container(p), bn); break; case 3: bn = BrowserActivityAction::add_add_variable_value(container(p), bn); break; case 4: bn = BrowserActivityAction::add_remove_variable_value(container(p), bn); break; default: return; } if (bn != 0) { history_save(); history_protected = TRUE; ActivityActionCanvas * c = new ActivityActionCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlClass)) != 0) { history_protected = FALSE; BrowserActivityObject * obj = BrowserActivityObject::add_activityobject(container(p), 0); if (obj != 0) { ((ActivityObjectData *) obj->get_data())->set_type((BrowserClass *) bn); history_save(); history_protected = TRUE; ActivityObjectCanvas * c = new ActivityObjectCanvas(obj, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlClassInstance)) != 0) { history_protected = FALSE; BrowserActivityObject * obj = BrowserActivityObject::add_activityobject(container(p), bn->get_name()); if (obj != 0) { ((ActivityObjectData *) obj->get_data()) ->set_type(((ClassInstanceData *) bn->get_data())->get_class()); history_save(); history_protected = TRUE; ActivityObjectCanvas * c = new ActivityObjectCanvas(obj, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlState, TRUE)) != 0) { history_protected = FALSE; bn = BrowserActivityAction::add_call_behavior(container(p), bn); if (bn != 0) { history_save(); history_protected = TRUE; ActivityActionCanvas * c = new ActivityActionCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } }