Example #1
0
void SdDurationCanvas::toOverlapping() {
  // reorder messages, few messages => use bubble sort
  unsigned sz = msgs.count();
  SdMsgBaseCanvas ** v = new SdMsgBaseCanvas *[sz];
  unsigned index = 0;
  
  while (! msgs.isEmpty())
    v[index++] = msgs.take(0);
  
  unsigned sup = sz;
  
  do {
    unsigned upper = 0;
    
    for (index = 1; index < sup; index += 1) {
      if (v[index - 1]->y() > v[index]->y()) {
	SdMsgBaseCanvas * m = v[index - 1];
	
	v[index - 1] = v[index];
	v[index] = m;
	upper = index;
      }
    }
    
    sup = upper;
  } while (sup != 0);
  
  index = 0;  
  toOverlapping(v, this, index, sz);
    
  delete [] v;
  
  postToOverlapping();
}
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);
}