예제 #1
0
ComponentDialog::ComponentDialog(SimpleData * nd)
    : TabDialog(0, 0, FALSE, Qt::WA_DeleteOnClose), data(nd)
{
    nd->get_browser_node()->edit_start();

    if (nd->get_browser_node()->is_writable()) {
        setOkButton(tr("OK"));
        setCancelButton(tr("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(tr("Close"));
    }

    setWindowTitle(tr("component dialog"));

    BrowserComponent * bn = (BrowserComponent *) nd->get_browser_node();

    init_uml_tab();
    rqs = bn->get_required_classes();
    init_l_tab(rq_page, rq_stereotypefilter, &ComponentDialog::rq_stereotypeFilterActivated,
               SLOT(rq_stereotypeFilterActivated(const QString &)),
               SLOT(require_cls()), SLOT(unrequire_cls()),
               lb_rq_available, lb_rq, rqs, tr("Required classes"));
    prs = bn->get_provided_classes();
    init_l_tab(pr_page, pr_stereotypefilter, &ComponentDialog::pr_stereotypeFilterActivated,
               SLOT(pr_stereotypeFilterActivated(const QString &)),
               SLOT(provide_cls()), SLOT(unprovide_cls()),
               lb_pr_available, lb_pr, prs, tr("Provided classes"));
    rzs = bn->get_realizing_classes();
    init_l_tab(rz_page, rz_stereotypefilter, &ComponentDialog::rz_stereotypeFilterActivated,
               SLOT(rz_stereotypeFilterActivated(const QString &)),
               SLOT(realize_cls()), SLOT(unrealize_cls()),
               lb_rz_available, lb_rz, rzs, tr("Realizing classes"));

    // USER : list key - value

    GridBox * grid = new GridBox(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(kvtable = new KeyValuesTable((BrowserComponent *) data->get_browser_node(),
                                 grid, !hasOkButton()));
    addTab(grid, tr("Properties"));

    //

    connect(this, SIGNAL(currentChanged(QWidget *)),
            this, SLOT(change_tabs(QWidget *)));

    open_dialog(this);
}
예제 #2
0
void ComponentDialog::init_uml_tab()
{
    bool visit = !hasOkButton();

    BrowserComponent * bn = (BrowserComponent *) data->get_browser_node();
    VVBox * vbox;
    GridBox * grid = new GridBox(2, this);

    umltab = grid;
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(new QLabel(tr("name : "), grid));
    grid->addWidget(edname = new LineEdit(bn->get_name(), grid));
    edname->setReadOnly(visit);

    grid->addWidget(new QLabel(tr("stereotype : "), grid));
    grid->addWidget(edstereotype = new QComboBox(grid));
    edstereotype->setEditable(true);
    edstereotype->addItem(toUnicode(data->get_stereotype()));

    if (! visit) {
        edstereotype->addItems(BrowserComponent::default_stereotypes());
        edstereotype->addItems(ProfiledStereotypes::defaults(UmlComponent));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentIndex(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorizontalPolicy(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);

    grid->addWidget(vbox = new VVBox(grid));
    vbox->addWidget(new QLabel(tr("description :"), vbox));

    if (! visit)
    {
        SmallPushButton* sButton;
        connect(sButton = new SmallPushButton(tr("Editor"), vbox), SIGNAL(clicked()),
                this, SLOT(edit_description()));
        vbox->addWidget(sButton);
    }

    grid->addWidget(comment = new MultiLineEdit(grid));
    comment->setReadOnly(visit);
    comment->setText(bn->get_comment());
    QFont font = comment->font();

    if (! hasCodec())
        font.setFamily("Courier");

    font.setFixedPitch(TRUE);
    comment->setFont(font);

    addTab(grid, "Uml");
}
예제 #3
0
void ActivityDialog::init_tab(CondDialog & d, InfoData & cd,
                              const char * lbl, bool enabled)
{
    GridBox * grid = new GridBox(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(new QLabel(tr("Pre\ncondition : "), grid));
    grid->addWidget(d.edpre = new MultiLineEdit(grid));
    d.edpre->setText(cd.first);

    if (visit)
        d.edpre->setReadOnly(TRUE);

    grid->addWidget(new QLabel(tr("Post\ncondition : "), grid));
    grid->addWidget(d.edpost = new MultiLineEdit(grid));
    d.edpost->setText(cd.second);

    if (visit)
        d.edpost->setReadOnly(TRUE);

    addTab(grid, lbl);

    if (! enabled)
        removePage(grid);
}
예제 #4
0
void ParameterDialog::init_tab(QWidget *& tab, MultiLineEdit *& ed, const char * v,
                               const char * lbl, const char * sl, bool enabled)
{
    bool visit = !hasOkButton();
    GridBox * grid = new GridBox(2, this);

    tab = grid;
    grid->setMargin(5);
    grid->setSpacing(5);

    VVBox * vtab;
    grid->addWidget(vtab = new VVBox(grid));

    vtab->addWidget(new QLabel(tr("selection : "), vtab));

    SmallPushButton* sButton;
    if (! visit)
    {
        connect(sButton = new SmallPushButton(tr("Editor"), vtab), SIGNAL(clicked()), this, sl);
        vtab->addWidget(sButton);
    }

    grid->addWidget(ed = new MultiLineEdit(grid));

    QFont font = ed->font();

    if (! hasCodec())
        font.setFamily("Courier");

    font.setFixedPitch(TRUE);
    ed->setFont(font);
    ed->setText(v);

    if (visit)
        ed->setReadOnly(TRUE);

    addTab(grid, lbl);

    if (! enabled)
        removePage(grid);
}
예제 #5
0
파일: grid.cpp 프로젝트: cigo/ufoai
/**
 * @brief This function recalculates the routing in and around the box bounded by min and max.
 * @sa CMod_LoadRouting
 * @sa Grid_RecalcRouting
 * @param[in] mapTiles List of tiles the current (RMA-)map is composed of
 * @param[in] routing The routing map (either server or client map)
 * @param[in] box The box to recalc routing for
 * @param[in] list The local models list (a local model has a name starting with * followed by the model number)
 */
void Grid_RecalcBoxRouting (mapTiles_t* mapTiles, Routing& routing, const GridBox& box, const char** list)
{
	int x, y, z, actorSize, dir;

	/* check unit heights */
	for (actorSize = 1; actorSize <= ACTOR_MAX_SIZE; actorSize++) {
		GridBox rBox(box);	/* the box we will actually reroute */
		/* Offset the initial X and Y to compensate for larger actors when needed. */
		rBox.expandXY(actorSize - 1);
		/* also start one level above the box to measure high floors correctly */
		rBox.addOneZ();
		for (y = rBox.getMinY(); y <= rBox.getMaxY(); y++) {
			for (x = rBox.getMinX(); x <= rBox.getMaxX(); x++) {
				/** @note RT_CheckCell goes from top (7) to bottom (0) */
				for (z = rBox.getMaxZ(); z >= 0; z--) {
					const int newZ = RT_CheckCell(mapTiles, routing, actorSize, x, y, z, list);
					assert(newZ <= z);
					z = newZ;
				}
			}
		}
	}

	/* check connections */
	for (actorSize = 1; actorSize <= ACTOR_MAX_SIZE; actorSize++) {
		GridBox rBox(box);			/* the box we will actually reroute */
		rBox.expandXY(actorSize);	/* for connections, expand by the full size of the actor */
		rBox.addOneZ();
		for (y = rBox.getMinY(); y <= rBox.getMaxY(); y++) {
			for (x = rBox.getMinX(); x <= rBox.getMaxX(); x++) {
				for (dir = 0; dir < CORE_DIRECTIONS; dir++) {
					/* for places outside the model box, skip dirs that can not be affected by the model */
					if (x > box.getMaxX() && dir != 1 && dir != 5 && dir != 6)
						continue;
					if (y > box.getMaxY() && dir != 3 && dir != 5 && dir != 7)
						continue;
					if (actorSize == ACTOR_SIZE_NORMAL) {
						if (x < box.getMinX() && dir != 0 && dir != 4 && dir != 7)
							continue;
						if (y < box.getMinY() && dir != 2 && dir != 4 && dir != 6)
							continue;
					} else {
						/* the position of 2x2 actors is their lower left cell */
						if (x < box.getMinX() - 1 && dir != 0 && dir != 4 && dir != 7)
							continue;
						if (y < box.getMinY() - 1 && dir != 2 && dir != 4 && dir != 6)
							continue;
					}
				//	RT_UpdateConnectionColumn(mapTiles, routing, actorSize, x, y, dir, list);
					RT_UpdateConnectionColumn(mapTiles, routing, actorSize, x, y, dir, list, rBox.getMinZ(), rBox.getMaxZ());
				}
			}
		}
	}
}
예제 #6
0
TransitionDialog::TransitionDialog(TransitionData * r)
    : TabDialog(0, 0, true, Qt::WA_DeleteOnClose), rel(r)
{
    r->browser_node->edit_start();

    if (r->browser_node->is_writable()) {
        setOkButton(tr("OK"));
        setCancelButton(tr("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(tr("Close"));
    }

    setWindowTitle(tr("Transition dialog"));
    visit = !hasOkButton();

    BrowserNode * bn = rel->browser_node;
    GridBox * grid;

    //
    // general tab
    //

    grid = new GridBox(2, this);
    umltab = grid;
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(new QLabel(tr("name : "), grid));
    grid->addWidget(edname = new LineEdit(bn->get_name(), grid));
    edname->setReadOnly(visit);

    grid->addWidget(new QLabel(tr("stereotype : "), grid));
    grid->addWidget(edstereotype = new QComboBox(grid));
    edstereotype->setEditable(!visit);
    edstereotype->addItem(toUnicode(rel->get_stereotype()));

    if (!visit) {
        //edstereotype->addItems(rel->get_start()->default_stereotypes(type));
        edstereotype->setAutoCompletion(completion());
        edstereotype->addItems(ProfiledStereotypes::defaults(UmlTransition));
    }

    edstereotype->setCurrentIndex(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorizontalPolicy(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);

    if (r->get_start_node() != r->get_end_node())
        internal_cb = 0;
    else {
        grid->addWidget(new QLabel(grid));
        grid->addWidget(internal_cb = new QCheckBox(tr("internal"), grid));
        internal_cb->setChecked(r->internal());
    }

    VVBox * vtab;
    grid->addWidget(vtab = new VVBox(grid));
    vtab->addWidget(new QLabel(tr("description :"), vtab));

    if (! visit)
    {
        SmallPushButton* sButton;
        connect(sButton = new SmallPushButton(tr("Editor"), vtab), SIGNAL(clicked()),
                this, SLOT(edit_description()));
        vtab->addWidget(sButton);
    }

    grid->addWidget(comment = new MultiLineEdit(grid));
    comment->setReadOnly(visit);
    comment->setText(bn->get_comment());
    //comment->setFont(font);

    addTab(grid, "Uml");

    // UML / OCL
    init_tab(ocltab, uml, rel->uml, "Ocl", SLOT(edit_uml_trigger()),
             SLOT(edit_uml_guard()), SLOT(edit_uml_expr()), TRUE);

    // CPP
    init_tab(cppTab, cpp, rel->cpp, "C++", SLOT(edit_cpp_trigger()),
             SLOT(edit_cpp_guard()), SLOT(edit_cpp_expr()),
             GenerationSettings::cpp_get_default_defs());

    // Java
    init_tab(javatab, java, rel->java, "Java", SLOT(edit_java_trigger()),
             SLOT(edit_java_guard()), SLOT(edit_java_expr()),
             GenerationSettings::java_get_default_defs());

    // USER : list key - value

    grid = new GridBox(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(kvtable = new KeyValuesTable(bn, grid, visit));
    addTab(grid, tr("Properties"));

    //

    connect(this, SIGNAL(currentChanged(QWidget *)),
            this, SLOT(change_tabs(QWidget *)));

    open_dialog(this);
}
예제 #7
0
void TransitionDialog::init_tab(QWidget *& tab, TransDialog & d, TransDef & td,
                                const char * lbl, const char * sl_trigger,
                                const char * sl_guard, const char * sl_expr,
                                bool enabled)
{
    GridBox * grid = new GridBox(2, this);
    VVBox * vtab;
    SmallPushButton* sButton;
    tab = grid;
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(vtab = new VVBox(grid));
    vtab->addWidget(new QLabel(tr("trigger : "), vtab));

    if (! visit)
    {
        connect(sButton = new SmallPushButton(tr("Editor"), vtab), SIGNAL(clicked()),
                this, sl_trigger);
        vtab->addWidget(sButton);
    }

    grid->addWidget(d.edtrigger = new MultiLineEdit(grid));

    QFont font = d.edtrigger->font();

    if (! hasCodec())
        font.setFamily("Courier");

    font.setFixedPitch(TRUE);
    d.edtrigger->setFont(font);
    d.edtrigger->setText(td.trigger);

    if (visit)
        d.edtrigger->setReadOnly(TRUE);

    grid->addWidget(vtab = new VVBox(grid));
    vtab->addWidget(new QLabel(tr("guard\nconstraint : "), vtab));

    if (! visit)
    {
        connect(sButton = new SmallPushButton(tr("Editor"), vtab), SIGNAL(clicked()),
                this, sl_guard);
        vtab->addWidget(sButton);
    }

    grid->addWidget(d.edguard = new MultiLineEdit(grid));
    d.edguard->setFont(font);
    d.edguard->setText(td.guard);

    if (visit)
        d.edguard->setReadOnly(TRUE);

    grid->addWidget(vtab = new VVBox(grid));
    vtab->addWidget(new QLabel(tr("activity\nexpression : "), vtab));

    if (! visit)
    {
        connect(sButton = new SmallPushButton(tr("Editor"), vtab), SIGNAL(clicked()),
                this, sl_expr);
        vtab->addWidget(sButton);
    }

    grid->addWidget(d.edexpr = new MultiLineEdit(grid));
    d.edexpr->setFont(font);
    d.edexpr->setText(td.expr);

    if (visit)
        d.edexpr->setReadOnly(TRUE);

    addTab(grid, lbl);

    if (! enabled)
        removePage(grid);
}
예제 #8
0
ClassInstanceDialog::ClassInstanceDialog(ClassInstanceData * i)
    : TabDialog(0, "class instance dialog", FALSE, Qt::WA_DeleteOnClose),
      inst(i), atbl(0), rtbl(0)
{
    setWindowTitle(tr("Class instance dialog"));

    BrowserNode * bn = inst->get_browser_node();

    bn->edit_start();

    if (bn->is_writable()) {
        setOkButton(tr("OK"));
        setCancelButton(tr("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(tr("Close"));
    }

    visit = !hasOkButton();

    GridBox * grid;

    // general tab

    grid = new GridBox(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(new QLabel(tr("name : "), grid));
    grid->addWidget(edname = new LineEdit(bn->get_name(), grid));

    if (visit)
        edname->setReadOnly(TRUE);

    grid->addWidget(new QLabel(tr("stereotype :"), grid));
    grid->addWidget(edstereotype = new QComboBox( grid));
    edstereotype->setEditable(!visit);
    edstereotype->addItem(toUnicode(bn->get_stereotype()));

    if (! visit) {
        edstereotype->addItems(ProfiledStereotypes::defaults(UmlClassInstance));
        edstereotype->setAutoCompletion(completion());
    }

    SmallPushButton  * b;
    grid->addWidget(b = new SmallPushButton(tr("class :"), grid));

    connect(b, SIGNAL(clicked()), this, SLOT(menu_class()));

    grid->addWidget(edtype = new QComboBox(grid));

    if (visit) {
        edtype->addItem(inst->get_class()->full_name());
        nodes.append(inst->get_class());
    }
    else {
        BrowserClass::instances(nodes);
        nodes.full_names(list);
        edtype->addItems(list);
        edtype->setCurrentIndex(nodes.indexOf(inst->get_class()));
        connect(edtype, SIGNAL(activated(int)), this, SLOT(type_changed(int)));
    }

    if (visit)
        cl_container = 0;
    else {
        cl_container = (BrowserNode *) bn->parent();

        if ((cl_container != 0) && !cl_container->is_writable())
            cl_container = 0;
    }

    VVBox * vtab;
    grid->addWidget(vtab = new VVBox(grid));

    vtab->addWidget(new QLabel(tr("description :"), vtab));

    if (! visit) {
        connect(b =new SmallPushButton(tr("Editor"), vtab), SIGNAL(clicked()),
                this, SLOT(edit_description()));
        vtab->addWidget(b);
    }

    grid->addWidget(comment = new MultiLineEdit(grid));
    comment->setReadOnly(visit);
    comment->setText(bn->get_comment());

    QFont font = comment->font();

    if (! hasCodec())
        font.setFamily("Courier");

    font.setFixedPitch(TRUE);

    comment->setFont(font);

    addTab(grid, "Uml");

    // attributes tab

    atbl = new MyTable(this);
    atbl->setColumnCount(3);
    //atbl->setSortingEnabled(true);
    atbl->setSelectionMode(QTableWidget::NoSelection);	// single does not work
    atbl->verticalHeader()->setSectionsMovable(true);
    atbl->verticalHeader()->setSectionsMovable(true);
    atbl->setHorizontalHeaderLabel(0, tr(" Attribute "));
    atbl->setHorizontalHeaderLabel(1, tr(" Class "));
    atbl->setHorizontalHeaderLabel(2, tr(" Value "));

    addTab(atbl, tr("Attributes"));

    // relation tab

    if (! inst->relations.isEmpty()) {
        rtbl = new RelTable(this, inst, visit);
        addTab(rtbl, tr("Relations"));
    }

    // USER : list key - value

    grid = new GridBox(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(kvtable = new KeyValuesTable(bn, grid, visit));
    addTab(grid, tr("Properties"));

    type_changed(edtype->currentIndex());

    connect(m_tabWidget, SIGNAL(currentChanged(int)),
            this, SLOT(update_all_tabs(int)));

    open_dialog(this);
}
예제 #9
0
ConstrDestrCopyDialog::ConstrDestrCopyDialog(UmlClass * cl, bool have_constructor,
        bool have_destructor, bool have_copy,
        bool have_const_copy, bool have_assignment,
        bool have_const_assignment)
    : QDialog(0), target(cl)
{
    setModal(true);
    QVBoxLayout * vbox = new QVBoxLayout(this);
    GridBox * g;
    QList<QLabel*> labels;
    QLabel * lbl;

    vbox->setSpacing(5);
    vbox->setMargin(5);

    lbl = new QLabel(QString("<big><b>C++ utilities for the class <i><tt>") +
                     (const char *) cl->name() + "</tt></i></b></big>",
                     this);
    lbl->setAlignment(Qt::AlignCenter);
    vbox->addWidget(lbl);

    // constructor

    g = new GridBox(2, this);
    vbox->addWidget(g);

    labels.append(lbl = new QLabel((have_constructor)
                             ? "the class already have contructor  "
                             : "the class doesn't have contructor  ",
                             g));
    g->addWidget(lbl);

    HHBox * h;
    g->addWidget(h = new HHBox(g));

    h->addWidget(add_constr = new QCheckBox("add constructor", h));
    h->addWidget(constr_explicit = new QCheckBox("explicit", h));

    // destructor

    if (! have_destructor) {
        g = new GridBox(2,this);
        vbox->addWidget(g);

        labels.append(lbl = new QLabel("the class doesn't have destructor  ",
                                 g));
        g->addWidget(lbl);

        h = new HHBox(g);
        g->addWidget(h);

        h->addWidget(add_destr = new QCheckBox("add destructor", h));
        h->addWidget(virtual_destr = new QCheckBox("virtual", h));
    }
    else
        add_destr = 0;

    // copy contructor

    if (have_copy) {
        add_copy = 0;

        if (!have_const_copy) {
            g = new GridBox(2, this);
            vbox->addWidget(g);

            labels.append(lbl = new QLabel("the class doesn't have copy contructor  \nwith const argument  ",
                                     g));
            g->addWidget(lbl);
            g->addWidget(add_const_copy = new QCheckBox("add copy constructor\nwith const argument",
                                           g));
        }
        else
            add_const_copy = 0;
    }
    else if (!have_const_copy) {
        g = new GridBox(2, this);
        vbox->addWidget(g);

        labels.append(lbl = new QLabel("the class doesn't have copy contructor  ",
                                 g));
        g->addWidget(lbl);

        VVBox * v = new VVBox(g);
        g->addWidget(v);
        v->addWidget(add_const_copy = new QCheckBox("add copy constructor\nwith const argument",
                                       v));
        v->addWidget(add_copy = new QCheckBox("add copy constructor\nwith non const argument",
                                 v));
    }
    else {
        g = new GridBox(2,this);
        vbox->addWidget(g);

        labels.append(lbl = new QLabel("the class doesn't have copy contructor  \nwith non const argument  ",
                                 g));
        g->addWidget(lbl);
        g->addWidget(add_copy = new QCheckBox("add copy constructor\nwith non const argument",
                                 g));
        add_const_copy = 0;
    }

    // assignment

    if (have_assignment) {
        add_assign = 0;

        if (!have_const_assignment) {
            g = new GridBox(2, this);
            vbox->addWidget(g);

            labels.append(lbl = new QLabel("the class doesn't have assignment\noperator with const argument  ",
                                     g));
            g->addWidget(lbl);
            g->addWidget(add_const_assign = new QCheckBox("add assignment\nwith const argument",
                                             g));
        }
        else
            add_const_assign = 0;
    }
    else if (!have_const_assignment) {
        g = new GridBox(2, this);
        vbox->addWidget(g);

        labels.append(lbl = new QLabel("the class doesn't have assignment operator  ", g));

        g->addWidget(lbl);
        VVBox * v = new VVBox(g);
        g->addWidget(v);

        v->addWidget(add_const_assign = new QCheckBox("add assignment\nwith const argument",
                                         v));
        v->addWidget(add_assign = new QCheckBox("add assignment\nwith non const argument",
                                   v));
    }
    else {
        g = new GridBox(2,this);
        vbox->addWidget(g);

        labels.append(lbl = new QLabel("the class doesn't have assignment operator  \nwith non const argument  ",
                                 g));
        g->addWidget(lbl);
        g->addWidget(add_assign = new QCheckBox("add assignment\nwith non const argument",
                                   g));
        add_const_assign = 0;
    }

    // use the same width for all the labels on the first column

    QSize sz(labels.first()->sizeHint());

    foreach (lbl,labels) {
        if (lbl->sizeHint().width() > sz.width())
            sz.setWidth(lbl->sizeHint().width());
    }

    foreach (lbl,labels) {
        sz.setHeight(lbl->sizeHint().height());
        lbl->setFixedSize(sz);
    }
예제 #10
0
StateDialog::StateDialog(StateData * d)
    : TabDialog(0, 0, FALSE, Qt::WA_DeleteOnClose), state(d)
{
    d->browser_node->edit_start();

    if (d->browser_node->is_writable()) {
        setOkButton(tr("OK"));
        setCancelButton(tr("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(tr("Close"));
    }

    setWindowTitle(tr("State dialog"));
    visit = !hasOkButton();

    BrowserNode * bn = state->browser_node;
    GridBox * grid;

    //
    // general tab
    //

    grid = new GridBox(2, this);
    umltab = grid;
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(new QLabel(tr("name : "), grid));
    grid->addWidget(edname = new LineEdit(bn->get_name(), grid));
    edname->setReadOnly(visit);

    grid->addWidget(new QLabel(tr("stereotype : "), grid));
    grid->addWidget(edstereotype = new QComboBox( grid));
    edstereotype->setEditable(!visit);
    edstereotype->addItem(toUnicode(state->get_stereotype()));

    if (!visit) {
        edstereotype->addItems(BrowserState::default_stereotypes());
        edstereotype->addItems(ProfiledStereotypes::defaults(UmlState));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentIndex(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorizontalPolicy(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);
    SmallPushButton* sButton;
    connect(sButton = new SmallPushButton(tr("specification :"), grid), SIGNAL(clicked()),
            this, SLOT(menu_specification()));
    grid->addWidget(sButton);
    grid->addWidget(edspecification = new QComboBox(grid));
    edspecification->setSizePolicy(sp);

    if (visit) {
        if (state->get_specification() == 0)
            edspecification->addItem("");
        else
            edspecification->addItem(state->get_specification()->full_name(TRUE));
    }
    else {
        edspecification->addItem("");
        edspecification->setAutoCompletion(completion());
        BrowserOperation::instances(opers);
        opers.full_names(speclist);
        edspecification->addItems(speclist);
        edspecification->setCurrentIndex((state->get_specification() == 0)
                                         ? 0
                                         : opers.indexOf(state->get_specification()) + 1);
    }

    switch (((BrowserNode *) bn->parent())->get_type()) {
    case UmlState:
    case UmlRegion:
        if ((state->get_reference() != 0) || (bn->firstChild() == 0)) {
            connect(sButton = new SmallPushButton(tr("reference :"), grid), SIGNAL(clicked()),
                    this, SLOT(menu_reference()));
            grid->addWidget(sButton);
            grid->addWidget(edreference = new QComboBox(grid));
            edreference->setSizePolicy(sp);

            if (visit) {
                if (state->get_reference() == 0)
                    edreference->addItem("");
                else
                    edreference->addItem(state->get_reference()->full_name(TRUE));
            }
            else {
                edreference->addItem("");
                edreference->setAutoCompletion(completion());

                if (((BrowserState *) bn)->can_reference()) {
                    BrowserState::instances(states, TRUE);

                    QMutableListIterator<BrowserNode *> it(states);

                    while (it.hasNext()) {
                        BrowserState *state = (BrowserState *)it.next();
                        if (!((BrowserState *) bn)->can_reference(state) ||
                                state->is_ref()) {
                            it.remove();
                        }
                    }
                }
                else
                    states.append(state->get_reference());

                states.full_names(reflist);
                edreference->addItems(reflist);
                edreference->setCurrentIndex((state->get_reference() == 0)
                                             ? 0
                                             : states.indexOf(state->get_reference()) + 1);

                connect(edreference, SIGNAL(activated(int)), this, SLOT(ed_ref_activated(int)));
            }

            break;
        }

        // no break
    default:
        edreference = 0;
    }
예제 #11
0
파일: grid.cpp 프로젝트: cigo/ufoai
/**
 * @brief This function recalculates the routing surrounding the entity name.
 * @sa CM_InlineModel
 * @sa CM_CheckUnit
 * @sa CM_UpdateConnection
 * @sa CMod_LoadSubmodels
 * @sa Grid_RecalcBoxRouting
 * @param[in] mapTiles List of tiles the current (RMA-)map is composed of
 * @param[in] routing The routing map (either server or client map)
 * @param[in] name Name of the inline model to compute the mins/maxs for
 * @param[in] box The box around the inline model (alternative to name)
 * @param[in] list The local models list (a local model has a name starting with * followed by the model number)
 */
void Grid_RecalcRouting (mapTiles_t* mapTiles, Routing& routing, const char* name, const GridBox& box, const char** list)
{
	if (box.isZero()) {
		/* get inline model, if it is one */
		if (*name != '*') {
			Com_Printf("Called Grid_RecalcRouting with no inline model\n");
			return;
		}
		const cBspModel_t* model = CM_InlineModel(mapTiles, name);
		if (!model) {
			Com_Printf("Called Grid_RecalcRouting with invalid inline model name '%s'\n", name);
			return;
		}

		AABB absbox;
#if 1
		/* An attempt to fix the 'doors starting opened' bug (# 3456).
		 * The main difference is the (missing) rotation of the halfVec.
		 * The results are better, but do not fix the problem. */
		CalculateMinsMaxs(model->angles, model->cbmBox, model->origin, absbox);
#else
		/* get the target model's dimensions */
		if (VectorNotEmpty(model->angles)) {
			vec3_t minVec, maxVec;
			vec3_t centerVec, halfVec, newCenterVec;
			vec3_t m[3];

			/* Find the center of the extents. */
			model->cbmBox.getCenter(centerVec);

			/* Find the half height and half width of the extents. */
			VectorSubtract(model->cbmBox.maxs, centerVec, halfVec);

			/* Rotate the center about the origin. */
			VectorCreateRotationMatrix(model->angles, m);
			VectorRotate(m, centerVec, newCenterVec);

			/* Set minVec and maxVec to bound around newCenterVec at halfVec size. */
			VectorSubtract(newCenterVec, halfVec, minVec);
			VectorAdd(newCenterVec, halfVec, maxVec);

			/* Now offset by origin then convert to position (Doors do not have 0 origins) */
			absbox.set(minVec, maxVec);
			absbox.shift(model->origin);
		} else {  /* normal */
			/* Now offset by origin then convert to position (Doors do not have 0 origins) */
			absbox.set(model->cbmBox);
			absbox.shift(model->origin);
		}
#endif
		GridBox rerouteBox(absbox);

		/* fit min/max into the world size */
		rerouteBox.clipToMaxBoundaries();

		/* We now have the dimensions, call the generic rerouting function. */
		Grid_RecalcBoxRouting(mapTiles, routing, rerouteBox, list);
	} else {
		/* use the passed box */
		Grid_RecalcBoxRouting(mapTiles, routing, box, list);
	}
}
예제 #12
0
파일: Dialog.cpp 프로젝트: DoUML/douml
Dialog::Dialog() : QDialog(0)
{
    setModal(true);
    QVBoxLayout * vbox = new QVBoxLayout(this);
    VGridBox * gbox;
    BButtonGroup * bg;
    HHBox * htab;

    vbox->setMargin(5);

    gbox = new VGridBox(10,this,"Filters");
    vbox->addWidget(gbox);

    gbox->addWidget(htab = new HHBox(gbox));
    //htab->setMargin(5);

    htab->addWidget(new QLabel("filter 1 : ", htab));
    htab->addWidget(filter1_le = new LineEdit(htab));

    htab->addWidget(new QLabel("  ", htab));

    htab->addWidget(bg = new BButtonGroup(htab));
    //bg->setRadioButtonExclusive(TRUE);

    bg->addWidget(with1_rb = new QRadioButton("with", bg));
    bg->addWidget(new QRadioButton("without", bg));
    with1_rb->setChecked(TRUE);

    //

    gbox->addWidget(htab = new HHBox(gbox));
    //htab->setMargin(5);

    htab->addWidget(new QLabel("", htab));
    htab->addWidget(bg = new BButtonGroup(htab));
    //bg->setRadioButtonExclusive(TRUE);

    bg->addWidget(and12_rb = new QRadioButton("and", bg));
    bg->addWidget(new QRadioButton("or", bg));
    and12_rb->setChecked(TRUE);

    htab->addWidget(new QLabel("", htab));

    //

    gbox->addWidget(htab = new HHBox(gbox));
    //htab->setMargin(5);

    htab->addWidget(new QLabel("filter 2 : ", htab));
    htab->addWidget(filter2_le = new LineEdit(htab));

    htab->addWidget(new QLabel("  ", htab));

    htab->addWidget(bg = new BButtonGroup(htab));
    //bg->setRadioButtonExclusive(TRUE);

    bg->addWidget(with2_rb = new QRadioButton("with", bg));
    bg->addWidget(new QRadioButton("without", bg));
    with2_rb->setChecked(TRUE);

    //

    gbox->addWidget(htab = new HHBox(gbox));
    //htab->setMargin(5);

    htab->addWidget(new QLabel("", htab));
    htab->addWidget(bg = new BButtonGroup(htab));
    //bg->setRadioButtonExclusive(TRUE);

    bg->addWidget(and23_rb = new QRadioButton("and", bg));
    bg->addWidget(new QRadioButton("or", bg));
    and23_rb->setChecked(TRUE);

    htab->addWidget(new QLabel("", htab));

    //

    gbox->addWidget(htab = new HHBox(gbox));
    //htab->setMargin(5);

    htab->addWidget(new QLabel("filter 3 : ", htab));
    htab->addWidget(filter3_le = new LineEdit(htab));

    htab->addWidget(new QLabel("  ", htab));

    htab->addWidget(bg = new BButtonGroup(htab));
    //bg->setRadioButtonExclusive(TRUE);

    bg->addWidget(with3_rb = new QRadioButton("with", bg));
    bg->addWidget(new QRadioButton("without", bg));
    with3_rb->setChecked(TRUE);

    //
    //

    gbox = new VGridBox(2,this,"Stereotype" );
    vbox->addWidget(gbox);

    gbox->addWidget(htab = new HHBox(gbox));
    //htab->setMargin(5);

    htab->addWidget(bg = new BButtonGroup(htab));
    //bg->setRadioButtonExclusive(TRUE);

    bg->addWidget(any_rb = new QRadioButton("any", bg));
    bg->addWidget(is_rb = new QRadioButton("is", bg));
    bg->addWidget(isnot_rb = new QRadioButton("is not", bg));
    any_rb->setChecked(TRUE);
    htab->addWidget(stereotype_le = new QLineEdit(htab));

    //
    //

    gbox = new VGridBox(2,this,"Targets" );
    vbox->addWidget(gbox);

    gbox->addWidget(htab = new HHBox(gbox));
    //htab->setMargin(5);

    htab->addWidget(artifact_cb = new QCheckBox("artifact", htab));
    htab->addWidget(class_cb = new QCheckBox("class", htab));
    htab->addWidget(operation_cb = new QCheckBox("operation", htab));
    htab->addWidget(attribute_cb = new QCheckBox("attribute", htab));
    htab->addWidget(relation_cb = new QCheckBox("relation", htab));

    //
    //

    gbox = new VGridBox(2,this,"Languages");
    vbox->addWidget(gbox);

    gbox->addWidget(htab = new HHBox(gbox));
    //htab->setMargin(5);

    htab->addWidget(cpp_cb = new QCheckBox("C++", htab));
    htab->addWidget(java_cb = new QCheckBox("Java", htab));
    htab->addWidget(php_cb = new QCheckBox("Php", htab));
    htab->addWidget(python_cb = new QCheckBox("Python", htab));
    htab->addWidget(idl_cb = new QCheckBox("Idl", htab));

    //
    //

    GridBox * grid = new GridBox(2, this);
    vbox->addWidget(grid);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(new QLabel("current : ", grid));
    grid->addWidget(current_le  = new LineEdit(grid));

    grid->addWidget(new QLabel("new : ", grid));
    grid->addWidget(new_le  = new LineEdit(grid));

    //
    //

    htab = new HHBox(this);
    htab->setMargin(5);
    vbox->addWidget(htab);

    htab->addWidget(new QLabel(htab));
    QPushButton * replace;
    htab->addWidget(replace = new QPushButton("Replace", htab));
    htab->addWidget(new QLabel(htab));
    QPushButton * quit;
    htab->addWidget(quit = new QPushButton("Quit", htab));
    htab->addWidget(new QLabel(htab));

    QSize bs(replace->sizeHint());

    quit->setFixedSize(bs);

    connect(replace, SIGNAL(clicked()), this, SLOT(do_replace()));
    connect(quit, SIGNAL(clicked()), this, SLOT(reject()));

}
예제 #13
0
파일: Dialog.cpp 프로젝트: DoUML/douml
Dialog::Dialog(UmlArtifact * art, const QByteArray & path_exe, QByteArray & pro, QByteArray & target, QByteArray & tmplt, QByteArray & config, QByteArray & defines, QByteArray & includepath, QByteArray & dependpath, QByteArray & objectsdir, QByteArray & footer)
    : QDialog(0), _art(art), _pro(pro), _target(target), _tmplt(tmplt),
      _config(config), _defines(defines), _includepath(includepath), _dependpath(dependpath),
      _objectsdir(objectsdir), _footer(footer)
{
    setModal(true);
    QDir d(path_exe);
    QVBoxLayout * vbox = new QVBoxLayout(this);
    GridBox * grid = new GridBox(2, this);
    HHBox * htab;
    int index;

    vbox->addWidget(grid);
    vbox->setMargin(5);

    grid->addWidget(new QLabel(".pro file : ", grid));
    grid->addWidget(htab = new HHBox(grid));
    htab->addWidget(edpro = new QLineEdit(htab));
    edpro->setText(d.absoluteFilePath(pro));

    htab->addWidget(new QLabel(" ", htab));
    htab->addWidget(browsepro = new SmallPushButton("browse", htab));
    connect(browsepro, SIGNAL(clicked()), this, SLOT(browse_pro()));

    grid->addWidget(new QLabel("target : ", grid));
    grid->addWidget(htab = new HHBox(grid));
    htab->addWidget(edtarget = new QLineEdit(htab));
    edtarget->setText(d.absoluteFilePath(target));
    htab->addWidget(new QLabel(" ", htab));
    htab->addWidget(browsetarget = new SmallPushButton("browse", htab));
    connect(browsetarget, SIGNAL(clicked()), this, SLOT(browse_target()));

    grid->addWidget(new QLabel("template : ", grid));
    grid->addWidget(cbtemplate = new QComboBox(grid));
    cbtemplate->setEditable(true);

    static const char * templates[] = { "app", "lib", "subdirs" };
    bool find = FALSE;

    for (index = 0; index != sizeof(templates) / sizeof(*templates); index += 1) {
        cbtemplate->addItem(templates[index]);

        if (tmplt == templates[index]) {
            cbtemplate->setCurrentIndex(index);
            find = TRUE;
        }
    }

    if (! find) {
        cbtemplate->addItem((QString) tmplt);
        cbtemplate->setCurrentIndex(index);
    }

    grid->addWidget(new QLabel("config : ", grid));
    grid->addWidget(htab = new HHBox(grid));
    htab->addWidget(cbconf[0] = new QComboBox( htab));
    cbconf[0]->addItem("debug");
    cbconf[0]->addItem("release");

    QStringList lcnf = QString(config).split(" ");
        //QStringList::split(" ", (const char *) config);
    QStringList::Iterator it = lcnf.begin();

    cbconf[0]->setCurrentIndex((*it++ == "debug") ? 0 : 1);

    htab->addWidget(cbconf[1] = new QComboBox( htab));
    cbconf[1]->addItem("warn_on");
    cbconf[1]->addItem("warn_off");
    cbconf[1]->setCurrentIndex((*it++ == "warn_on") ? 0 : 1);

    QSizePolicy sp = cbconf[0]->sizePolicy();

    sp.setHorizontalPolicy(QSizePolicy::Fixed);
    cbconf[0]->setSizePolicy(sp);
    cbconf[1]->setSizePolicy(sp);

    htab->addWidget(new QLabel(" qt ", htab));
    it++;	// qt

    /*const char * configs[] = {
        "", "opengl", "thread", "x11", "windows",
        "console", "dll", "staticlib", 0
    };*/
    QStringList configs;
    configs<<""<<"opengl"<<"thread"<<"x11"<<"windows"<<
            "console"<<"dll"<<"staticlib";

    for (index = 2;
         index != sizeof(cbconf) / sizeof(*cbconf) - 1;
         index += 1) {
        htab->addWidget(cbconf[index] = new QComboBox( htab));
        cbconf[index]->setEditable(true);

        if (it != lcnf.end())
            cbconf[index]->addItem(*it++);

        cbconf[index]->addItems(configs);
        cbconf[index]->setCurrentIndex(0);
    }

    htab->addWidget(cbconf[index] = new QComboBox( htab));
    cbconf[index]->setEditable(true);

    if (it != lcnf.end()) {
        QString s = *it++;

        while (it != lcnf.end())
            s += " " + *it++;

        cbconf[index]->addItem(s);
    }

    cbconf[index]->addItems(configs);
    cbconf[index]->setCurrentIndex(0);


    grid->addWidget(new QLabel("defines : ", grid));
    grid->addWidget(eddefines = new QLineEdit(grid));
    eddefines->setText(defines);

    ///may be computed
    grid->addWidget(new QLabel("include paths : ", grid));
    grid->addWidget(htab = new HHBox(grid));
    htab->addWidget(edincludepath = new QLineEdit(htab));
    edincludepath->setText(includepath);
    htab->addWidget(new QLabel(" ", htab));
    htab->addWidget(computeincludepath = new SmallPushButton("compute", htab));
    connect(computeincludepath, SIGNAL(clicked()), this, SLOT(compute_includepath()));

    grid->addWidget(new QLabel("depend paths : ", grid));
    grid->addWidget(eddependpath = new QLineEdit(grid));
    eddependpath->setText(dependpath);

    grid->addWidget(new QLabel("objects dir : ", grid));
    grid->addWidget(htab = new HHBox(grid));
    htab->addWidget(edobjectsdir = new QLineEdit(htab));
    edobjectsdir->setText(objectsdir);
    htab->addWidget(new QLabel(" ", htab));
    htab->addWidget(browseobjectsdir = new SmallPushButton("browse", htab));
    connect(browseobjectsdir, SIGNAL(clicked()), this, SLOT(browse_objectsdir()));

    grid->addWidget(new QLabel("footer : ", grid));
    grid->addWidget(edfooter = new QTextEdit(grid));
    edfooter->setText(footer);

    grid->addWidget(new QLabel(grid));
    grid->addWidget(new QLabel(grid));

    grid->addWidget(new QLabel(grid));
    grid->addWidget(htab = new HHBox(grid));
    htab->addWidget(new QLabel(htab));
    QPushButton * ok ;
    htab->addWidget(ok = new QPushButton("&OK", htab));
    htab->addWidget(new QLabel(htab));
    QPushButton * cancel;
    htab->addWidget( cancel = new QPushButton("&Cancel", htab));
    htab->addWidget(new QLabel(htab));
    QSize bs(cancel->sizeHint());

    ok->setDefault(TRUE);

    if (ok->sizeHint().width() > bs.width())
        bs.setWidth(ok->sizeHint().width());

    ok->setFixedSize(bs);
    cancel->setFixedSize(bs);

    connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
    connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
}
예제 #14
0
PseudoStateDialog::PseudoStateDialog(PseudoStateData * ps)
    : TabDialog(0, 0, FALSE, Qt::WA_DeleteOnClose), pst(ps)
{
    BrowserPseudoState * bn = (BrowserPseudoState *) pst->browser_node;
    BrowserState * refst;
    SmallPushButton* sButton;

    switch (bn->get_type()) {
    case EntryPointPS:
    case ExitPointPS:
        if (((BrowserNode *) bn->parent())->get_type() == UmlState) {
            refst = ((StateData *)((BrowserNode *) bn->parent())->get_data())->get_reference();
            break;
        }

        // no break
    default:
        refst = 0;
    }

    bn->edit_start();

    if (bn->is_writable()) {
        setOkButton(TR("OK"));
        setCancelButton(TR("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(TR("Close"));
    }

    QString s = stringify(bn->get_type());
    int index = s.indexOf("_");

    if (index != -1)
        s.replace(index, 1, " ");

    setCaption((s + " dialog"));

    visit = !hasOkButton();

    // general tab

    GridBox * grid = new GridBox(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(new QLabel(TR("name : "), grid));
    grid->addWidget(edname = new LineEdit(bn->get_name(), grid));
    edname->setReadOnly(visit);

    grid->addWidget(new QLabel(TR("stereotype : "), grid));
    grid->addWidget(edstereotype = new QComboBox(grid));
    edstereotype->setEditable(!visit);
    edstereotype->addItem(toUnicode(pst->get_stereotype()));

    if (! visit) {
        edstereotype->addItems(BrowserPseudoState::default_stereotypes());
        edstereotype->addItems(ProfiledStereotypes::defaults(bn->get_type()));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentIndex(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorizontalPolicy(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);

    if (refst != 0) {
        connect(new SmallPushButton(TR("reference :"), grid), SIGNAL(clicked()),
                this, SLOT(menu_reference()));
        grid->addWidget(edreference = new QComboBox(grid));
        edreference->setSizePolicy(sp);

        BrowserNode * ref = ((pst->get_reference() == 0) ||
                             !bn->can_reference(pst->get_reference()))
                            ? 0 : pst->get_reference();

        if (visit) {
            if (ref == 0)
                edreference->addItem("");
            else
                edreference->addItem(ref->full_name(TRUE));
        }
        else {
            edreference->addItem("");
            edreference->setAutoCompletion(completion());

            BrowserNode * child;
            UmlCode k = bn->get_type();

            for (child = refst->firstChild();
                 child != 0;
                 child = child->nextSibling()) {
                if (!((BrowserNode *) child)->deletedp()) {
                    UmlCode kk = ((BrowserNode *) child)->get_type();

                    if (kk == k)
                        pseudostates.append((BrowserNode *) child);
                    else if (kk == UmlRegion) {
                        for (BrowserNode * schild = child->firstChild();
                             schild != 0;
                             schild = schild->nextSibling()) {
                            if (!((BrowserNode *) schild)->deletedp() &&
                                (((BrowserNode *) schild)->get_type() == k))
                                pseudostates.append((BrowserNode *) schild);
                        }
                    }
                }
            }

            pseudostates.sort();
            pseudostates.full_names(reflist);
            edreference->addItems(reflist);
            edreference->setCurrentIndex((ref == 0)
                                        ? 0
                                        : pseudostates.indexOf(ref) + 1);
        }
    }
    else
        edreference = 0;

    VVBox * vtab;
    grid->addWidget(vtab = new VVBox(grid));
    vtab->addWidget(new QLabel(TR("description :"), vtab));

    if (! visit)
    {
        connect(sButton = new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()),
                this, SLOT(edit_description()));
        vtab->addWidget(sButton);
    }

    grid->addWidget(comment = new MultiLineEdit(grid));
    comment->setReadOnly(visit);
    comment->setText(bn->get_comment());

    QFont font = comment->font();

    if (! hasCodec())
        font.setFamily("Courier");

    font.setFixedPitch(TRUE);
    comment->setFont(font);

    addTab(grid, "Uml");

    // USER : list key - value

    grid = new GridBox(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(kvtable = new KeyValuesTable(bn, grid, visit));
    addTab(grid, TR("Properties"));

    open_dialog(this);
}
예제 #15
0
ActivityDialog::ActivityDialog(ActivityData * d)
    : TabDialog(0, 0, FALSE, Qt::WA_DeleteOnClose), activity(d)
{
    d->browser_node->edit_start();

    if (d->browser_node->is_writable()) {
        setOkButton(tr("OK"));
        setCancelButton(tr("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(tr("Close"));
    }

    setWindowTitle(tr("Activity dialog"));
    visit = !hasOkButton();

    BrowserNode * bn = activity->browser_node;
    GridBox * grid;

    //
    // general tab
    //

    grid = new GridBox(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(new QLabel(tr("name : "), grid));
    grid->addWidget(edname = new LineEdit(bn->get_name(), grid));
    edname->setReadOnly(visit);

    grid->addWidget(new QLabel(tr("stereotype : "), grid));
    grid->addWidget(edstereotype = new QComboBox(grid));
    edstereotype->setEditable(!visit);
    edstereotype->addItem(toUnicode(activity->get_stereotype()));

    if (!visit) {
        edstereotype->addItems(BrowserActivity::default_stereotypes());
        edstereotype->addItems(ProfiledStereotypes::defaults(UmlActivity));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentIndex(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorizontalPolicy(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);

    SmallPushButton* sButton;
    connect(sButton = new SmallPushButton(tr("specification :"), grid), SIGNAL(clicked()),
            this, SLOT(menu_specification()));
    grid->addWidget(sButton);
    grid->addWidget(edspecification = new QComboBox(grid));
    edspecification->setSizePolicy(sp);

    if (visit) {
        if (activity->get_specification() == 0)
            edspecification->addItem("");
        else
            edspecification->addItem(activity->get_specification()->full_name(TRUE));
    }
    else {
        edspecification->addItem("");
        edspecification->setAutoCompletion(completion());
        BrowserOperation::instances(opers);
        opers.full_names(list);
        edspecification->addItems(list);
        edspecification->setCurrentIndex((activity->get_specification() == 0)
                                         ? 0
                                         : opers.indexOf(activity->get_specification()) + 1);
    }

    grid->addWidget(new QLabel(grid));
    BButtonGroup * bg;
    grid->addWidget(bg =
            new BButtonGroup(3, Qt::Horizontal, QString(), grid));

    bg->addWidget(readonly_cb = new QCheckBox(tr("read only"), bg));

    if (activity->read_only)
        readonly_cb->setChecked(TRUE);

    readonly_cb->setDisabled(visit);

    bg->addWidget(singlexec_cb = new QCheckBox(tr("single execution"), bg));

    if (activity->single_execution)
        singlexec_cb->setChecked(TRUE);

    singlexec_cb->setDisabled(visit);

    bg->addWidget(active_cb = new QCheckBox(tr("active"), bg));

    if (activity->is_active)
        active_cb->setChecked(TRUE);

    active_cb->setDisabled(visit);

    VVBox * vtab;
    grid->addWidget(vtab = new VVBox(grid));
    vtab->addWidget(new QLabel(tr("description :"), vtab));

    if (! visit)
    {
        connect(sButton = new SmallPushButton(tr("Editor"), vtab), SIGNAL(clicked()),
                this, SLOT(edit_description()));
    vtab->addWidget(sButton);
    }

    grid->addWidget(comment = new MultiLineEdit(grid));
    comment->setReadOnly(visit);
    comment->setText(bn->get_comment());
    //comment->setFont(font);

    grid->addWidget(vtab = new VVBox(grid));
    vtab->addWidget(new QLabel(tr("constraint :"), vtab));

    if (! visit) {
        connect(sButton = new SmallPushButton(tr("Editor"), vtab), SIGNAL(clicked()),
                this, SLOT(edit_constraint()));
        vtab->addWidget(sButton);
    }


    grid->addWidget(constraint = new MultiLineEdit(grid));
    constraint->setReadOnly(visit);
    constraint->setText(activity->constraint);
    //constraint->setFont(font);

    addTab(grid, "Uml");

    // UML / OCL
    init_tab(uml, activity->uml_condition, "Ocl", TRUE);

    // CPP
    init_tab(cpp, activity->cpp_condition, "C++",
             GenerationSettings::cpp_get_default_defs());

    // Java
    init_tab(java, activity->java_condition, "Java",
             GenerationSettings::java_get_default_defs());

    // USER : list key - value

    grid = new GridBox(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(kvtable = new KeyValuesTable(bn, grid, visit));
    addTab(grid, tr("Properties"));

    //

    connect(this, SIGNAL(currentChanged(QWidget *)),
            this, SLOT(change_tabs(QWidget *)));

    open_dialog(this);
}
예제 #16
0
ParameterDialog::ParameterDialog(ParameterData * pa)
    : TabDialog(0, 0, true, Qt::WA_DeleteOnClose), param(pa)
{
    pa->browser_node->edit_start();

    if (pa->browser_node->is_writable()) {
        setOkButton(tr("OK"));
        setCancelButton(tr("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(tr("Close"));
    }

    visit = !hasOkButton();
    setWindowTitle(tr("Parameter dialog"));

    GridBox * grid;
    HHBox * htab;
    QString s;

    // general tab

    grid = new GridBox(2, this);
    umltab = grid;
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(new QLabel(tr("name :"), grid));
    grid->addWidget(edname = new LineEdit(pa->name(), grid));
    edname->setReadOnly(visit);

    QFont font = edname->font();

    if (! hasCodec())
        font.setFamily("Courier");

    font.setFixedPitch(TRUE);

    grid->addWidget(new QLabel(tr("stereotype : "), grid));
    grid->addWidget(edstereotype = new QComboBox(grid));
    edstereotype->setEditable(!visit);
    edstereotype->addItem(toUnicode(pa->stereotype));

    if (! visit) {
        edstereotype->addItems(BrowserParameter::default_stereotypes());
        edstereotype->addItems(ProfiledStereotypes::defaults(UmlParameter));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentIndex(0);

    QSizePolicy sp = edstereotype->sizePolicy();

    sp.setHorizontalPolicy(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);

    SmallPushButton* sButton;
    connect(sButton = new SmallPushButton(tr("type :"), grid), SIGNAL(clicked()),
            this, SLOT(menu_type()));

    grid->addWidget(sButton);
    grid->addWidget(edtype = new QComboBox( grid));
    edtype->setEditable(!visit);
    edtype->addItem(pa->get_type().get_full_type());

    if (!visit) {
        BrowserClass::instances(nodes);
        nodes.full_names(list);

        edtype->addItems(GenerationSettings::basic_types());
        offset = edtype->count();
        edtype->addItems(list);
        edtype->setAutoCompletion(completion());
        view = pa->browser_node->container(UmlClass);
    }

    edtype->setCurrentIndex(0);
    edtype->setSizePolicy(sp);

    grid->addWidget(new QLabel(tr("direction :"), grid));
    grid->addWidget(htab = new HHBox(grid));
    htab->addWidget(eddir = new QComboBox(htab));

    UmlParamDirection dir = pa->get_dir();

    eddir->addItem(stringify(dir));

    if (! visit) {
        if (dir != UmlInOut)
            eddir->addItem(stringify(UmlInOut));

        if (dir != UmlIn)
            eddir->addItem(stringify(UmlIn));

        if (dir != UmlOut)
            eddir->addItem(stringify(UmlOut));

        if (dir != UmlReturn)
            eddir->addItem(stringify(UmlReturn));
    }

    htab->addWidget(new QLabel(tr("   multiplicity : "), htab));
    htab->addWidget( edmultiplicity = new QComboBox(htab));
    edmultiplicity->setEditable(!visit);
    edmultiplicity->setSizePolicy(sp);
    edmultiplicity->addItem(pa->get_multiplicity());

    if (!visit) {
        edmultiplicity->addItem("1");
        edmultiplicity->addItem("0..1");
        edmultiplicity->addItem("*");
        edmultiplicity->addItem("1..*");
    }

    htab->addWidget(new QLabel(tr("   ordering : "), htab));
    htab->addWidget(edordering = new QComboBox(htab));

    UmlOrderingKind o = pa->get_ordering();

    edordering->addItem(stringify(o));

    if (!visit) {
        if (o != UmlUnordered)
            edordering->addItem(stringify(UmlUnordered));

        if (o != UmlOrdered)
            edordering->addItem(stringify(UmlOrdered));

        if (o != UmlLifo)
            edordering->addItem(stringify(UmlLifo));

        if (o != UmlFifo)
            edordering->addItem(stringify(UmlFifo));
    }

    htab->addWidget(new QLabel(tr("   effect : "), htab));
    htab->addWidget(edeffect = new QComboBox(htab));

    UmlParamEffect e = pa->get_effect();

    edeffect->addItem(stringify(e));

    if (!visit) {
        if (e != UmlNoEffect)
            edeffect->addItem(stringify(UmlNoEffect));

        if (e != UmlCreate)
            edeffect->addItem(stringify(UmlCreate));

        if (e != UmlRead)
            edeffect->addItem(stringify(UmlRead));

        if (e != UmlUpdate)
            edeffect->addItem(stringify(UmlUpdate));

        if (e != UmlDelete)
            edeffect->addItem(stringify(UmlDelete));
    }

    grid->addWidget(new QLabel(tr("in state : "), grid));
    grid->addWidget(edin_state = new LineEdit(pa->in_state, grid));
    edin_state->setReadOnly(visit);

    grid->addWidget(new QLabel(tr("default value :"), grid));
    grid->addWidget(htab = new HHBox(grid));
    htab->addWidget(edinit = new LineEdit(pa->get_default_value(), htab));

    if (visit)
    {
        edinit->setReadOnly(TRUE);
    }
    else
    {
        connect(sButton = new SmallPushButton(tr("Editor"), htab), SIGNAL(clicked()),
                this, SLOT(edit_init()));
        htab->addWidget(sButton);
    }

    grid->addWidget(new QLabel(grid));
    grid->addWidget(htab = new HHBox(grid));
    BButtonGroup * bg ;
    htab->addWidget( bg = new BButtonGroup(2, Qt::Horizontal, QString(), htab));

    bg->addWidget(is_control_cb = new QCheckBox(tr("is_control"), bg));

    if (pa->is_control)
        is_control_cb->setChecked(TRUE);

    is_control_cb->setDisabled(visit);

    bg->addWidget(unique_cb = new QCheckBox(tr("unique"), bg));

    if (pa->unique)
        unique_cb->setChecked(TRUE);

    unique_cb->setDisabled(visit);

    htab->addWidget(bg = new BButtonGroup(3, Qt::Horizontal, QString(), htab));
    bg->setExclusive(TRUE);

    bg->addWidget(standard_rb = new QRadioButton(tr("standard"), bg));
    bg->addWidget(exception_rb = new QRadioButton(tr("exception"), bg));
    bg->addWidget(stream_rb = new QRadioButton(tr("stream"), bg));

    if (pa->exception)
        exception_rb->setChecked(TRUE);
    else if (pa->stream)
        stream_rb->setChecked(TRUE);
    else
        standard_rb->setChecked(TRUE);

    VVBox * vtab;
    grid->addWidget(vtab = new VVBox(grid));
    vtab->addWidget(new QLabel(tr("description :"), vtab));

    if (! visit) {
        connect(sButton = new SmallPushButton(tr("Editor"), vtab), SIGNAL(clicked()),
                this, SLOT(edit_description()));
        vtab->addWidget(sButton);
    }

    grid->addWidget(comment = new MultiLineEdit(grid));
    comment->setReadOnly(visit);
    comment->setText(pa->browser_node->get_comment());
    comment->setFont(font);

    addTab(grid, "Uml");

    init_tab(ocltab, eduml_selection, pa->uml_selection, "Ocl",
             SLOT(edit_uml_selection()), TRUE);

    // C++
    init_tab(cppTab, edcpp_selection, pa->cpp_selection, "C++",
             SLOT(edit_cpp_selection()),
             GenerationSettings::cpp_get_default_defs());

    // Java
    init_tab(javatab, edjava_selection, pa->java_selection, "Java",
             SLOT(edit_java_selection()),
             GenerationSettings::java_get_default_defs());

    // USER : list key - value

    grid = new GridBox(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(kvtable = new KeyValuesTable(pa->browser_node, grid, visit));
    addTab(grid, tr("Properties"));

    //

    connect(this, SIGNAL(currentChanged(QWidget *)),
            this, SLOT(change_tabs(QWidget *)));

    open_dialog(this);
}
예제 #17
0
ExpansionRegionDialog::ExpansionRegionDialog(ExpansionRegionData * nd)
    : TabDialog(0, 0, FALSE, Qt::WA_DeleteOnClose), data(nd)
{
    nd->browser_node->edit_start();

    if (nd->browser_node->is_writable()) {
        setOkButton(TR("OK"));
        setCancelButton(TR("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(TR("Close"));
    }

    setWindowTitle(TR("Expansion Region dialog"));

    bool visit = !hasOkButton();

    // general tab

    BrowserNode * bn = data->get_browser_node();
    GridBox * grid = new GridBox(2, this);

    umltab = grid;
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(new QLabel(TR("name : "), grid));
    grid->addWidget(edname = new LineEdit(bn->get_name(), grid));
    edname->setReadOnly(visit);

    grid->addWidget(new QLabel(TR("stereotype : "), grid));
    grid->addWidget(edstereotype = new QComboBox(grid));
    edstereotype->setEditable(!visit);
    edstereotype->addItem(toUnicode(data->get_stereotype()));

    if (! visit) {
        edstereotype->addItems(BrowserExpansionRegion::default_stereotypes());
        edstereotype->addItems(ProfiledStereotypes::defaults(UmlExpansionRegion));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentIndex(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorizontalPolicy(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);

    HHBox * htab;

    grid->addWidget(new QLabel(TR("mode :"), grid));
    grid->addWidget(htab = new HHBox(grid));
    htab->addWidget(edmode = new QComboBox(htab));

    UmlExpansionKind m = data->get_mode();

    edmode->addItem(stringify(m));

    if (! visit) {
        if (m != UmlParallel)
            edmode->addItem(stringify(UmlParallel));

        if (m != UmlIterative)
            edmode->addItem(stringify(UmlIterative));

        if (m != UmlStream)
            edmode->addItem(stringify(UmlStream));
    }

    htab->addWidget(new QLabel("  ", htab));
    htab->addWidget(must_isolate_cb = new QCheckBox(TR("must isolate"), htab));

    if (data->must_isolate)
        must_isolate_cb->setChecked(TRUE);

    must_isolate_cb->setDisabled(visit);
    htab->addWidget(new QLabel("", htab));

    VVBox * vtab;
    grid->addWidget(vtab = new VVBox(grid));
    vtab->addWidget(new QLabel(TR("description :"), vtab));

    SmallPushButton* b;
    if (! visit)
    {
        connect(b = new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()),
                this, SLOT(edit_description()));
        vtab->addWidget(b);
    }

    grid->addWidget(comment = new MultiLineEdit(grid));
    comment->setReadOnly(visit);
    comment->setText(bn->get_comment());
    QFont font = comment->font();

    if (! hasCodec())
        font.setFamily("Courier");

    font.setFixedPitch(TRUE);
    comment->setFont(font);

    addTab(grid, "Uml");

    // USER : list key - value

    grid = new GridBox(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(kvtable = new KeyValuesTable(bn, grid, visit));
    addTab(grid, TR("Properties"));

    //

    connect(this, SIGNAL(currentChanged(QWidget *)),
            this, SLOT(change_tabs(QWidget *)));

    open_dialog(this);
}
예제 #18
0
파일: grid.cpp 프로젝트: ibrahimmusba/ufoai
/**
 * @brief This function recalculates the routing surrounding the entity name.
 * @sa CM_InlineModel
 * @sa CM_CheckUnit
 * @sa CM_UpdateConnection
 * @sa CMod_LoadSubmodels
 * @sa Grid_RecalcBoxRouting
 * @param[in] mapTiles List of tiles the current (RMA-)map is composed of
 * @param[in] routing The routing map (either server or client map)
 * @param[in] name Name of the inline model to compute the mins/maxs for
 * @param[in] box The box around the inline model (alternative to name)
 * @param[in] list The local models list (a local model has a name starting with * followed by the model number)
 */
void Grid_RecalcRouting (mapTiles_t *mapTiles, Routing &routing, const char *name, const GridBox &box, const char **list)
{
	if (box.isZero()) {
		pos3_t min, max;
		vec3_t absmin, absmax;
		const cBspModel_t *model;
		unsigned int i;
		/* get inline model, if it is one */
		if (*name != '*') {
			Com_Printf("Called Grid_RecalcRouting with no inline model\n");
			return;
		}
		model = CM_InlineModel(mapTiles, name);
		if (!model) {
			Com_Printf("Called Grid_RecalcRouting with invalid inline model name '%s'\n", name);
			return;
		}

#if 1
		/* An attempt to fix the 'doors starting opened' bug (# 3456).
		 * The main difference is the (missing) rotation of the halfVec.
		 * The results are better, but do not fix the problem. */
		CalculateMinsMaxs(model->angles, model->mins, model->maxs, model->origin, absmin, absmax);
#else
		/* get the target model's dimensions */
		if (VectorNotEmpty(model->angles)) {
			vec3_t minVec, maxVec;
			vec3_t centerVec, halfVec, newCenterVec;
			vec3_t m[3];

			/* Find the center of the extents. */
			VectorCenterFromMinsMaxs(model->mins, model->maxs, centerVec);

			/* Find the half height and half width of the extents. */
			VectorSubtract(model->maxs, centerVec, halfVec);

			/* Rotate the center about the origin. */
			VectorCreateRotationMatrix(model->angles, m);
			VectorRotate(m, centerVec, newCenterVec);

			/* Set minVec and maxVec to bound around newCenterVec at halfVec size. */
			VectorSubtract(newCenterVec, halfVec, minVec);
			VectorAdd(newCenterVec, halfVec, maxVec);

			/* Now offset by origin then convert to position (Doors do not have 0 origins) */
			VectorAdd(minVec, model->origin, absmin);
			VectorAdd(maxVec, model->origin, absmax);
		} else {  /* normal */
			/* Now offset by origin then convert to position (Doors do not have 0 origins) */
			VectorAdd(model->mins, model->origin, absmin);
			VectorAdd(model->maxs, model->origin, absmax);
		}
#endif
		VecToPos(absmin, min);
		VecToPos(absmax, max);

		/* fit min/max into the world size */
		max[0] = std::min(max[0], (pos_t)(PATHFINDING_WIDTH - 1));
		max[1] = std::min(max[1], (pos_t)(PATHFINDING_WIDTH - 1));
		max[2] = std::min(max[2], (pos_t)(PATHFINDING_HEIGHT - 1));
		for (i = 0; i < 3; i++)
			min[i] = std::max(min[i], (pos_t)0);

		/* We now have the dimensions, call the generic rerouting function. */
		GridBox rerouteBox(min, max);
		Grid_RecalcBoxRouting(mapTiles, routing, rerouteBox, list);
	} else {
		/* use the passed box */
		Grid_RecalcBoxRouting(mapTiles, routing, box, list);
	}
}
예제 #19
0
SettingsDialog::SettingsDialog(StateSpecVector * st, ColorSpecVector * co,
                               bool nodefault, bool unchanged, QString title)
    : TabDialog(0, title.toLatin1().constData(), TRUE),
      states(st), colors(co), first_visible_page(0),
      several(unchanged), did_apply(FALSE)
{
    setWindowTitle((title.isEmpty()) ? QObject::tr("Diagram Drawing Settings dialog") : title);

    QString s_diagram = QObject::tr("diagram");

    QWidget * grid = 0;

    QString tabname;
    unsigned i;
    unsigned n;

    if (states != 0) {
        n = states->size();
        cbstates = new QHash<int,ComboStates*>;

        for (i = 0; i != n; i += 1) {
            StateSpec & st = states->at(i);
            QString s = st.name;
            int index = s.indexOf('#');
            QString tbn;

            if (index != -1) {
                tbn = s.left(index);
                s = s.mid(index + 1);
            }
            else
                tbn = s_diagram;

            if ((grid == 0) || (tabname != tbn)) {
                if (grid != 0) {
                    addTab(grid, tabname);
                    grid->setObjectName(tabname);
                    if (tabname == previous_active_tab)
                        first_visible_page = grid;
                }

                grid = WidgetWithLayout::gridBox(5, this);
                grid->layout()->setMargin(0);
                grid->layout()->setSpacing(0);
                tabname = tbn;
            }

            QGridLayout *gridLayout = (QGridLayout *)grid->layout();
            int currentRow = gridLayout->rowCount();
            //gridLayout->addWidget(new QLabel("", grid), currentRow, 0);
            gridLayout->addWidget(new QLabel(s + " : ", grid), currentRow, 1);
            QWidget * hb = WidgetWithLayout::hBox( grid);
            QHBoxLayout* hLayout;
            hLayout = (QHBoxLayout*)hb->layout();
            hLayout->setMargin(0);
            gridLayout->addWidget(hb,  currentRow, 2);

            ComboStates* widget;
            switch (st.who) {
            case StateSpec::is3states:
                cbstates->insert(i, widget = new ComboStates(hb, *((Uml3States *) st.state), nodefault, unchanged));
                break;

            case StateSpec::isClassDrawingMode:
                cbstates->insert(i, widget = new ComboStates(hb, *((ClassDrawingMode *) st.state),
                                                    nodefault, unchanged));
                break;

            case StateSpec::isDrawingLanguage:
                cbstates->insert(i, widget = new ComboStates(hb, *((DrawingLanguage *) st.state),
                                                    nodefault, unchanged));
                break;

            case StateSpec::isShowContextMode:
                cbstates->insert(i, widget = new ComboStates(hb, *((ShowContextMode *) st.state),
                                                    nodefault, unchanged));
                break;

            default:
                cbstates->insert(i, widget = new ComboStates(hb, *((char *) st.state),
                                                    nodefault, unchanged));
            }
            hLayout->addWidget(widget);
            hLayout->addWidget(new QLabel("", hb));
            gridLayout->addWidget(new QLabel("", grid),currentRow, 3);
            gridLayout->addWidget(new QLabel("", grid),currentRow, 4);
        }

        addTab(grid, tabname);
        grid->setObjectName(tabname);
        if (tabname == previous_active_tab)
            first_visible_page = grid;
    }

    if (colors != 0) {
        QString lbl = QObject::tr("color");
        QString s_default = QObject::tr("default ");

        n = colors->size();
        cbcolors = new QHash<int, ComboColor*>;
        GridBox *gridBox = new GridBox( 5, this);
        gridBox->setMargin(2);
        gridBox->setSpacing(2);

        for (i = 0; i != n; i += 1) {
            if (i == 11) {
                lbl = QObject::tr("color [1]");
                addTab(gridBox, lbl);
                gridBox->setObjectName(lbl);
                if (previous_active_tab == lbl)
                    first_visible_page = gridBox;

                lbl = QObject::tr("color [2]");
                gridBox = new GridBox(5, this);
                gridBox->setMargin(2);
                gridBox->setSpacing(2);
            }

            gridBox->addWidget(new QLabel("", grid));

            QString s = colors->at(i).name;

            s += " : ";
            gridBox->addWidget(new QLabel(s, grid));
            ComboColor *ccolor = new ComboColor(grid, *(colors->at(i).color),nodefault, unchanged);
            gridBox->addWidget(ccolor);
            cbcolors->insert(i, ccolor);
            gridBox->addWidget(new QLabel("", grid));
            gridBox->addWidget(new QLabel("", grid));
        }

        addTab(gridBox, lbl);
        gridBox->setObjectName(lbl);
        if (previous_active_tab == lbl)
            first_visible_page = gridBox;
    }
    setHelpButton(tr("Apply"));
    // use help rather than apply because when the OK button is clicked,
    // the applyButtonPressed() signal is emitted
    setOkButton(tr("OK"));
    setCancelButton(tr("Cancel"));

    connect(this, SIGNAL(helpButtonPressed()),
            this, SLOT(apply()));
    polish();

}