Exemplo n.º 1
0
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();
  }
}
Exemplo n.º 2
0
int main(){
	history_remove();
	history_load();
	history_add(__T("abcd"));
	assert( _tcscmp(history_get(0),__T("abcd"))==0 );
	history_add(__T("qwerrr"));
	assert( _tcscmp(history_get(0),__T("qwerrr"))==0 );
	history_add(__T("zxcv"));
	assert( _tcscmp(history_get(0),__T("zxcv"))==0 );
	history_save();
	history_load();
	history_add(__T("zxcv1"));
	assert( _tcscmp(history_get(0),__T("zxcv1"))==0 );
	assert( _tcscmp(history_get(1),__T("zxcv"))==0 );
	assert( _tcscmp(history_get(2),__T("qwerrr"))==0 );
	assert( _tcscmp(history_get(3),__T("abcd"))==0 );
	history_delete(1);
	history_save();
	history_load();
	assert( _tcscmp(history_get(0),__T("zxcv1"))==0 );
	assert( _tcscmp(history_get(1),__T("zxcv"))!=0 );
	assert( _tcscmp(history_get(2),__T("qwerrr"))==0 );
	assert( _tcscmp(history_get(3),__T("abcd"))==0 );
	history_pin(2);
	check_ni_wi();
	history_add(__T("asdff"));
	history_add(__T("asdfff"));
	history_add(__T("asdffff"));
	assert( _tcscmp(history_get(0),__T("asdffff"))==0 );
	assert( _tcscmp(history_get(1),__T("asdfff"))==0 );
	assert( _tcscmp(history_get(2),__T("qwerrr"))==0 );
	assert( _tcscmp(history_get(3),__T("asdff"))==0 );
	history_pin(3);
	check_ni_wi();
	history_unpin(2);
	check_ni_wi();
	history_pin(11);
	history_pin(13);
	check_ni_wi();
	history_pin(5);
	history_pin(6);
	check_ni_wi();
	history_delete(4);
	history_delete(5);
	check_ni_wi();
	{
		TCHAR buffer[VIEW_HISTORY*MAX_PATH];
		int len = history_to_json(buffer);
		buffer[len+1] = __T('\0');
		_tprintf(__T("\n%d,%s\n"),len,buffer);
	}
	return 0;
}
Exemplo n.º 3
0
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();
    }
}
Exemplo n.º 4
0
void ClassDiagramView::contentsMousePressEvent(QMouseEvent * e) {
  if (!window()->frozen()) {
    switch (window()->buttonOn()) {
    case UmlClass:
      {
	history_protected = TRUE;
	unselect_all();
	window()->selectOn();
	history_save();
	
	BrowserNode * parent = 
	  ((BrowserNode *) window()->browser_diagram()->parent());
	BrowserNode * b = BrowserClass::get_class(parent);
	
	if (b != 0) {
	  CdClassCanvas * cl = 
	    new CdClassCanvas(b, the_canvas(), e->x(), e->y());
	  
	  cl->show();
	  cl->upper();
	  window()->package_modified();
	}
	canvas()->update();
	history_protected = FALSE;
      }
      break;
    default:
      DiagramView::contentsMousePressEvent(e);
      break;
    }
  }
  else
    DiagramView::contentsMousePressEvent(e);
}
Exemplo n.º 5
0
void ComponentDiagramView::contentsMousePressEvent(QMouseEvent * e) {
  if (!window()->frozen()) {
    UmlCode action = window()->buttonOn();
    
    switch (action) {
    case UmlComponent:
      {
	history_protected = TRUE;
	unselect_all();
	window()->selectOn();
	history_save();
	
	BrowserNode * b = 
	  BrowserComponent::get_component(((BrowserNode *) window()->browser_diagram()->parent()));
	
	if (b != 0) {
	  ComponentCanvas * c = 
	    new ComponentCanvas(b, the_canvas(), e->x(), e->y());
	  
	  c->show();
	  c->upper();
	  window()->package_modified();
	}
	canvas()->update();
	history_protected = FALSE;
      }
      break;
    default:
      DiagramView::contentsMousePressEvent(e);
      break;
    }
  }
  else
    DiagramView::contentsMousePressEvent(e);
}
Exemplo n.º 6
0
static void
history_shift(Rune c, void* f, int n){
	if(n){
		history_save();
		history_advance(n);
	}
	history_load();
}
Exemplo n.º 7
0
Arquivo: cpu.c Projeto: SiGe/argos
void cpu_snapshot_delete(cpu_snapshot *snap) {
    for (unsigned i = 0; i < MAX_CPU; ++i) {
        cpu_history_delete(snap->cpus[i]);
    }
    cpu_history_delete(snap->main);

    history_save(snap->ctxt);
    history_delete(snap->ctxt);

    free(snap);
}
Exemplo n.º 8
0
void                    free_shell(s_shell              *shell)
{
    history_save(shell->queue_history);

    free_history_queue(shell->queue_history);
    free_variables(shell->vars);
    free_functions(shell->func);
    free_variables(shell->alias);

    mstream_close();
    mmalloc_free();

    free(shell);
}
Exemplo n.º 9
0
static void
history_restore(){
	FILE *f;
	int len, i;
	if((f = fopen(history_file, "r")) == NULL) return;
	while(1){
		text_clear(line);
		if((len = fget_rune(f)) == EOF) break;
		for(i = 0; i<len; i++)
			insert_character(fget_rune(f), NULL, 0);
		history_save();
		history_add();
		hist_first++;
	}
	fclose(f);
}
Exemplo n.º 10
0
void ClassDiagramView::add_classview_classes(BrowserNode * container, const QPoint& p,
					     Q3PtrDict<DiagramItem> & drawn) {
  QApplication::setOverrideCursor(Qt::waitCursor);
  
  history_save();
  history_protected = TRUE;
  
  int x = p.x();
  int y = p.y();
  int future_y = Diagram_Margin;
  
  add_classview_classes(container, drawn, x, y, future_y);
  
  canvas()->update();
  history_protected = FALSE;
  window()->package_modified();
  
  QApplication::restoreOverrideCursor();
}
Exemplo n.º 11
0
static void
flush_line(Rune c, void* f, int v){
	if(pty_mode || f == NULL){
		append_character(v);
	}else{
		(*(void(*)(int)) f)(v);
	}
	cursor_shift(-cursor);
	erase_line();
	fflush(stderr);
	render(stdout, line->buf, utf8_of_rune);
	fflush(stdout);
	if(pty_mode || f == NULL) line->buf->c--; /* FIXME! store history without the flushing character! */
	hist_cur = hist_len - 1;
	history_save();
	if(--lines <= 0) exit(0);
	history_add();
	history_load();
}
Exemplo n.º 12
0
Arquivo: main.c Projeto: meddulla/lsh
/**
   @brief Loop getting input and executing it.
 */
