extern "C" void InitSceneSwitcher()
{
	QAction *action = (QAction*)obs_frontend_add_tools_menu_qaction(
			obs_module_text("SceneSwitcher"));

	switcher = new SwitcherData;

	auto cb = [] ()
	{
		obs_frontend_push_ui_translation(obs_module_get_string);

		QMainWindow *window =
			(QMainWindow*)obs_frontend_get_main_window();

		SceneSwitcher ss(window);
		ss.exec();

		obs_frontend_pop_ui_translation();
	};

	obs_frontend_add_save_callback(SaveSceneSwitcher, nullptr);
	obs_frontend_add_event_callback(OBSEvent, nullptr);

	action->connect(action, &QAction::triggered, cb);
}
Example #2
0
QList< QAction * > Inputs::getAddActions()
{
	QAction *actCD = new QAction( NULL );
	actCD->setObjectName( "actCD" );
	actCD->setIcon( QIcon( ":/cd" ) );
	actCD->setText( tr( "PÅ‚yta AudioCD" ) );
	actCD->connect( actCD, SIGNAL( triggered() ), this, SLOT( add() ) );

	QAction *actTone = new QAction( NULL );
	actTone->setObjectName( "actTone" );
	actTone->setIcon( QIcon( ":/sine" ) );
	actTone->setText( tr( "Generator częstotliwości" ) );
	actTone->connect( actTone, SIGNAL( triggered() ), this, SLOT( add() ) );

	return QList< QAction * >() << actCD << actTone;
}
Example #3
0
extern "C" void InitCaptions()
{
	QAction *action = (QAction*)obs_frontend_add_tools_menu_qaction(
			obs_module_text("Captions"));

	captions = new obs_captions;

	auto cb = [] ()
	{
		obs_frontend_push_ui_translation(obs_module_get_string);

		QWidget *window =
			(QWidget*)obs_frontend_get_main_window();

		CaptionsDialog dialog(window);
		dialog.exec();

		obs_frontend_pop_ui_translation();
	};

	obs_frontend_add_save_callback(save_caption_data, nullptr);
	obs_frontend_add_event_callback(obs_event, nullptr);

	action->connect(action, &QAction::triggered, cb);
}
Example #4
0
QList< QAction * > AudioCD::getAddActions()
{
	QAction *actCD = new QAction(NULL);
	actCD->setIcon(QIcon(":/AudioCD"));
	actCD->setText(tr("AudioCD"));
	actCD->connect(actCD, SIGNAL(triggered()), this, SLOT(add()));
	return QList< QAction * >() << actCD;
}
Example #5
0
QList< QAction * > Inputs::getAddActions()
{
	QAction *actTone = new QAction(NULL);
	actTone->setIcon(QIcon(":/sine"));
	actTone->setText(tr("Tone generator"));
	actTone->connect(actTone, SIGNAL(triggered()), this, SLOT(add()));
	return QList< QAction * >() << actTone;
}
TaskFemConstraintPressure::TaskFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView,QWidget *parent)
  : TaskFemConstraint(ConstraintView, parent, "fem-constraint-pressure")
{
    proxy = new QWidget(this);
    ui = new Ui_TaskFemConstraintPressure();
    ui->setupUi(proxy);
    QMetaObject::connectSlotsByName(this);

    QAction* action = new QAction(tr("Delete"), ui->lw_references);
    action->connect(action, SIGNAL(triggered()), this, SLOT(onReferenceDeleted()));
    ui->lw_references->addAction(action);
    ui->lw_references->setContextMenuPolicy(Qt::ActionsContextMenu);

    connect(ui->if_pressure, SIGNAL(valueChanged(Base::Quantity)),
            this, SLOT(onPressureChanged(Base::Quantity)));
    connect(ui->b_add_reference, SIGNAL(pressed()),
            this, SLOT(onButtonReference()));
    connect(ui->cb_reverse_direction, SIGNAL(toggled(bool)),
            this, SLOT(onCheckReverse(bool)));

    this->groupLayout()->addWidget(proxy);

    // Temporarily prevent unnecessary feature recomputes
    ui->if_pressure->blockSignals(true);
    ui->lw_references->blockSignals(true);
    ui->b_add_reference->blockSignals(true);
    ui->cb_reverse_direction->blockSignals(true);

    // Get the feature data
    Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
    double f = pcConstraint->Pressure.getValue();
    std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
    std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
    bool reversed = pcConstraint->Reversed.getValue();

    // Fill data into dialog elements
    ui->if_pressure->setMinimum(0);
    ui->if_pressure->setMaximum(FLOAT_MAX);
    //1000 because FreeCAD used kPa internally
    Base::Quantity p = Base::Quantity(1000 * f, Base::Unit::Stress);
    ui->if_pressure->setValue(p);
    ui->lw_references->clear();
    for (std::size_t i = 0; i < Objects.size(); i++) {
        ui->lw_references->addItem(makeRefText(Objects[i], SubElements[i]));
    }
    if (Objects.size() > 0) {
        ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
    }
    ui->cb_reverse_direction->setChecked(reversed);

    ui->if_pressure->blockSignals(false);
    ui->lw_references->blockSignals(false);
    ui->b_add_reference->blockSignals(false);
    ui->cb_reverse_direction->blockSignals(false);

    updateUI();
}
Example #7
0
/**
 * @brief Populate a QMenu from a node's menu definition called "menu_key"
 * @param menu The QMenu to populate
 * @param node The PlaylistNode the menu belongs to
 * @param menu_key The name of the menu
 */
