Exemplo n.º 1
0
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();
    }
}
Exemplo n.º 2
0
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);
}
Exemplo n.º 3
0
OdClassInstCanvas * OdClassInstCanvas::read(char * & st, UmlCanvas * canvas,
					      char * k)
{
  if (!strcmp(k, "classinstance_ref"))
    return ((OdClassInstCanvas *) dict_get(read_id(st), "classinstance", canvas));
  else if (!strcmp(k, "classinstance")) {
    // old release
    int id = read_id(st);
    BrowserClass * cl = BrowserClass::read_ref(st);
    
    k = read_keyword(st);
    
    UmlColor co = UmlDefaultColor;
    
    read_color(st, "color", co, k);	// updates k
    
    Uml3States ho;
    
    if (!strcmp(k, "write_horizontally") || 
	!strcmp(k, "write_horizontaly")) {
      ho = state(read_keyword(st));
      k = read_keyword(st);
    }
    else
      ho = UmlDefaultState;
    
    if (strcmp(k, "xyz"))
      wrong_keyword(k, "xyz");
    
    int x = (int) read_double(st);
    int y = (int) read_double(st);
    double z = read_double(st);
    
    read_keyword(st, "name");

    BrowserNode * parent =
      canvas->browser_diagram()->container(UmlClass);
    BrowserClassInstance * icl =
      // create a new one, don't look at already exising instances
      // contrarilly to the collaboration and sequence diagram
      // because of attributes & relations
      new BrowserClassInstance(read_string(st), cl, parent);
    OdClassInstCanvas * result =
      new OdClassInstCanvas(icl, canvas, x, y, id);

    result->setZ(z);    
    result->itscolor = co;
    result->write_horizontally = ho;
    result->show_context_mode = noContext;
    
    k = read_keyword(st);
    
    if (!strcmp(k, "values")) 
      ((ClassInstanceData *) icl->get_data())->read_attributes(st, k);	// updates k
    else if (strcmp(k, "end") && 
	     strcmp(k, "xyz"))
      wrong_keyword(k, "end or xyz");
    
    if (*k == 'x')
      read_xyz(st, result);
    result->compute_size();
    result->set_center100();
    result->show();
    
    // to save new instance and diagram def
    result->package_modified();
    canvas->browser_diagram()->modified();
    
    return result;
  }
  else if (!strcmp(k, "classinstancecanvas")) {
    int id = read_id(st);
    BrowserClassInstance * icl = BrowserClassInstance::read_ref(st);
    
    read_keyword(st, "xyz");
    
    int x = (int) read_double(st);
    OdClassInstCanvas * result =
      new OdClassInstCanvas(icl, canvas, x, (int) read_double(st), id);

    result->setZ(read_double(st));
        
    result->ClassInstCanvas::read(st, k);
    if (read_file_format() < 74)
      result->show_context_mode = noContext;
    
    result->read_stereotype_property(st, k);	// updates k
    
    if (strcmp(k, "end"))
      wrong_keyword(k, "end");

    if (result->get_type() != 0) {
      // not a deleted instance
      result->compute_size();
      result->set_center100();
      result->show();
      result->check_stereotypeproperties();
    }
    return result;
  }
  else
    return 0;
}