24 #include <QFileDialog>
25 #include <QHBoxLayout>
28 #include <QToolButton>
34 #include "GuiHelperAction.h"
43 int group,
int param) :
QObject() {
49 p_fileButton =
new QToolButton();
50 p_lineEdit =
new QLineEdit();
52 p_label =
new QLabel(p_name);
53 p_label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
54 p_label->setToolTip(p_ui->
ParamBrief(group, param));
55 grid->addWidget(p_label, param, 0, Qt::AlignCenter);
58 whatsThis = (QString)(
"<b>Parameter:</b> " + p_ui->
ParamName(group, param));
59 whatsThis += (QString)(
"<p><b>Type:</b> " + p_ui->
ParamType(group, param) +
"</p>");
60 whatsThis += (QString)(
"<p><b>Brief:</b> " + p_ui->
ParamBrief(group, param) +
"</p>");
62 if(def ==
"") def =
"None";
63 whatsThis +=
"<p><b>Default: </b>" + QString(def) +
"</p>";
66 whatsThis +=
"<p><b>Internal Default: </b> " + QString(intdef) +
"</p>";
68 QString pixtype = p_ui->
PixelType(group, param);
70 whatsThis +=
"<p><b>Pixel Type: </b> " + QString(pixtype) +
"</p>";
75 whatsThis +=
"<p><b>Greater Than Or Equal To: </b>" +
76 QString(pmin) +
"</p>";
79 whatsThis +=
"<p><b>Greater Than: </b>" + QString(pmin) +
"</p>";
85 whatsThis +=
"<p><b>Less Than Or Equal To: </b>" +
86 QString(pmax) +
"</p>";
89 whatsThis +=
"<p><b>Less Than: </b>" + QString(pmax) +
"</p>";
93 whatsThis +=
"<p><b>Less Than: </b>" +
96 whatsThis +=
", " + QString(p_ui->
ParamLessThan(group, param, l));
101 whatsThis +=
"<p><b>Less Than Or Equal: </b>" +
110 whatsThis +=
"<p><b>Not Equal: </b>" +
113 whatsThis +=
", " + QString(p_ui->
ParamNotEqual(group, param, l));
118 whatsThis +=
"<p><b>Greater Than: </b>" +
127 whatsThis +=
"<p><b>Greater Than Or Equal: </b>" +
136 whatsThis +=
"<p><b>Inclusions: </b>" +
145 whatsThis +=
"<p><b>Exclusions: </b>" +
153 if(p_ui->
ParamOdd(group, param) !=
"") {
154 whatsThis +=
"<p><b>Odd: </b>" +
155 QString(p_ui->
ParamOdd(group, param)) +
"</p>";
157 p_label->setWhatsThis(whatsThis);
170 p_widgetList.clear();
200 if(Value() == p_ui->
ParamDefault(p_group, p_param))
return false;
206 if(Value() ==
"")
return false;
216 else if(p_ui->
ParamDefault(p_group, p_param).size() > 0) {
229 p_widgetList.push_back(w);
234 if(p_type != ComboWidget) {
235 p_label->setEnabled(enabled);
236 p_label->setVisible(
true);
237 if(isParentCombo && !enabled) {
238 p_label->setVisible(
false);
240 for(
int i = 0; i < p_widgetList.size(); i++) {
241 p_widgetList[i]->setEnabled(enabled);
242 p_widgetList[i]->setVisible(
true);
243 if(isParentCombo && !enabled) {
244 p_widgetList[i]->setVisible(
false);
249 p_label->setEnabled(enabled);
250 p_widgetList[0]->setEnabled(enabled);
256 std::vector<QString> list;
266 if(p_ui->
HelperIcon(p_group, p_param, 0) !=
"") {
268 p_ui->
HelperIcon(p_group, p_param, 0)).expanded();
269 action->setIcon(QIcon(QPixmap(file)));
274 action->setToolTip(p_ui->
HelperBrief(p_group, p_param, 0));
275 QString helperText =
"<p><b>Function:</b> " +
277 action->setWhatsThis(helperText);
278 connect(action, SIGNAL(trigger(
const QString &)),
this,
279 SIGNAL(HelperTrigger(
const QString &)));
281 QToolButton *helper =
new QToolButton();
283 helper->setDefaultAction(action);
285 if(p_ui->
HelperIcon(p_group, p_param, 0) !=
"") {
288 p_ui->
HelperIcon(p_group, p_param, 0)).expanded();
289 helper->setIconSize(QSize(22, 22));
290 helper->setIcon(QIcon(QPixmap(file)));
293 helper->setFixedWidth(helper->fontMetrics().width(
294 " " + helper->text() +
" "));
304 "Can not call GuiParameter::AddHelpers twice",
308 p_helperMenu =
new QMenu();
313 if(p_ui->
HelperIcon(p_group, p_param, 0) !=
"") {
315 p_ui->
HelperIcon(p_group, p_param, 0)).expanded();
316 action->setIcon(QIcon(QPixmap(file)));
321 connect(action, SIGNAL(trigger(
const QString &)),
this,
322 SIGNAL(HelperTrigger(
const QString &)));
325 QToolButton *helper =
new QToolButton();
328 helper->setMenu(p_helperMenu);
329 helper->setPopupMode(QToolButton::MenuButtonPopup);
330 helper->setDefaultAction(action);
331 helper->setToolTip(p_ui->
HelperBrief(p_group, p_param, 0));
332 QString text =
"<p><b>Function:</b> " +
334 "<p><b>Hint: </b> Click on the arrow to see more helper functions</p>";
335 helper->setWhatsThis(text);
337 if(p_ui->
HelperIcon(p_group, p_param, 0) !=
"") {
340 p_ui->
HelperIcon(p_group, p_param, 0)).expanded();
341 helper->setIconSize(QSize(22, 22));
342 helper->setIcon(QIcon(QPixmap(file)));
345 helper->setFixedWidth(helper->fontMetrics().width(
346 " " + helper->text() +
" "));
352 action2->setText(p_ui->
HelperBrief(p_group, p_param, 0));
353 action2->setToolTip(p_ui->
HelperBrief(p_group, p_param, 0));
354 QString helperText =
"<p><b>Function:</b> " +
356 action2->setWhatsThis(helperText);
357 connect(action2, SIGNAL(trigger(
const QString &)),
this,
358 SIGNAL(HelperTrigger(
const QString &)));
359 p_helperMenu->addAction(action2);
363 for(
int i = 1; i < p_ui->
HelpersSize(p_group, p_param); i++) {
366 helperAction->setText(p_ui->
HelperBrief(p_group, p_param, i));
367 helperAction->setToolTip(p_ui->
HelperBrief(p_group, p_param, i));
368 QString helperText =
"<p><b>Function:</b> " +
370 helperAction->setWhatsThis(helperText);
371 connect(helperAction, SIGNAL(trigger(
const QString &)),
this,
372 SIGNAL(HelperTrigger(
const QString &)));
373 p_helperMenu->addAction(helperAction);
virtual ~GuiParameter()
Destructor.
int ParamIncludeSize(const int &group, const int ¶m) const
Returns the number of parameters included in this parameter's inclusions.
void SetEnabled(bool enabled, bool isParentCombo=false)
Enable or disable the parameter.
QString ParamDefault(const int &group, const int ¶m) const
Returns the default for a parameter in a specified group.
File name manipulation and expansion.
int HelpersSize(const int &group, const int ¶m) const
Returns the number of helpers the parameter has.
QString ParamMinimum(const int &group, const int ¶m) const
Returns the minimum value of a parameter in a specified group.
QWidget * AddHelpers(QObject *lo)
Sets up helper button.
QString HelperIcon(const int &group, const int ¶m, const int &helper) const
Returns the name of the icon for the helper button.
QString HelperDescription(const int &group, const int ¶m, const int &helper) const
Returns the long description of the helper button.
QString ParamMaximum(const int &group, const int ¶m) const
Returns the maximum value of a parameter in a specified group.
int ParamGreaterThanOrEqualSize(const int &group, const int ¶m) const
Returns the number of values in the parameters greater than or equal list.
int ParamNotEqualSize(const int &group, const int ¶m) const
Returns the number of values in the not equal list.
int ParamExcludeSize(const int &group, const int ¶m) const
Returns the number of parameters excluded in this parameter's exclusions.
void Update()
Update the value on the GUI with the value in the UI.
void SetToDefault()
Change the parameter to the default value.
This error is for when a programmer made an API call that was illegal.
GuiParameter(QGridLayout *grid, UserInterface &ui, int group, int param)
Constructor.
QString HelperButtonName(const int &group, const int ¶m, const int &helper) const
Returns the name of the helper button.
QString HelperFunction(const int &group, const int ¶m, const int &helper) const
Returns the name of the helper function.
QString ParamLessThan(const int &group, const int ¶m, const int &great) const
Returns the name of the specified lessThan parameter.
QString GetAsString(const QString ¶mName) const
Allows the retrieval of a value for a parameter of any type.
QString ParamMinimumInclusive(const int &group, const int ¶m) const
Returns whether the minimum value is inclusive or not.
QString ParamInclude(const int &group, const int ¶m, const int &include) const
Returns the name of the specified included parameter.
QString ParamType(const int &group, const int ¶m) const
Returns the parameter type of a parameter in a specified group.
int ParamLessThanOrEqualSize(const int &group, const int ¶m) const
Returns the number of values in the parameters less than or equal list.
#define _FILEINFO_
Macro for the filename and line number.
QString ParamExclude(const int &group, const int ¶m, const int &exclude) const
Returns the name of the specified excluded parameter.
int ParamLessThanSize(const int &group, const int ¶m) const
Returns the number of values in the parameters less than list.
QString ParamGreaterThan(const int &group, const int ¶m, const int &great) const
Returns the name of the specified greaterThan parameter.
QString ParamName(const int &group, const int ¶m) const
Returns the parameter name.
virtual bool IsModified()
Return if the parameter value is different from the default value.
QString PixelType(const int &group, const int ¶m) const
Returns the default pixel type from the XML.
QString HelperBrief(const int &group, const int ¶m, const int &helper) const
Returns the brief description of the helper button.
QString ParamOdd(const int &group, const int ¶m) const
Returns whether the selected parameter has a restriction on odd values or not.
QString ParamBrief(const int &group, const int ¶m) const
Returns the brief description of a parameter in a specified group.
void SetToCurrent()
Change the parameter to the current user interface value.
QString ParamNotEqual(const int &group, const int ¶m, const int ¬Eq) const
Returns the name of the specified notEqual parameter.
virtual std::vector< QString > Exclusions()
Return list of current exclusions.
Command Line and Xml loader, validation, and access.
QString ParamGreaterThanOrEqual(const int &group, const int ¶m, const int &great) const
Returns the name of the specified greaterThanOrEqual parameter.
bool WasEntered(const QString ¶mName) const
Returns a true if the parameter has a value, and false if it does not.
QString ParamInternalDefault(const int &group, const int ¶m) const
Returns the internal default for a parameter in a specified group.
void RememberWidget(QWidget *w)
Add widgets to a list for enabling/disabling.
QString ParamLessThanOrEqual(const int &group, const int ¶m, const int &les) const
Returns the name of the specified lessThanOrEqual parameter.
int ParamGreaterThanSize(const int &group, const int ¶m) const
Returns the number of values in the parameters greater than list.
bool IsEnabled() const
Is the parameter enabled.
QString ParamMaximumInclusive(const int &group, const int ¶m) const
Returns whether the maximum value is inclusive or not.