inline void populate_menu(QMenu &menu, PlaylistNode* node, QString menu_key)
{
    for (QVariant e : node->property2<QVariantList>(menu_key))
    {
        QVariantMap entry = e.toMap();

        QAction *a = menu.addAction(entry["text"].toString());
        if (entry["action"].toString() == "call" && node->hasMethod(entry["method"].toString()))
            a->connect(a, &QAction::triggered, [entry, node](){
                node->call(entry["method"].toString(), entry.value("args").toList());
            });
        else
            a->setEnabled(false);
    }
}
Example #8
0
QConsoleWidgetPrivate::QConsoleWidgetPrivate(
        QConsoleWidget *s,QWidget *p
        ):
    QConsoleWidgetPrivateParent(p)
{
    super = s;
    positionX = 0;
    positionY = 0;
    {//TODO: font menu
        QMenu * menu = new QMenu(this);
        this->setMenu(menu);
        menu->setStyleSheet( MenuStyleSheet );
        this->setPopupMode(QToolButton::InstantPopup);
        typedef void(QAction::*AT)(bool);
        {
            QAction * action =
                    new QAction( trUtf8(u8"选择字体"), this);
            action->connect(action, AT(&QAction::triggered ),
                            [this](bool) { 
				selectAndSetFont(); }
            );
            menu->addAction(action);
			actions[0] = action;
        }
		{
			QAction * action =
                new QAction( trUtf8(u8"选择字体颜色"), this);
			action->connect(action, AT(&QAction::triggered),
				[this](bool) {
				selectAndSetFontColor(); }
			);
			actions[1] = action;
			menu->addAction(action);
		}
    }
}
TaskFemConstraintPressure::TaskFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView,QWidget *parent)
  : TaskFemConstraint(ConstraintView, parent, "fem-constraint-pressure")
{ //Note change "pressure" in line above to new constraint name
    proxy = new QWidget(this);
    ui = new Ui_TaskFemConstraintPressure();
    ui->setupUi(proxy);
    QMetaObject::connectSlotsByName(this);

    QAction* action = new QAction(tr("Delete"), ui->lw_references);
    action->connect(action, SIGNAL(triggered()), this, SLOT(onReferenceDeleted()));
    ui->lw_references->addAction(action);
    ui->lw_references->setContextMenuPolicy(Qt::ActionsContextMenu);

    connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
        this, SLOT(setSelection(QListWidgetItem*)));

    this->groupLayout()->addWidget(proxy);

/* Note: */
    // Get the feature data
    Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());

    std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
    std::vector<std::string> SubElements = pcConstraint->References.getSubValues();

    // Fill data into dialog elements
    ui->if_pressure->setMinimum(0);
    ui->if_pressure->setMaximum(FLOAT_MAX);
    Base::Quantity p = Base::Quantity(1000 * (pcConstraint->Pressure.getValue()), Base::Unit::Stress);
    ui->if_pressure->setValue(p);
    bool reversed = pcConstraint->Reversed.getValue();
    ui->checkBoxReverse->setChecked(reversed);
