コード例 #1
0
ファイル: LabelCanvas.cpp プロジェクト: javrillon/douml
LabelCanvas * LabelCanvas::read(char *& st, UmlCanvas * canvas, char * k)
{
    if (strcmp(k, "label"))
        return 0;

    QString s = read_string(st);
    bool bold = FALSE;
    bool italic = FALSE;
    bool underlined = FALSE;

    for (;;) {
        k = read_keyword(st);

        if (!strcmp(k, "bold"))
            bold = TRUE;
        else if (!strcmp(k, "italic"))
            italic = TRUE;
        else if (!strcmp(k, "underlined"))
            underlined = TRUE;
        else
            break;
    }

    int x = (int) read_double(st);

    LabelCanvas * result =
        new LabelCanvas(s, canvas, x, (int) read_double(st),
                        bold, italic, underlined);

    if (!strcmp(k, "xyz"))
        result->setZValue(read_double(st));
    else if (!strcmp(k, "xy"))
        // old version
        ;//result->setZValue(OLD_LABEL_Z);
    else
        wrong_keyword(k, "xyz");

    return result;
}
コード例 #2
0
SimpleRelationCanvas * SimpleRelationCanvas::read(char *& st, UmlCanvas * canvas, char * k)
{
    if (!strcmp(k, "simplerelationcanvas_ref"))
        return ((SimpleRelationCanvas *) dict_get(read_id(st), "simplerelationcanvas", canvas));
    else if (!strcmp(k, "simplerelationcanvas")) {
        int id = read_id(st);
        BrowserSimpleRelation * br = BrowserSimpleRelation::read_ref(st);
        SimpleRelationData * rd = (SimpleRelationData *) br->get_data();
        LineGeometry geo;
        bool fixed;

        k = read_keyword(st);

        if (! strcmp(k, "geometry")) {
            geo = line_geometry(read_keyword(st));
            k = read_keyword(st);

            if (! strcmp(k, "unfixed")) {
                k = read_keyword(st);
                fixed = FALSE;
            }
            else
                fixed = TRUE;
        }
        else {
            geo = NoGeometry;
            fixed = FALSE;
        }

        float dbegin;
        float dend;

        if (! strcmp(k, "decenter_begin")) {
            dbegin = read_double(st) / 1000;
            k = read_keyword(st);
        }
        else
            dbegin = -1;

        if (! strcmp(k, "decenter_end")) {
            dend = read_double(st) / 1000;
            k = read_keyword(st);
        }
        else
            dend = -1;

        unread_keyword(k, st);

        read_keyword(st, "from");
        read_keyword(st, "ref");

        DiagramItem * bi = dict_get(read_id(st), "canvas", canvas);
        BrowserNode * b = rd->get_start_node();
        UmlCode t = rd->get_type();
        SimpleRelationCanvas * first = 0;
        SimpleRelationCanvas * result;
        LabelCanvas * stereotype;
        double z;

        for (;;) {
            read_keyword(st, "z");
            z = read_double(st);
            k = read_keyword(st);

            if (!strcmp(k, "stereotype")) {
                (void) read_string(st);
                read_keyword(st, "xyz");

                int x = (int) read_double(st);
                int y = (int) read_double(st);

                if ((rd == 0) || (*(rd->get_stereotype()) == 0)) {
                    stereotype = 0;
                    read_double(st);	// z
                }
                else {
                    QString s = toUnicode(rd->get_short_stereotype());

                    if (s[0] != '{')
                        s = QString("<<") + s + ">>";

                    stereotype = new LabelCanvas(s, canvas, x, y);
                    stereotype->setZ(read_double(st));
                }

                k = read_keyword(st);
            }
            else
                stereotype = 0;

            if (strcmp(k, "to"))
                wrong_keyword(k, "to");

            DiagramItem * di;

            if (strcmp(k = read_keyword(st), "ref")) {
                di = ArrowPointCanvas::read(st, canvas, k);

                if (di == 0)
                    unknown_keyword(k);
            }
            else
                di = dict_get(read_id(st), "classcanvas", canvas);

            // do not give rd to not call update()
            result = new SimpleRelationCanvas(canvas, bi, di, b, t, id, dbegin, dend);
            result->geometry = geo;
            result->fixed_geometry = fixed;
            result->set_z(z);
            result->data = rd;
            connect(rd, SIGNAL(changed()), result, SLOT(modified()));
            connect(rd, SIGNAL(deleted()), result, SLOT(deleted()));

            if (first == 0) {
                first = result;

                if (read_file_format() == 30)
                    // to remove redondant relation made by release 2.22
                    RelsToCheck.append(result);
            }

            if (stereotype != 0)
                (result->stereotype = stereotype)->show();

            result->show();

            if (di->type() != UmlArrowPoint)
                break;

            bi = di;

            read_keyword(st, "line");
            id = read_id(st);
        }

        if (read_file_format() >= 58) {
            // stereotype property

            k = read_keyword(st);

            first->stereotypeproperties =
                StereotypePropertiesCanvas::read(st,  canvas, k, first);

            if (first->stereotypeproperties != 0)
                k = read_keyword(st);

            if (strcmp(k, "end"))
                wrong_keyword(k, "end");
        }

        // to add stereotype ... if needed

        first->update(FALSE);

        if (first != result)
            result->update(FALSE);

        first->check_stereotypeproperties();

        // manage case where the relation is deleted but present in the browser
        if (result->data->get_start()->deletedp())
            RelsToDel.append(result);
        else
            result->update_geometry();

        return result;
    }
    else
        return 0;
}
コード例 #3
0
ファイル: FlowCanvas.cpp プロジェクト: SciBoy/douml
FlowCanvas * FlowCanvas::read(char * & st, UmlCanvas * canvas, char * k)
{
  if (!strcmp(k, "flowcanvas_ref"))
    return ((FlowCanvas *) dict_get(read_id(st), "flowcanvas", canvas));
  else if (!strcmp(k, "flowcanvas")) {    
    int id = read_id(st);
    BrowserFlow * br = BrowserFlow::read_ref(st);
    FlowData * tr = (FlowData *) br->get_data();
    LineGeometry geo;
    bool fixed = FALSE;
    
    k = read_keyword(st);
    if (! strcmp(k, "geometry")) {
      geo = line_geometry(read_keyword(st));
      k = read_keyword(st);
      if (! strcmp(k, "unfixed"))
	k = read_keyword(st);
      else {
	fixed = TRUE;
      }
    }
    else
      geo = NoGeometry;
    
    float dbegin;
    float dend;

    if (! strcmp(k, "decenter_begin")) {
      dbegin = read_double(st) / 1000;
      k = read_keyword(st);
    }
    else
      dbegin = -1;

    if (! strcmp(k, "decenter_end")) {
      dend = read_double(st) / 1000;
      k = read_keyword(st);
    }
    else
      dend = -1;

    unread_keyword(k, st);
    
    read_keyword(st, "from");
    read_keyword(st, "ref");
    
    DiagramItem * bi = dict_get(read_id(st), "canvas", canvas);
    BrowserNode * b = tr->get_start_node();
    QString s = br->get_name();
    FlowCanvas * first = 0;
    FlowCanvas * result;
    LabelCanvas * label;
    LabelCanvas * stereotype;
    double z;
              
    for (;;) {
      read_keyword(st, "z");
      z = read_double(st);
      k = read_keyword(st);
      
      if ((label = LabelCanvas::read(st, canvas, k)) != 0) {
	// the flow name can't be empty
	label->setZ(z);
	k = read_keyword(st);
      }
      
      if (!strcmp(k, "stereotype")) {
	(void) read_string(st);
	read_keyword(st, "xyz");
	
	int x = (int) read_double(st);
	int y = (int) read_double(st);
	
	if ((tr == 0) || (*(tr->get_stereotype()) == 0)) {
	  stereotype = 0;
	  read_double(st);	// z
	}
	else {
	  QString s = tr->get_short_stereotype();
	 
	  if (s == "interrupt")
	    s = LabelCanvas::Zigzag;
	  else
	    s = QString("<<") + toUnicode(s) + ">>";

	  stereotype = new LabelCanvas(s, canvas, x, y);
	  stereotype->setZ(read_double(st));
	}
	k = read_keyword(st);
      }
      else
	stereotype = 0;

      if (strcmp(k, "to"))
	wrong_keyword(k, "to");

      DiagramItem * di;
      
      if (strcmp(k = read_keyword(st), "ref")) {
	di = ArrowPointCanvas::read(st, canvas, k);
	
	if (di == 0)
	  unknown_keyword(k);
      }
      else
	di = dict_get(read_id(st), "activity node", canvas);

      // do not give data to not call update()
      result = new FlowCanvas(canvas, bi, di, b, id, dbegin, dend);
      result->geometry = geo;
      result->fixed_geometry = fixed;
      result->set_z(z);
      result->data = tr;
      connect(tr, SIGNAL(changed()), result, SLOT(modified()));
      connect(tr, SIGNAL(deleted()), result, SLOT(deleted()));

      if (first == 0) {
	first = result;
	if (read_file_format() == 30)
	  // to remove redondant relation made by release 2.22
	  RelsToCheck.append(result);
      }
      if (label != 0)
	result->label = label;
      if (stereotype != 0)
	(result->stereotype = stereotype)->show();
      result->show();
      
      if (di->type() != UmlArrowPoint)
	break;
      
      bi = di;
      
      read_keyword(st, "line");
      id = read_id(st);
    }
    
    k = read_keyword(st);
    result->settings.read(st, k);	// updates k    
    if (strcmp(k, "write_horizontally") != 0)
      wrong_keyword(k, "write_horizontally");
    result->write_horizontally = state(read_keyword(st));
    k = read_keyword(st);
    result->propagate_drawing_settings();
    
    // to add label, stereotype ... if needed    
    first->update(FALSE);
    if (first != result)
      result->update(FALSE);
    
    if (! strcmp(k, "selection")) {
      k = read_keyword(st);
      first->selection = InfoCanvas::read(st, canvas, k, first);
      k = read_keyword(st);
    }
    if (! strcmp(k, "transformation")) {
      k = read_keyword(st);
      first->transformation = InfoCanvas::read(st, canvas, k, first);
      k = read_keyword(st);
    }

    first->stereotypeproperties = 
      StereotypePropertiesCanvas::read(st,  canvas, k, first);
    
    if (first->stereotypeproperties != 0)
      k = read_keyword(st);
    
    first->check_sel_trans();
    first->check_stereotypeproperties();

    // manage case where the relation is deleted but present in the browser
    if (result->data->get_start()->deletedp())
      RelsToDel.append(result);
    else
      result->update_geometry();
    
    if (strcmp(k, "end"))
      wrong_keyword(k, "end");
    
    return result;
  }
  else
    return 0;
}