void lsh_loop(void)
{
  char *line;
  char **args;
  int status;

  do {
    printf("> ");
    line = lsh_read_line();
    args = lsh_split_line(line);
    status = lsh_execute(args);

    if(strncmp(args[0], "history", sizeof(*args[0])) != 0) {
        // no need to save history in history
        history_save(*args);
    }
    free(line);
    free(args);
  } while (status);
}
Exemplo n.º 13
0
Arquivo: cpu.c Projeto: SiGe/argos
static void
cpu_history_delete(cpu_history *cpu) {
    history_save(cpu->cpu);
    history_save(cpu->sys);
    history_save(cpu->user);
    history_save(cpu->iowait);
    history_save(cpu->steal);
    history_save(cpu->idle);

    history_delete(cpu->cpu);
    history_delete(cpu->sys);
    history_delete(cpu->user);
    history_delete(cpu->iowait);
    history_delete(cpu->steal);
    history_delete(cpu->idle);
}
Exemplo n.º 14
0
/****************************************************************************
 * history_add_file
 *
 * Adds the given file path to the top of the history list, shifting each
 * existing entry in the history down one place. If given file path is 
 * already in the list then the existing entry is (in effect) moved to the
 * top instead.
  ****************************************************************************/ 
void history_add_file(char *filepath, char *filename)
{
  /* Create the new entry for this path. */
  t_history_entry newentry;
  strncpy(newentry.filepath, filepath, MAXJOLIET - 1);
  strncpy(newentry.filename, filename, MAXJOLIET - 1);
  newentry.filepath[MAXJOLIET - 1] = '\0';
  newentry.filename[MAXJOLIET - 1] = '\0';
  
  t_history_entry oldentry;  /* Old entry is the one being shuffled down a spot. */  
  t_history_entry currentry;  /* Curr entry is the one that just replaced old path. */
  
  /* Initially set curr entry to the new value. */
  memcpy(&currentry, &newentry, sizeof(t_history_entry));

  int i;
  for(i=0; i < NUM_HISTORY_ENTRIES; i++)
  {
    /* Save off the next entry. */
    memcpy(&oldentry, &history.entries[i], sizeof(t_history_entry));

    /* Overwrite with the previous entry. */
    memcpy(&history.entries[i], &currentry, sizeof(t_history_entry));

    /* Switch the old entry to the curr entry now. */
    memcpy(&currentry, &oldentry, sizeof(t_history_entry));

    /* If the entry in the list at this spot matches
       the new entry then do nothing and let this
       entry get deleted. */
    if(strcmp(newentry.filepath, currentry.filepath) == 0 && strcmp(newentry.filename, currentry.filename) == 0)
      break;
  }

  /* now save to disk */
  history_save();
}
Exemplo n.º 15
0
void SeqDiagramView::mousePressEvent(QMouseEvent * e)
{
    if (!window()->frozen()) {
        if (e->button() == ::Qt::RightButton)
            DiagramView::mousePressEvent(e);
        else {
            QPoint diagramPoint(e->x(), e->y());
            QPointF scenePoint = mapToScene(diagramPoint);
            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) {
                    SdClassInstCanvas * cli =
                            new SdClassInstCanvas(b, the_canvas(), scenePoint.x(), 0);

                    cli->show();
                    cli->moveBy(scenePoint.x() - cli->center().x(), 0);
                    cli->upper();
                    window()->package_modified();
                }
            }
                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) {
                    SdClassInstCanvas * cli =
                            new SdClassInstCanvas(b, the_canvas(), scenePoint.x(), 0);

                    cli->show();
                    cli->moveBy(scenePoint.x() - cli->center().x(), 0);
                    cli->upper();
                    window()->package_modified();
                }
            }
                break;

            case UmlSyncSelfMsg:
            case UmlAsyncSelfMsg:
            case UmlSelfReturnMsg: {
                history_protected = TRUE;
                unselect_all();
                window()->selectOn();
                history_save();

                QGraphicsItem * ci = the_canvas()->collision(scenePoint.toPoint());

                if (ci != 0) {
                    DiagramItem * i = QCanvasItemToDiagramItem(ci);

                    if (i != 0) {
                        QString err = i->may_start(c);

                        if (!err.isEmpty())
                            msg_critical("Douml" , err);
                        else {
                            i->connexion(c, i, scenePoint.toPoint(), scenePoint.toPoint());
                            window()->package_modified();
                        }
                    }
                }
            }
                break;

            case UmlContinuation: {
                history_protected = TRUE;
                unselect_all();
                window()->selectOn();
                history_save();
                SdContinuationCanvas * cont =
                        new SdContinuationCanvas(the_canvas(), scenePoint.x(), scenePoint.y(), 0);
                cont->show();
                cont->upper();
                window()->package_modified();
            }
                break;

            default:
                DiagramView::mousePressEvent(e);
                return;
            }

            canvas()->update();
            history_protected = FALSE;
        }
    }
    else
        DiagramView::mousePressEvent(e);
}
Exemplo n.º 16
0
void StateDiagramView::mousePressEvent(QMouseEvent * e)
{
    QPoint diagramPoint(e->x(), e->y());
    QPointF scenePoint = mapToScene(diagramPoint);
    if (!window()->frozen()) {
        UmlCode action = window()->buttonOn();

        switch (action) {
        case UmlState: {
            history_protected = TRUE;
            unselect_all();
            window()->selectOn();
            history_save();

            QGraphicsItem * ci = the_canvas()->collision(scenePoint.toPoint());
            DiagramItem * di;
            bool specified = ((ci != 0) &&
                              ((di = QCanvasItemToDiagramItem(ci)) != 0) &&
                              (di->typeUmlCode() == UmlState) &&
                              ((BrowserState *)((StateCanvas *) di)->get_bn())->may_contains(action));
            BrowserNode * parent;

            if (specified) {
                if ((parent = ((StateCanvas *) di)->pointed_region(scenePoint.toPoint())) == 0)
                    parent = ((StateCanvas *) di)->get_bn();
            }
            else
                parent = (BrowserNode *) window()->browser_diagram()->parent();

            BrowserNode * b = BrowserState::get_state(parent);

            if (b != 0) {
                if (the_canvas()->already_drawn(b)) {
                    msg_information("Douml", TR("already drawn"));
                    history_protected = FALSE;
                    return;
                }

                // may be added in a the state's region rather than the state
                StateCanvas * c = new StateCanvas(b, the_canvas(), scenePoint.x(), scenePoint.y());

                c->show();
                c->upper();
                canvas()->update();
                StateCanvas::force_inside(c, TRUE);
                canvas()->update();
                history_protected = FALSE;
                window()->package_modified();
                return; // canvas already updated
            }
        }
        break;

        case UmlRegion: {
            history_protected = TRUE;
            unselect_all();
            window()->selectOn();
            history_save();

            QGraphicsItem * ci = the_canvas()->collision(scenePoint.toPoint());
            DiagramItem * di;

            if ((ci != 0) &&
                ((di = QCanvasItemToDiagramItem(ci)) != 0) &&
                (di->typeUmlCode() == UmlState) &&
                ((BrowserState *)((StateCanvas *) di)->get_bn())->may_contains(action)) {
                BrowserRegion::add_region(((StateCanvas *) di)->get_bn());
                window()->package_modified();
            }
        }
        break;

        case InitialPS:
        case EntryPointPS:
        case FinalPS:
        case TerminatePS:
        case ExitPointPS:
        case DeepHistoryPS:
        case ShallowHistoryPS:
        case JunctionPS:
        case ChoicePS:
        case ForkPS:
        case JoinPS: {
            history_protected = TRUE;
            unselect_all();
            window()->selectOn();
            history_save();

            QGraphicsItem * ci = the_canvas()->collision(scenePoint.toPoint());
            DiagramItem * di;
            bool specified = ((ci != 0) &&
                              ((di = QCanvasItemToDiagramItem(ci)) != 0) &&
                              (di->typeUmlCode() == UmlState) &&
                              ((BrowserState *)((StateCanvas *) di)->get_bn())->may_contains(action));
            BrowserNode * parent;

            if (specified) {
                if ((parent = ((StateCanvas *) di)->pointed_region(scenePoint.toPoint())) == 0)
                    parent = ((StateCanvas *) di)->get_bn();
            }
            else
                parent = (BrowserNode *) window()->browser_diagram()->parent();

            BrowserNode * b = BrowserPseudoState::get_pseudostate(parent, action);

            if (b != 0) {
                PseudoStateCanvas * c =
                    // may be added in a the state's region rather than the state
                    new PseudoStateCanvas(b, the_canvas(), scenePoint.x(), scenePoint.y());

                c->show();
                c->upper();
                StateCanvas::force_inside(c, FALSE);
                window()->package_modified();
            }
        }
        break;

        case UmlStateAction:
        case UmlSignalIn:
        case UmlSignalOut: {
            history_protected = TRUE;
            unselect_all();
            window()->selectOn();
            history_save();

            QGraphicsItem * ci = the_canvas()->collision(scenePoint.toPoint());
            DiagramItem * di;
            bool specified = ((ci != 0) &&
                              ((di = QCanvasItemToDiagramItem(ci)) != 0) &&
                              (di->typeUmlCode() == UmlState) &&
                              ((BrowserState *)((StateCanvas *) di)->get_bn())->may_contains(UmlStateAction));
            BrowserNode * parent;

            if (specified) {
                if ((parent = ((StateCanvas *) di)->pointed_region(scenePoint.toPoint())) == 0)
                    parent = ((StateCanvas *) di)->get_bn();
            }
            else
                parent = (BrowserNode *) window()->browser_diagram()->parent();

            BrowserNode * b = BrowserStateAction::add_stateaction(parent);

            switch (action) {
            case UmlSignalIn:
                ((StateActionData *) b->get_data())->set_stereotype("receive-signal");
                break;

            case UmlSignalOut:
                ((StateActionData *) b->get_data())->set_stereotype("send-signal");
                break;

            default:	// to avoid warning
                break;
            }

            StateActionCanvas * c =
                // may be added in a the state's region rather than the state
                new StateActionCanvas(b, the_canvas(), scenePoint.x(), scenePoint.y());

            c->show();
            c->upper();
            StateCanvas::force_inside(c, FALSE);
            window()->package_modified();
        }
        break;

        default:
            DiagramView::mousePressEvent(e);
            return;
        }

        canvas()->update();
        history_protected = FALSE;
    }
    else
        DiagramView::mousePressEvent(e);
}
Exemplo n.º 17
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();
    }
}
Exemplo n.º 18
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.º 19
0
void UseCaseDiagramView::contentsMousePressEvent(QMouseEvent * e) {
  if (!window()->frozen()) {
    UmlCode action = window()->buttonOn();
    
    switch (action) {
    case UmlClass:
      {
	history_protected = TRUE;
	unselect_all();
	window()->selectOn();
	history_save();
	
	BrowserNode * b = 
	  BrowserClass::get_class(((BrowserNode *) window()->browser_diagram()->parent()),
				  "actor");
	
	if (b != 0) {
	  UcClassCanvas * uc = 
	    new UcClassCanvas(b, the_canvas(), e->x(), e->y(), 0);
	  
	  uc->show();
	  uc->upper();
	  window()->package_modified();
	}
      }
      break;
    case UmlUseCase:
      {
	history_protected = TRUE;
	unselect_all();
	window()->selectOn();
	history_save();
	
	BrowserNode * b = 
	  BrowserUseCase::get_use_case(((BrowserNode *) window()->browser_diagram()->parent()));
	
	if (b != 0) {
	  UcUseCaseCanvas * uc = 
	    new UcUseCaseCanvas(b, the_canvas(), e->x(), e->y(), 0);
	  uc->show();
	  uc->upper();
	  window()->package_modified();
	}
      }
      break;
      case UmlSubject:
	{
	  unselect_all();
	  window()->selectOn();
	  history_save();
	  
	  SubjectCanvas * f = 
	    new SubjectCanvas(the_canvas(), e->x(), e->y(), 0);
	  
	  f->show();
	  f->upper();
	  window()->package_modified();
	}
	break;
    default:
      DiagramView::contentsMousePressEvent(e);
      return;
    }
    
    canvas()->update();
    history_protected = FALSE;
  }
  else
    DiagramView::contentsMousePressEvent(e);
}
Exemplo n.º 20
0
Arquivo: main.c Projeto: huynhrene/dex
int main(int argc, char *argv[])
{
	const char *term = getenv("TERM");
	const char *home = getenv("HOME");
	const char *tag = NULL;
	const char *rc = NULL;
	const char *command = NULL;
	char *command_history_filename;
	char *search_history_filename;
	char *editor_dir;
	bool read_rc = true;
	int i;

	if (!home)
		home = "";
	home_dir = xstrdup(home);

	for (i = 1; i < argc; i++) {
		const char *opt = argv[i];

		if (opt[0] != '-' || !opt[1])
			break;
		if (!opt[2]) {
			switch (opt[1]) {
			case 'R':
				read_rc = false;
				continue;
			case 't':
				tag = opt_arg(opt, argv[++i]);
				continue;
			case 'r':
				rc = opt_arg(opt, argv[++i]);
				continue;
			case 'c':
				command = opt_arg(opt, argv[++i]);
				continue;
			case 'V':
				printf("%s %s\nWritten by Timo Hirvonen\n", program, version);
				return 0;
			}
			if (opt[1] == '-') {
				i++;
				break;
			}
		}
		printf("Usage: %s [-R] [-V] [-c command] [-t tag] [-r rcfile] [file]...\n", argv[0]);
		return 1;
	}

	if (!isatty(1)) {
		fprintf(stderr, "stdout doesn't refer to a terminal\n");
		return 1;
	}
	if (term == NULL || term[0] == 0) {
		fprintf(stderr, "TERM not set\n");
		return 1;
	}
	switch (term_init(term)) {
	case -1:
		fprintf(stderr, "terminal is hardcopy\n");
		return 1;
	case -2:
		fprintf(stderr, "terminal could not be found\n");
		return 1;
	case -3:
		fprintf(stderr, "terminfo database could not be found\n");
		return 1;
	}

	// create this early. needed if lock-files is true
	editor_dir = editor_file("");
	mkdir(editor_dir, 0755);
	free(editor_dir);

	setlocale(LC_CTYPE, "");
	charset = nl_langinfo(CODESET);
	if (streq(charset, "UTF-8"))
		term_utf8 = true;

	exec_builtin_rc(builtin_rc);
	fill_builtin_colors();

	// NOTE: syntax_changed() uses window. should possibly create window after reading rc
	window = new_window();
	root_frame = new_root_frame(window);

	if (read_rc) {
		if (rc) {
			read_config(commands, rc, true);
		} else {
			char *filename = editor_file("rc");
			if (read_config(commands, filename, false)) {
				free(filename);
				filename = xsprintf("%s/rc", pkgdatadir);
				read_config(commands, filename, true);
			}
			free(filename);
		}
	}

	update_all_syntax_colors();
	sort_aliases();

	/* Terminal does not generate signals for control keys. */
	set_signal_handler(SIGINT, SIG_IGN);
	set_signal_handler(SIGQUIT, SIG_IGN);
	set_signal_handler(SIGPIPE, SIG_IGN);

	/* Terminal does not generate signal for ^Z but someone can send
	 * us SIGTSTP nevertheless. SIGSTOP can't be caught.
	 */
	set_signal_handler(SIGTSTP, handle_sigtstp);

	set_signal_handler(SIGCONT, handle_sigcont);
	set_signal_handler(SIGWINCH, handle_sigwinch);

	load_file_history();
	command_history_filename = editor_file("command-history");
	search_history_filename = editor_file("search-history");
	history_load(&command_history, command_history_filename, command_history_size);
	history_load(&search_history, search_history_filename, search_history_size);
	if (search_history.count)
		search_set_regexp(search_history.ptrs[search_history.count - 1]);

	/* Initialize terminal but don't update screen yet.  Also display
	 * "Press any key to continue" prompt if there were any errors
	 * during reading configuration files.
	 */
	term_raw();
	if (nr_errors) {
		any_key();
		clear_error();
	}

	editor_status = EDITOR_RUNNING;

	for (; i < argc; i++)
		window_open_buffer(window, argv[i], false, NULL);
	if (window->views.count == 0)
		window_open_empty_buffer(window);
	set_view(window->views.ptrs[0]);

	if (command || tag)
		resize();

	if (command)
		handle_command(commands, command);
	if (tag) {
		PTR_ARRAY(array);
		ptr_array_add(&array, xstrdup("tag"));
		ptr_array_add(&array, xstrdup(tag));
		ptr_array_add(&array, NULL);
		run_commands(commands, &array);
		ptr_array_free(&array);
	}
	resize();
	main_loop();
	ui_end();

	// unlock files and add files to file history
	remove_frame(root_frame);

	history_save(&command_history, command_history_filename);
	history_save(&search_history, search_history_filename);
	free(command_history_filename);
	free(search_history_filename);
	save_file_history();
	return 0;
}
Exemplo n.º 21
0
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();
        }
    }
}
Exemplo n.º 22
0
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);
}
Exemplo n.º 23
0
void ColDiagramView::contentsMousePressEvent(QMouseEvent * e)
{
    if (!window()->frozen()) {
        if (e->button() == ::Qt::RightButton)
            DiagramView::contentsMousePressEvent(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) {
                    CodClassInstCanvas * cl =
                        new CodClassInstCanvas(b, the_canvas(),
                                               e->x(), e->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) {
                    CodClassInstCanvas * cl =
                        new CodClassInstCanvas(b, the_canvas(),
                                               e->x(), e->y(), 0);

                    cl->show();
                    cl->upper();
                    window()->package_modified();
                }
            }

            canvas()->update();
            history_protected = FALSE;
            break;

            case UmlSelfLink: {
                history_protected = TRUE;
                window()->selectOn();
                history_save();

                Q3CanvasItem * ci = the_canvas()->collision(e->pos());

                if (ci != 0) {
                    DiagramItem * i = QCanvasItemToDiagramItem(ci);

                    if (i != 0) {
                        QString err = i->may_start(c);

                        if (!err.isEmpty())
                            msg_critical("Douml", err);
                        else {
                            i->connexion(c, i, e->pos(), e->pos());
                            window()->package_modified();
                        }
                    }
                }
            }

            canvas()->update();
            history_protected = FALSE;
            break;

            default:
                DiagramView::contentsMousePressEvent(e);
                break;
            }
        }
    }
    else
        DiagramView::contentsMousePressEvent(e);
}
Exemplo n.º 24
0
void ComponentDiagramView::add_marked_elements(const QPoint& p,
					       Q3PtrDict<DiagramItem> & drawn) {
  QApplication::setOverrideCursor(Qt::waitCursor);
  
  history_save();
  history_protected = TRUE;
  
  int xmax = canvas()->width() - Diagram_Margin;
  int ymax = canvas()->height() - Diagram_Margin;
  int x = p.x();
  int y = p.y();
  int future_y = y;
  const Q3PtrList<BrowserNode> & l = BrowserNode::marked_nodes();
  Q3PtrListIterator<BrowserNode> it(l);
  BrowserNode * bn;

  for (; (bn = it.current()) != 0; ++it) {
    if (drawn[bn->get_data()] == 0) {
      DiagramCanvas * dc;
      
      switch (bn->get_type()) {
      case UmlComponent:
	dc = new ComponentCanvas(bn, the_canvas(), x, y);
	break;
      case UmlPackage:
	dc = new PackageCanvas(bn, the_canvas(), x, y, 0);
	break;
      default:
	continue;
      }

      drawn.replace(dc->get_bn()->get_data(), dc);
      
      if ((x + dc->width()) > xmax)
	dc->move(x = Diagram_Margin, y = future_y);
      
      if (y + dc->height() > ymax) {
	dc->move(x = Diagram_Margin, y = Diagram_Margin);
	future_y = y + dc->height() + Diagram_Margin;
      }
      else {
	int bot = y + dc->height() + Diagram_Margin;
	
	if (bot > future_y)
	  future_y = bot;
      }
      
      x = x + dc->width() + Diagram_Margin;
      
      dc->show();
      dc->upper();
    }
  }
  
  UmlCanvas * cnv = (UmlCanvas *) canvas();
  
  if (! cnv->must_draw_all_relations()) {
    for (it.toFirst(); (bn = it.current()) != 0; ++it) {
      if ((drawn[bn->get_data()] == 0) &&
	  IsaSimpleRelation(bn->get_type()))
	SimpleRelationCanvas::drop(bn, cnv, drawn);
    }
  }
  
  canvas()->update();
  history_protected = FALSE;
  window()->package_modified();
  
  QApplication::restoreOverrideCursor();
}
Exemplo n.º 25
0
void ComponentDiagramView::add_related_elements(DiagramItem *  di, QString what,
						bool inh, bool assoc) {
  BrowserNodeList l;
  RelatedElementsDialog dialog(di->get_bn(), what, inh, assoc, l);
  
  dialog.raise();
  
  if (dialog.exec() == QDialog::Accepted) {
    QApplication::setOverrideCursor(Qt::waitCursor);
  
    DiagramItemList items(canvas()->allItems());
    Q3PtrDict<DiagramItem> drawn;
    
    get_drawn(items, drawn);
    history_save();
    history_protected = TRUE;
    
    int xmax = canvas()->width() - Diagram_Margin;
    int ymax = canvas()->height() - Diagram_Margin;
    QRect re = di->rect();
    int x = re.x();
    int y = re.bottom() + Diagram_Margin;
    int future_y = y;
    Q3PtrListIterator<BrowserNode> it(l);
    BrowserNode * bn;
    
    for (; (bn = it.current()) != 0; ++it) {
      if (drawn[bn->get_data()] == 0) {
	DiagramCanvas * dc;
	
	switch (bn->get_type()) {
	case UmlComponent:
	  dc = new ComponentCanvas(bn, the_canvas(), x, y);
	  break;
	case UmlPackage:
	  dc = new PackageCanvas(bn, the_canvas(), x, y, 0);
	  break;
	default:
	  continue;
	}
	
	drawn.replace(dc->get_bn()->get_data(), dc);
	
	if ((x + dc->width()) > xmax)
	  dc->move(x = Diagram_Margin, y = future_y);
	
	if (y + dc->height() > ymax) {
	  dc->move(x = Diagram_Margin, y = Diagram_Margin);
	  future_y = y + dc->height() + Diagram_Margin;
	}
	else {
	  int bot = y + dc->height() + Diagram_Margin;
	  
	  if (bot > future_y)
	    future_y = bot;
	}
	
	x = x + dc->width() + Diagram_Margin;
	
	dc->show();
	dc->upper();
      }
    }
    
    canvas()->update();
    history_protected = FALSE;
    window()->package_modified();
  
    QApplication::restoreOverrideCursor();
  }
}
Exemplo n.º 26
0
void input_destroy(input_state* input) {
	history_save(input->history_first);
	reset_term(input, true);
	history_destroy(input->history_first);
	free(input);
}
Exemplo n.º 27
0
void DeploymentDiagramView::contentsMousePressEvent(QMouseEvent * e) {
  if (!window()->frozen()) {
    UmlCode action = window()->buttonOn();
    
    switch (action) {
    case UmlDeploymentNode:
      {
	history_protected = TRUE;
	unselect_all();
	window()->selectOn();
	history_save();
	
	BrowserNode * b = 
	  BrowserDeploymentNode::get_deploymentnode(((BrowserNode *) window()->browser_diagram()->parent()));
	
	if (b != 0) {
	  DeploymentNodeCanvas * d = 
	    new DeploymentNodeCanvas(b, the_canvas(), e->x(), e->y(), 0);
	  
	  d->show();
	  d->upper();
	  window()->package_modified();
	}
      }
      break;
    case UmlComponent:
      {
	history_protected = TRUE;
	unselect_all();
	window()->selectOn();
	history_save();
	
	BrowserNode * b = 
	  BrowserComponent::get_component(((BrowserNode *) window()->browser_diagram()->parent()),
					  TRUE);
	
	if (b != 0) {
	  ComponentCanvas * c = 
	    new ComponentCanvas(b, the_canvas(), e->x(), e->y());
	  
	  c->show();
	  c->upper();
	  window()->package_modified();
	}
      }
      break;
    case UmlArtifact:
      {
	history_protected = TRUE;
	unselect_all();
	window()->selectOn();
	history_save();
	
	BrowserNode * b = 
	  BrowserArtifact::get_artifact(((BrowserNode *) window()->browser_diagram()->parent()),
					 TRUE);
	
	if (b != 0) {
	  ArtifactCanvas * c = 
	    new ArtifactCanvas(b, the_canvas(), e->x(), e->y());
	  
	  c->show();
	  c->upper();
	  window()->package_modified();
	}
      }
      break;
    case UmlHub:
      {
	history_protected = TRUE;
	unselect_all();
	window()->selectOn();
	history_save();
	
	HubCanvas * h = new HubCanvas(the_canvas(), e->x(), e->y(), 0);
	
	h->show();
	h->upper();
	window()->package_modified();
      }
      break;
    default:
      DiagramView::contentsMousePressEvent(e);
      return;
    }
    
    canvas()->update();
    history_protected = FALSE;
  }
  else
    DiagramView::contentsMousePressEvent(e);
}
Exemplo n.º 28
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();
    }
}