/* */

    ui->lw_references->clear();
    for (std::size_t i = 0; i < Objects.size(); i++) {
        ui->lw_references->addItem(makeRefText(Objects[i], SubElements[i]));
    }
    if (Objects.size() > 0) {
        ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
    }

    //Selection buttons
    connect(ui->btnAdd, SIGNAL(clicked()),  this, SLOT(addToSelection()));
    connect(ui->btnRemove, SIGNAL(clicked()),  this, SLOT(removeFromSelection()));

    updateUI();
}
TaskFemConstraintFixed::TaskFemConstraintFixed(ViewProviderFemConstraintFixed *ConstraintView,QWidget *parent)
    : TaskFemConstraint(ConstraintView, parent, "Fem_ConstraintFixed")
{
    // we need a separate container widget to add all controls to
    proxy = new QWidget(this);
    ui = new Ui_TaskFemConstraintFixed();
    ui->setupUi(proxy);
    QMetaObject::connectSlotsByName(this);

    // Create a context menu for the listview of the references
    QAction* action = new QAction(tr("Delete"), ui->listReferences);
    action->connect(action, SIGNAL(triggered()),
                    this, SLOT(onReferenceDeleted()));
    ui->listReferences->addAction(action);
    ui->listReferences->setContextMenuPolicy(Qt::ActionsContextMenu);

    connect(ui->buttonReference, SIGNAL(pressed()),
            this, SLOT(onButtonReference()));

    this->groupLayout()->addWidget(proxy);

    // Temporarily prevent unnecessary feature recomputes
    ui->listReferences->blockSignals(true);
    ui->buttonReference->blockSignals(true);

    // Get the feature data
    Fem::ConstraintFixed* pcConstraint = static_cast<Fem::ConstraintFixed*>(ConstraintView->getObject());
    std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
    std::vector<std::string> SubElements = pcConstraint->References.getSubValues();

    // Fill data into dialog elements
    ui->listReferences->clear();
    for (int i = 0; i < Objects.size(); i++)
        ui->listReferences->addItem(makeRefText(Objects[i], SubElements[i]));
    if (Objects.size() > 0)
        ui->listReferences->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);

    ui->listReferences->blockSignals(false);
    ui->buttonReference->blockSignals(false);

    // Selection mode can be always on since there is nothing else in the UI
    onButtonReference(true);
}
Example #11
0
extern "C" void InitScripts()
{
	scriptLogWindow = new ScriptLogWindow();

	obs_scripting_load();
	obs_scripting_set_log_callback(script_log, nullptr);

	QAction *action = (QAction*)obs_frontend_add_tools_menu_qaction(
			obs_module_text("Scripts"));

#if PYTHON_UI
	config_t *config = obs_frontend_get_global_config();
	const char *python_path = config_get_string(config, "Python",
			"Path" ARCH_NAME);

	if (!obs_scripting_python_loaded() && python_path && *python_path)
		obs_scripting_load_python(python_path);
#endif

	scriptData = new ScriptData;

	auto cb = [] ()
	{
		obs_frontend_push_ui_translation(obs_module_get_string);

		if (!scriptsWindow) {
			scriptsWindow = new ScriptsTool();
			scriptsWindow->show();
		} else {
			scriptsWindow->show();
			scriptsWindow->raise();
		}

		obs_frontend_pop_ui_translation();
	};

	obs_frontend_add_save_callback(save_script_data, nullptr);
	obs_frontend_add_preload_callback(load_script_data, nullptr);
	obs_frontend_add_event_callback(obs_event, nullptr);

	action->connect(action, &QAction::triggered, cb);
}
Example #12
0
LoadSaveState::LoadSaveState(GameController* controller, QWidget* parent)
	: QWidget(parent)
	, m_controller(controller)
	, m_currentFocus(controller->stateSlot() - 1)
	, m_mode(LoadSave::LOAD)
{
	setAttribute(Qt::WA_TranslucentBackground);
	m_ui.setupUi(this);

	m_slots[0] = m_ui.state1;
	m_slots[1] = m_ui.state2;
	m_slots[2] = m_ui.state3;
	m_slots[3] = m_ui.state4;
	m_slots[4] = m_ui.state5;
	m_slots[5] = m_ui.state6;
	m_slots[6] = m_ui.state7;
	m_slots[7] = m_ui.state8;
	m_slots[8] = m_ui.state9;

	unsigned width, height;
	controller->thread()->core->desiredVideoDimensions(controller->thread()->core, &width, &height);
	int i;
	for (i = 0; i < NUM_SLOTS; ++i) {
		loadState(i + 1);
		m_slots[i]->installEventFilter(this);
		m_slots[i]->setMaximumSize(width + 2, height + 2);
		connect(m_slots[i], &QAbstractButton::clicked, this, [this, i]() { triggerState(i + 1); });
	}

	if (m_currentFocus >= 9) {
		m_currentFocus = 0;
	}
	if (m_currentFocus < 0) {
		m_currentFocus = 0;
	}

	QAction* escape = new QAction(this);
	escape->connect(escape, SIGNAL(triggered()), this, SLOT(close()));
	escape->setShortcut(QKeySequence("Esc"));
	escape->setShortcutContext(Qt::WidgetWithChildrenShortcut);
	addAction(escape);
}
Example #13
0
extern "C" void InitOutputTimer()
{
	QAction *action = (QAction*)obs_frontend_add_tools_menu_qaction(
			obs_module_text("OutputTimer"));

	obs_frontend_push_ui_translation(obs_module_get_string);

	QMainWindow *window = (QMainWindow*)obs_frontend_get_main_window();

	ot = new OutputTimer(window);

	auto cb = [] ()
	{
		ot->ShowHideDialog();
	};

	obs_frontend_pop_ui_translation();

	obs_frontend_add_save_callback(SaveOutputTimer, nullptr);
	obs_frontend_add_event_callback(OBSEvent, nullptr);

	action->connect(action, &QAction::triggered, cb);
}
Example #14
0
void shortcuts::setStandardKeys(QWidget* widget)
{
  if (!widget)
    return;

  // Add standard shortcuts to applicable buttons
  bool hasShortcut = false;
  QPushButton* button;

  // For Save
  button = widget->findChild<QPushButton*>("_save");
  if (button)
  {
    button->setShortcut(QKeySequence::Save);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }
  if (!hasShortcut) // Because some screens have both
  {
    // For Post
    button = widget->findChild<QPushButton*>("_post");
    if (button)
    {
      button->setShortcut(QKeySequence::Save);
      button->setToolTip(button->text().remove("&")  + " " +
                         button->shortcut().toString(QKeySequence::NativeText));
    }
  }
  if (!hasShortcut)
  {
    QDialogButtonBox* bb = widget->findChild<QDialogButtonBox*>();
    if (bb)
    {
      QList<QAbstractButton*> buttons =  bb->buttons();
      for (int i = 0; i < buttons.size(); ++i)
      {
        QAbstractButton *bbutton = buttons.at(i);
        QDialogButtonBox::ButtonRole btnrole = bb->buttonRole(buttons.at(i));
        if (btnrole == QDialogButtonBox::AcceptRole)
        {
          bbutton->setShortcut(QKeySequence::Save);
          bbutton->setToolTip(bbutton->text().remove("&")  + " " +
                              bbutton->shortcut().toString(QKeySequence::NativeText));

        }
        else if (btnrole == QDialogButtonBox::RejectRole)
        {
          bbutton->setShortcut(QKeySequence::Close);
          bbutton->setToolTip(bbutton->text().remove("&")  + " " +
                              bbutton->shortcut().toString(QKeySequence::NativeText));

        }
      }
    }
  }

  // For Close
  hasShortcut = false;
  button = widget->findChild<QPushButton*>("_close");
  if (button)
  {
    button->setShortcut(QKeySequence::Close);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }
  if (!hasShortcut) // Because some screens have both
  {
    // For Post
    button = widget->findChild<QPushButton*>("_cancel");
    if (button)
    {
      button->setShortcut(QKeySequence::Close);
      button->setToolTip(button->text().remove("&")  + " " +
                         button->shortcut().toString(QKeySequence::NativeText));
    }
  }

  // For New
  button = widget->findChild<QPushButton*>("_new");
  if (button)
  {
    button->setShortcut(QKeySequence::New);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }

  // For Print
  button = widget->findChild<QPushButton*>("_print");
  if (button)
  {
    button->setShortcut(QKeySequence::Print);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }

  // For Query
  button = widget->findChild<QPushButton*>("_query");
  if (button)
  {
    button->setShortcut(QKeySequence::Refresh);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }

  // Page up/down for tab widgets
  QTabWidget* tab = widget->findChild<QTabWidget*>();
  if (tab)
  {
    TabWidgetNavigtor* tabNav = new TabWidgetNavigtor(tab, widget);
    QAction* pagedownAct = new QAction(tab);
    pagedownAct->setShortcut(QKeySequence::MoveToNextPage);
    pagedownAct->connect(pagedownAct, SIGNAL(triggered()), tabNav, SLOT(pageDown()));
    tab->addAction(pagedownAct);

    QAction* pageupAct = new QAction(tab);
    pageupAct->setShortcut(QKeySequence::MoveToPreviousPage);
    pageupAct->connect(pageupAct, SIGNAL(triggered()), tabNav, SLOT(pageUp()));
    tab->addAction(pageupAct);
  }
}
TaskFemConstraintTransform::TaskFemConstraintTransform(ViewProviderFemConstraintTransform *ConstraintView,QWidget *parent)
  : TaskFemConstraint(ConstraintView, parent, "fem-constraint-transform")
{
    proxy = new QWidget(this);
    ui = new Ui_TaskFemConstraintTransform();
    ui->setupUi(proxy);
    QMetaObject::connectSlotsByName(this);

    QAction* actionRect = new QAction(tr("Delete"), ui->lw_Rect);
    actionRect->connect(actionRect, SIGNAL(triggered()), this, SLOT(onReferenceDeleted()));
    ui->lw_Rect->addAction(actionRect);
    ui->lw_Rect->setContextMenuPolicy(Qt::ActionsContextMenu);

    connect(ui->lw_Rect, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
        this, SLOT(setSelection(QListWidgetItem*)));

    this->groupLayout()->addWidget(proxy);

    connect(ui->rb_rect, SIGNAL(clicked(bool)),  this, SLOT(Rect()));
    connect(ui->rb_cylin, SIGNAL(clicked(bool)),  this, SLOT(Cyl()));

    connect(ui->sp_X, SIGNAL(valueChanged(int)), this, SLOT(x_Changed(int)));
    connect(ui->sp_Y, SIGNAL(valueChanged(int)), this, SLOT(y_Changed(int)));
    connect(ui->sp_Z, SIGNAL(valueChanged(int)), this, SLOT(z_Changed(int)));

/* Note: */
    // Get the feature data
    Fem::ConstraintTransform* pcConstraint = static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());

    std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
    std::vector<std::string> SubElements = pcConstraint->References.getSubValues();

    // Fill data into dialog elements
    ui->sp_X->setValue(pcConstraint->X_rot.getValue());
    ui->sp_Y->setValue(pcConstraint->Y_rot.getValue());
    ui->sp_Z->setValue(pcConstraint->Z_rot.getValue());
    std::string transform_type = pcConstraint->TransformType.getValueAsString();
    if (transform_type == "Rectangular") {
        ui->sw_transform->setCurrentIndex(0);
        ui->rb_rect->setChecked(1);
        ui->rb_cylin->setChecked(0);
    } else if (transform_type == "Cylindrical") {
        ui->sw_transform->setCurrentIndex(1);
        ui->rb_rect->setChecked(0);
        ui->rb_cylin->setChecked(1);
    }

