Exemple #1
0
void ActivityPartitionCanvas::same_drawing_settings(Q3PtrList<DiagramItem> & l) {
  Q3PtrListIterator<DiagramItem> it(l);
  
  ActivityPartitionCanvas * x = (ActivityPartitionCanvas *) it.current();
  
  while (++it, it.current() != 0) {
    ActivityPartitionCanvas * o =  (ActivityPartitionCanvas *) it.current();
				 
    o->itscolor = x->itscolor;
    o->modified();	// call package_modified()
  }
}
Exemple #2
0
ActivityPartitionCanvas * 
  ActivityPartitionCanvas::read(char * & st, UmlCanvas * canvas,
					  char * k)
{
  if (!strcmp(k, "activitypartitioncanvas_ref"))
    return ((ActivityPartitionCanvas *) dict_get(read_id(st), "activitypartitioncanvas", canvas));
  else if (!strcmp(k, "activitypartitioncanvas")) {
    int id = read_id(st);
    BrowserActivityPartition * br =
      BrowserActivityPartition::read_ref(st);
    ActivityPartitionCanvas * result =
      new ActivityPartitionCanvas(canvas, id);
    
    result->browser_node = br;
    connect(br->get_data(), SIGNAL(changed()), result, SLOT(modified()));
    connect(br->get_data(), SIGNAL(deleted()), result, SLOT(deleted()));

    k = read_keyword(st);
    
    read_color(st, "color", result->itscolor, k);	// updates k
    if (! strcmp(k, "horiz")) {
      result->horiz = TRUE;
      k = read_keyword(st);
    }
    result->read_stereotype_property(st, k);	// updates k
    
    if (!strcmp(k, "xyzwh"))
      read_xyzwh(st, result);
    else
      wrong_keyword(k, "xyzwh");
    
    result->check_size();
    result->width_scale100 = result->width();
    result->height_scale100 = result->height();
    result->set_center100();
    result->show();
    result->check_stereotypeproperties();
    
    read_keyword(st, "end");
    
    // result->force_sub_inside() useless
    
    if (canvas->paste())
      result->remove_if_already_present();
    
    return result;
  }
  else 
    return 0;
}
Exemple #3
0
void ActivityPartitionCanvas::turn(int cx100, int cy100)
{
  horiz ^= TRUE;
  setSize(height(), width());
  
  if (cx100 == -1000) {
    // first turn partition
    cx100 = center_x_scale100;
    cy100 = center_y_scale100;
  }
  else {
    int dx = center_x_scale100 - cx100;
    int dy = center_y_scale100 - cy100;
    
    if (horiz) {
      center_x_scale100 = cx100 + dy;
      center_y_scale100 = cy100 - dx;
    }
    else {
      center_x_scale100 = cx100 - dy;
      center_y_scale100 = cy100 + dx;
    }
  }
  
  recenter();
  DiagramCanvas::resize(width(), height());
  
  Q3CanvasItemList all = the_canvas()->allItems();
  Q3CanvasItemList::Iterator cit;
  
  for (cit = all.begin(); cit != all.end(); ++cit) {
    if ((*cit)->visible()) {
      ActivityPartitionCanvas * p = dynamic_cast<ActivityPartitionCanvas *>(*cit);

      if ((p != 0) && 
	  (p->get_bn()->parent() == browser_node) &&
	  (p->horiz != horiz)) {
	p->turn(cx100, cy100);
      }
    }
  }
}
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();
        }
    }
}
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);
}