/* */

    ui->lw_Rect->clear();

    //Transformable surfaces
    Gui::Command::doCommand(Gui::Command::Doc,TaskFemConstraintTransform::getDisplcementReferences((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str());
    std::vector<App::DocumentObject*> ObjDispl = pcConstraint->RefDispl.getValues();
    std::vector<App::DocumentObject*> nDispl = pcConstraint->NameDispl.getValues();
    std::vector<std::string> SubElemDispl = pcConstraint->RefDispl.getSubValues();

    for (std::size_t i = 0; i < ObjDispl.size(); i++) {
        ui->lw_displobj_rect->addItem(makeRefText(ObjDispl[i], SubElemDispl[i]));
        ui->lw_displobj_cylin->addItem(makeRefText(ObjDispl[i], SubElemDispl[i]));
        ui->lw_dis_rect->addItem(makeText(nDispl[i]));
        ui->lw_dis_cylin->addItem(makeText(nDispl[i]));
    }

    if (Objects.size() > 0) {
        for (std::size_t i = 0; i < Objects.size(); i++) {
            ui->lw_Rect->addItem(makeRefText(Objects[i], SubElements[i]));
        }
    }
    int p = 0;
    for (std::size_t i = 0; i < ObjDispl.size(); i++) {
        for (std::size_t j = 0; j < Objects.size(); j++) {
            if ((makeRefText(ObjDispl[i], SubElemDispl[i]))==(makeRefText(Objects[j], SubElements[j]))){
                p++;
            }
        }
    }
    //Selection buttons
    connect(ui->btnAdd, SIGNAL(clicked()),  this, SLOT(addToSelection()));
    connect(ui->btnRemove, SIGNAL(clicked()),  this, SLOT(removeFromSelection()));

    updateUI();
    if ((p==0) && (Objects.size() > 0)) {
        QMessageBox::warning(this, tr("Constraint update error"), tr("The transformable faces have changed. Please add only the transformable faces and remove non-transformable faces!"));
        return;
    }
}
TaskMultiTransformParameters::TaskMultiTransformParameters(ViewProviderTransformed *TransformedView,QWidget *parent)
    : TaskTransformedParameters(TransformedView, parent), subTask(nullptr), subFeature(nullptr)
{
    // we need a separate container widget to add all controls to
    proxy = new QWidget(this);
    ui = new Ui_TaskMultiTransformParameters();
    ui->setupUi(proxy);
    QMetaObject::connectSlotsByName(this);
    this->groupLayout()->addWidget(proxy);

    connect(ui->buttonAddFeature, SIGNAL(toggled(bool)), this, SLOT(onButtonAddFeature(bool)));
    connect(ui->buttonRemoveFeature, SIGNAL(toggled(bool)), this, SLOT(onButtonRemoveFeature(bool)));
    // Create context menu
    QAction* action = new QAction(tr("Remove"), this);
    ui->listWidgetFeatures->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onFeatureDeleted()));
    ui->listWidgetFeatures->setContextMenuPolicy(Qt::ActionsContextMenu);

    // Create a context menu for the listview of transformation features
    action = new QAction(tr("Edit"), ui->listTransformFeatures);
    action->connect(action, SIGNAL(triggered()),
                    this, SLOT(onTransformEdit()));
    ui->listTransformFeatures->addAction(action);
    action = new QAction(tr("Delete"), ui->listTransformFeatures);
    action->connect(action, SIGNAL(triggered()),
                    this, SLOT(onTransformDelete()));
    ui->listTransformFeatures->addAction(action);
    action = new QAction(tr("Add mirrored transformation"), ui->listTransformFeatures);
    action->connect(action, SIGNAL(triggered()),
                    this, SLOT(onTransformAddMirrored()));
    ui->listTransformFeatures->addAction(action);
    action = new QAction(tr("Add linear pattern"), ui->listTransformFeatures);
    action->connect(action, SIGNAL(triggered()),
                    this, SLOT(onTransformAddLinearPattern()));
    ui->listTransformFeatures->addAction(action);
    action = new QAction(tr("Add polar pattern"), ui->listTransformFeatures);
    action->connect(action, SIGNAL(triggered()),
                    this, SLOT(onTransformAddPolarPattern()));
    ui->listTransformFeatures->addAction(action);
    action = new QAction(tr("Add scaled transformation"), ui->listTransformFeatures);
    action->connect(action, SIGNAL(triggered()),
                    this, SLOT(onTransformAddScaled()));
    ui->listTransformFeatures->addAction(action);
    action = new QAction(tr("Move up"), ui->listTransformFeatures);
    action->connect(action, SIGNAL(triggered()),
                    this, SLOT(onMoveUp()));
    ui->listTransformFeatures->addAction(action);
    action = new QAction(tr("Move down"), ui->listTransformFeatures);
    action->connect(action, SIGNAL(triggered()),
                    this, SLOT(onMoveDown()));
    ui->listTransformFeatures->addAction(action);
    ui->listTransformFeatures->setContextMenuPolicy(Qt::ActionsContextMenu);
    connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
            this, SLOT(onUpdateView(bool)));

    connect(ui->listTransformFeatures, SIGNAL(activated(QModelIndex)),
            this, SLOT(onTransformActivated(QModelIndex)));

    // Get the transformFeatures data
    PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(TransformedView->getObject());
    std::vector<App::DocumentObject*> transformFeatures = pcMultiTransform->Transformations.getValues();

    // Fill data into dialog elements
    ui->listTransformFeatures->setEnabled(true);
    ui->listTransformFeatures->clear();
    for (std::vector<App::DocumentObject*>::const_iterator i = transformFeatures.begin(); i != transformFeatures.end(); i++)
    {
        if ((*i) != NULL)
            ui->listTransformFeatures->addItem(QString::fromLatin1((*i)->Label.getValue()));
    }
    if (transformFeatures.size() > 0) {
        ui->listTransformFeatures->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
        editHint = false;
    } else {
        ui->listTransformFeatures->addItem(tr("Right-click to add"));
        editHint = true;
    }

    // Get the Originals data
    std::vector<App::DocumentObject*> originals = pcMultiTransform->Originals.getValues();

    // Fill data into dialog elements
    for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); i++)
    {
        if ((*i) != NULL)
            ui->listWidgetFeatures->addItem(QString::fromLatin1((*i)->getNameInDocument()));
    }
    // ---------------------
}
TaskFemConstraintBearing::TaskFemConstraintBearing(ViewProviderFemConstraint *ConstraintView,QWidget *parent,
                                                   const char *pixmapname)
    : TaskFemConstraint(ConstraintView, parent, pixmapname)
{
    // we need a separate container widget to add all controls to
    proxy = new QWidget(this);
    ui = new Ui_TaskFemConstraintBearing();
    ui->setupUi(proxy);
    QMetaObject::connectSlotsByName(this);

    // Create a context menu for the listview of the references
    QAction* action = new QAction(tr("Delete"), ui->listReferences);
    action->connect(action, SIGNAL(triggered()),
                    this, SLOT(onReferenceDeleted()));
    ui->listReferences->addAction(action);
    ui->listReferences->setContextMenuPolicy(Qt::ActionsContextMenu);

    connect(ui->spinDistance, SIGNAL(valueChanged(double)),
            this, SLOT(onDistanceChanged(double)));
    connect(ui->buttonReference, SIGNAL(pressed()),
            this, SLOT(onButtonReference()));
    connect(ui->buttonLocation, SIGNAL(pressed()),
            this, SLOT(onButtonLocation()));
    connect(ui->checkAxial, SIGNAL(toggled(bool)),
            this, SLOT(onCheckAxial(bool)));

    this->groupLayout()->addWidget(proxy);

    // Temporarily prevent unnecessary feature recomputes
    ui->spinDistance->blockSignals(true);
    ui->listReferences->blockSignals(true);
    ui->buttonReference->blockSignals(true);
    ui->buttonLocation->blockSignals(true);
    ui->checkAxial->blockSignals(true);

    // Get the feature data
    Fem::ConstraintBearing* pcConstraint = static_cast<Fem::ConstraintBearing*>(ConstraintView->getObject());
    double d = pcConstraint->Dist.getValue();
    std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
    std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
    std::vector<std::string> locStrings = pcConstraint->Location.getSubValues();
    QString loc;
    if (!locStrings.empty())
        loc = makeRefText(pcConstraint->Location.getValue(), locStrings.front());
    bool axialfree = pcConstraint->AxialFree.getValue();

    // Fill data into dialog elements
    ui->spinDistance->setMinimum(-FLOAT_MAX);
    ui->spinDistance->setMaximum(FLOAT_MAX);
    ui->spinDistance->setValue(d);
    ui->listReferences->clear();
    for (std::size_t i = 0; i < Objects.size(); i++)
        ui->listReferences->addItem(makeRefText(Objects[i], SubElements[i]));
    if (Objects.size() > 0)
        ui->listReferences->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
    ui->lineLocation->setText(loc);
    ui->checkAxial->setChecked(axialfree);

    // Hide unwanted ui elements
    ui->labelDiameter->setVisible(false);
    ui->spinDiameter->setVisible(false);
    ui->labelOtherDiameter->setVisible(false);
    ui->spinOtherDiameter->setVisible(false);
    ui->labelCenterDistance->setVisible(false);
    ui->spinCenterDistance->setVisible(false);
    ui->checkIsDriven->setVisible(false);
    ui->labelForce->setVisible(false);
    ui->spinForce->setVisible(false);
    ui->labelTensionForce->setVisible(false);
    ui->spinTensionForce->setVisible(false);
    ui->labelForceAngle->setVisible(false);
    ui->spinForceAngle->setVisible(false);
    ui->buttonDirection->setVisible(false);
    ui->lineDirection->setVisible(false);
    ui->checkReversed->setVisible(false);

    ui->spinDistance->blockSignals(false);
    ui->listReferences->blockSignals(false);
    ui->buttonReference->blockSignals(false);
    ui->buttonLocation->blockSignals(false);
    ui->checkAxial->blockSignals(false);

    onButtonReference(true);
}
TaskFemConstraintContact::TaskFemConstraintContact(ViewProviderFemConstraintContact *ConstraintView,QWidget *parent)
  : TaskFemConstraint(ConstraintView, parent, "fem-constraint-contact")
{
    proxy = new QWidget(this);
    ui = new Ui_TaskFemConstraintContact();
    ui->setupUi(proxy);
    QMetaObject::connectSlotsByName(this);

    QAction* actionSlave = new QAction(tr("Delete"), ui->lw_referencesSlave);
    actionSlave->connect(actionSlave, SIGNAL(triggered()), this, SLOT(onReferenceDeletedSlave()));

    QAction* actionMaster = new QAction(tr("Delete"), ui->lw_referencesMaster);
    actionMaster->connect(actionMaster, SIGNAL(triggered()), this, SLOT(onReferenceDeletedMaster()));

    ui->lw_referencesSlave->addAction(actionSlave);
    ui->lw_referencesSlave->setContextMenuPolicy(Qt::ActionsContextMenu);

    connect(ui->lw_referencesSlave, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
        this, SLOT(setSelection(QListWidgetItem*)));

    ui->lw_referencesMaster->addAction(actionMaster);
    ui->lw_referencesMaster->setContextMenuPolicy(Qt::ActionsContextMenu);

    connect(ui->lw_referencesMaster, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
        this, SLOT(setSelection(QListWidgetItem*)));

    this->groupLayout()->addWidget(proxy);

/* Note: */
    // Get the feature data
    Fem::ConstraintContact* pcConstraint = static_cast<Fem::ConstraintContact*>(ConstraintView->getObject());

    std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
    std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
    double S = pcConstraint->Slope.getValue();
    double F = pcConstraint->Friction.getValue();

    // Fill data into dialog elements
    ui->spSlope->setMinimum(1.0);
    ui->spSlope->setValue(S);
    ui->spFriction->setValue(F);

/* */

    ui->lw_referencesMaster->clear();
    ui->lw_referencesSlave->clear();
    if (Objects.size() > 0){
        for (std::size_t i = 1; i < Objects.size(); i++) {
           ui->lw_referencesMaster->addItem(makeRefText(Objects[i], SubElements[i]));
        }

        for (std::size_t i = 0; i < (Objects.size()-1); i++) {
          ui->lw_referencesSlave->addItem(makeRefText(Objects[i], SubElements[i]));
        }
}

    //Selection buttons
    connect(ui->btnAddSlave, SIGNAL(clicked()),  this, SLOT(addToSelectionSlave()));
    connect(ui->btnRemoveSlave, SIGNAL(clicked()),  this, SLOT(removeFromSelectionSlave()));

    connect(ui->btnAddMaster, SIGNAL(clicked()),  this, SLOT(addToSelectionMaster()));
    connect(ui->btnRemoveMaster, SIGNAL(clicked()),  this, SLOT(removeFromSelectionMaster()));

    updateUI();
}
/* TRANSLATOR FemGui::TaskFemConstraintFluidBoundary */
TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(ViewProviderFemConstraintFluidBoundary *ConstraintView,QWidget *parent)
    : TaskFemConstraint(ConstraintView, parent, "fem-constraint-fluid-boundary")
{
    // we need a separate container widget to add all controls to
    proxy = new QWidget(this);
    ui = new Ui_TaskFemConstraintFluidBoundary();
    ui->setupUi(proxy);
    QMetaObject::connectSlotsByName(this);

    // Create a context menu for the listview of the references
    QAction* action = new QAction(tr("Delete"), ui->listReferences);
    action->connect(action, SIGNAL(triggered()),
                    this, SLOT(onReferenceDeleted()));
    ui->listReferences->addAction(action);
    ui->listReferences->setContextMenuPolicy(Qt::ActionsContextMenu);

    connect(ui->comboBoundaryType, SIGNAL(currentIndexChanged(int)),
            this, SLOT(onBoundaryTypeChanged(void)));
    connect(ui->comboSubtype, SIGNAL(currentIndexChanged(int)),
            this, SLOT(onSubtypeChanged(void)));
    connect(ui->spinBoundaryValue, SIGNAL(valueChanged(double)),
            this, SLOT(onBoundaryValueChanged(double)));
            
    connect(ui->comboTurbulenceSpecification, SIGNAL(currentIndexChanged(int)),
            this, SLOT(onTurbulenceSpecificationChanged(void)));
    connect(ui->comboThermalBoundaryType, SIGNAL(currentIndexChanged(int)),
            this, SLOT(onThermalBoundaryTypeChanged(void)));
            
    connect(ui->buttonReference, SIGNAL(pressed()),
            this, SLOT(onButtonReference()));
    connect(ui->buttonDirection, SIGNAL(pressed()),
            this, SLOT(onButtonDirection()));
    connect(ui->checkReverse, SIGNAL(toggled(bool)),
            this, SLOT(onCheckReverse(bool)));

    this->groupLayout()->addWidget(proxy);

    // Temporarily prevent unnecessary feature recomputes
    ui->spinBoundaryValue->blockSignals(true);
    ui->listReferences->blockSignals(true);
    
    ui->buttonReference->blockSignals(true);
    ui->buttonDirection->blockSignals(true);
    ui->checkReverse->blockSignals(true);

    // Get the feature data
    Fem::ConstraintFluidBoundary* pcConstraint = static_cast<Fem::ConstraintFluidBoundary*>(ConstraintView->getObject());
    
    Fem::FemSolverObject* pcSolver = NULL;
    if (FemGui::ActiveAnalysisObserver::instance()->hasActiveObject()) {
        Fem::FemAnalysis* pcAnalysis = FemGui::ActiveAnalysisObserver::instance()->getActiveObject();
        //Fem::FemSolverObject is derived from DocumentObject
        std::vector<App::DocumentObject*> fem = pcAnalysis->Member.getValues();
        for (std::vector<App::DocumentObject*>::iterator it = fem.begin(); it != fem.end(); ++it) {
            if ((*it)->getTypeId().isDerivedFrom(Fem::FemSolverObject::getClassTypeId()))
                pcSolver = static_cast<Fem::FemSolverObject*>(*it);
        }
    }
    pHeatTransfering = NULL;
    pTurbulenceModel = NULL;
    if (pcSolver != NULL) {
        //if only it is CFD solver, otherwise  exit by SIGSEGV error,  detect  getPropertyByName() !=  NULL
        if (pcSolver->getPropertyByName("HeatTransfering")) {
            pHeatTransfering = static_cast<App::PropertyBool*>(pcSolver->getPropertyByName("HeatTransfering"));
            if (pHeatTransfering->getValue()) {
                ui->tabThermalBoundary->setEnabled(true);
                initComboBox(ui->comboThermalBoundaryType, pcConstraint->ThermalBoundaryType.getEnumVector(), 
                                pcConstraint->ThermalBoundaryType.getValueAsString());
                updateThermalBoundaryUI();               
            }
            else {
                ui->tabThermalBoundary->setEnabled(false);
                //Base::Console().Message("retrieve solver property HeatTransfering as false\n");
            } 
        }
        else {
            ui->tabThermalBoundary->setEnabled(false);
        }
        if (pcSolver->getPropertyByName("TurbulenceModel")) {
            pTurbulenceModel = static_cast<App::PropertyEnumeration*>(pcSolver->getPropertyByName("TurbulenceModel"));
            if (pTurbulenceModel->getValueAsString() == std::string("laminar")){
                ui->tabTurbulenceBoundary->setEnabled(false);
            }
            else {
                ui->tabTurbulenceBoundary->setEnabled(true);
                ui->labelTurbulenceSpecification->setText(Base::Tools::fromStdString(
                            pTurbulenceModel->getValueAsString()));
                initComboBox(ui->comboTurbulenceSpecification, pcConstraint->TurbulenceSpecification.getEnumVector(), 
                            pcConstraint->TurbulenceSpecification.getValueAsString());
                updateTurbulenceUI();   
            }
        }
        else {
            ui->tabTurbulenceBoundary->setEnabled(false);
        }
    }
    else {
        Base::Console().Message("Warning: No solver object inside FemAnalysis object\n");
    }
    ui->tabWidget->setTabText(0, tr("Basic"));
    ui->tabWidget->setTabText(1, tr("Turbulence"));
    ui->tabWidget->setTabText(2, tr("Thermal"));
    ui->tabWidget->setCurrentIndex(0);
    ui->labelHelpText->setText(tr("select boundary type, faces and set value"));

    initComboBox(ui->comboBoundaryType, pcConstraint->BoundaryType.getEnumVector(), 
                 pcConstraint->BoundaryType.getValueAsString());
    updateBoundaryTypeUI();
    //updateSubtypeUI(); // already called inside updateBoundaryTypeUI();
    
    std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
    std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
    std::vector<std::string> dirStrings = pcConstraint->Direction.getSubValues();
    QString dir;
    if (!dirStrings.empty())
        dir = makeRefText(pcConstraint->Direction.getValue(), dirStrings.front());

    // Fill data into dialog elements
    double f = pcConstraint->BoundaryValue.getValue();
    ui->spinBoundaryValue->setMinimum(0);
    ui->spinBoundaryValue->setMaximum(FLOAT_MAX);
    ui->spinBoundaryValue->setValue(f);
    ui->listReferences->clear();
    for (std::size_t i = 0; i < Objects.size(); i++)
        ui->listReferences->addItem(makeRefText(Objects[i], SubElements[i]));
    if (Objects.size() > 0)
        ui->listReferences->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
    ui->lineDirection->setText(dir.isEmpty() ? tr("") : dir);
    ui->checkReverse->setVisible(false); // no need such UI for fluid boundary, set by cpp code only

    ui->listReferences->blockSignals(false);
    ui->buttonReference->blockSignals(false);

    ui->spinBoundaryValue->blockSignals(false);
    ui->buttonDirection->blockSignals(false);
    ui->checkReverse->blockSignals(false);
    updateSelectionUI();
}
TaskFemConstraintTemperature::TaskFemConstraintTemperature(ViewProviderFemConstraintTemperature *ConstraintView,QWidget *parent)
  : TaskFemConstraint(ConstraintView, parent, "fem-constraint-temperature")
{
    proxy = new QWidget(this);
    ui = new Ui_TaskFemConstraintTemperature();
    ui->setupUi(proxy);
    QMetaObject::connectSlotsByName(this);

    QAction* action = new QAction(tr("Delete"), ui->lw_references);
    action->connect(action, SIGNAL(triggered()), this, SLOT(onReferenceDeleted()));
    ui->lw_references->addAction(action);
    ui->lw_references->setContextMenuPolicy(Qt::ActionsContextMenu);

    connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
        this, SLOT(setSelection(QListWidgetItem*)));
    connect(ui->rb_temperature, SIGNAL(clicked(bool)),  this, SLOT(Temp()));
    connect(ui->rb_cflux, SIGNAL(clicked(bool)),  this, SLOT(Flux()));

    connect(ui->if_temperature, SIGNAL(valueChanged(double)),
            this, SLOT(onTempCfluxChanged(double)));

    this->groupLayout()->addWidget(proxy);

    // Get the feature data
    Fem::ConstraintTemperature* pcConstraint = static_cast<Fem::ConstraintTemperature*>(ConstraintView->getObject());

    std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
    std::vector<std::string> SubElements = pcConstraint->References.getSubValues();

    // Fill data into dialog elements
    ui->if_temperature->setMinimum(0);
    ui->if_temperature->setMaximum(FLOAT_MAX);

    std::string constraint_type = pcConstraint->ConstraintType.getValueAsString();
    if (constraint_type == "Temperature") {
        ui->rb_temperature->setChecked(1);
        std::string str = "Temperature";
        QString qstr = QString::fromStdString(str);
        ui->lbl_type->setText(qstr);
        Base::Quantity t = Base::Quantity(pcConstraint->Temperature.getValue(), Base::Unit::Temperature);
        ui->if_temperature->setValue(t);
    } else if (constraint_type == "CFlux") {
        ui->rb_cflux->setChecked(1);
        std::string str = "Concentrated heat flux";
        QString qstr = QString::fromStdString(str);
        ui->lbl_type->setText(qstr);
        Base::Quantity c = Base::Quantity(pcConstraint->CFlux.getValue(), Base::Unit::Power);
        ui->if_temperature->setValue(c);
    }

    ui->lw_references->clear();
    for (std::size_t i = 0; i < Objects.size(); i++) {
        ui->lw_references->addItem(makeRefText(Objects[i], SubElements[i]));
    }
    if (Objects.size() > 0) {
        ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
    }

    //Selection buttons
    connect(ui->btnAdd, SIGNAL(clicked()),  this, SLOT(addToSelection()));
    connect(ui->btnRemove, SIGNAL(clicked()),  this, SLOT(removeFromSelection()));

    updateUI();
}
TaskFemConstraintForce::TaskFemConstraintForce(ViewProviderFemConstraintForce *ConstraintView,QWidget *parent)
    : TaskFemConstraint(ConstraintView, parent, "Fem_ConstraintForce")
{
    // we need a separate container widget to add all controls to
    proxy = new QWidget(this);
    ui = new Ui_TaskFemConstraintForce();
    ui->setupUi(proxy);
    QMetaObject::connectSlotsByName(this);

    // Create a context menu for the listview of the references
    QAction* action = new QAction(tr("Delete"), ui->listReferences);
    action->connect(action, SIGNAL(triggered()),
                    this, SLOT(onReferenceDeleted()));
    ui->listReferences->addAction(action);
    ui->listReferences->setContextMenuPolicy(Qt::ActionsContextMenu);

    connect(ui->spinForce, SIGNAL(valueChanged(double)),
            this, SLOT(onForceChanged(double)));
    connect(ui->buttonReference, SIGNAL(pressed()),
            this, SLOT(onButtonReference()));
    connect(ui->buttonDirection, SIGNAL(pressed()),
            this, SLOT(onButtonDirection()));
    connect(ui->checkReverse, SIGNAL(toggled(bool)),
            this, SLOT(onCheckReverse(bool)));

    this->groupLayout()->addWidget(proxy);

    // Temporarily prevent unnecessary feature recomputes
    ui->spinForce->blockSignals(true);
    ui->listReferences->blockSignals(true);
    ui->buttonReference->blockSignals(true);
    ui->buttonDirection->blockSignals(true);
    ui->checkReverse->blockSignals(true);

    // Get the feature data
    Fem::ConstraintForce* pcConstraint = static_cast<Fem::ConstraintForce*>(ConstraintView->getObject());
    double f = pcConstraint->Force.getValue();
    std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
    std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
    std::vector<std::string> dirStrings = pcConstraint->Direction.getSubValues();
    QString dir;
    if (!dirStrings.empty())
        dir = makeRefText(pcConstraint->Direction.getValue(), dirStrings.front());
    bool reversed = pcConstraint->Reversed.getValue();

    // Fill data into dialog elements
    ui->spinForce->setMinimum(0);
    ui->spinForce->setMaximum(FLOAT_MAX);
    ui->spinForce->setValue(f);
    ui->listReferences->clear();
    for (std::size_t i = 0; i < Objects.size(); i++)
        ui->listReferences->addItem(makeRefText(Objects[i], SubElements[i]));
    if (Objects.size() > 0)
        ui->listReferences->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
    ui->lineDirection->setText(dir.isEmpty() ? tr("") : dir);
    ui->checkReverse->setChecked(reversed);

    ui->spinForce->blockSignals(false);
    ui->listReferences->blockSignals(false);
    ui->buttonReference->blockSignals(false);
    ui->buttonDirection->blockSignals(false);
    ui->checkReverse->blockSignals(false);

    updateUI();
}