musredit 1.0.0
Loading...
Searching...
No Matches
PGetTheoryBlockDialog.cpp
Go to the documentation of this file.
1/****************************************************************************
2
3 PGetTheoryBlockDialog.cpp
4
5 Author: Andreas Suter
6 e-mail: andreas.suter@psi.ch
7
8*****************************************************************************/
9
10/***************************************************************************
11 * Copyright (C) 2009-2026 by Andreas Suter *
12 * andreas.suter@psi.ch *
13 * *
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. *
18 * *
19 * This program is distributed in the hope that it will be useful, *
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22 * GNU General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU General Public License *
25 * along with this program; if not, write to the *
26 * Free Software Foundation, Inc., *
27 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
28 ***************************************************************************/
29
42
43#include <QMessageBox>
44#include <QTextEdit>
45#include <QComboBox>
46#include <QPixmap>
47#include <QImage>
48#include <QDesktopServices>
49#include <QUrl>
50
51#include <QtDebug>
52
54
55//----------------------------------------------------------------------------------------------------
85 fAdmin(admin),
86 fHelpUrl(helpUrl)
87{
88 setupUi(this);
89
90 setModal(true);
91
92 // feed theory function combo box
93 fTheoryFunction_comboBox->setIconSize(QSize(250, 20));
94 PTheory *theoItem;
95 QIcon *icon;
96 QString iconName;
97 for (unsigned int i=0; i<fAdmin->getTheoryCounts(); i++) {
98 theoItem = fAdmin->getTheoryItem(i);
99 if (theoItem->pixmapName.length() > 0) {
100 iconName = QString(":/latex_images/") + theoItem->pixmapName;
101 icon = new QIcon(QPixmap(iconName));
102 fTheoryFunction_comboBox->insertItem(i, *icon, theoItem->label);
103 } else {
104 fTheoryFunction_comboBox->insertItem(i, theoItem->label);
105 }
106 }
107}
108
109//----------------------------------------------------------------------------------------------------
146{
147 QString str = "????";
148 int idx = fTheoryFunction_comboBox->currentIndex();
149 PTheory *theoItem = fAdmin->getTheoryItem(idx);
150 if (theoItem == 0)
151 return str;
152
153 // add theory function name
154 str = theoItem->name + " ";
155 if (theoItem->name == "userFcn") {
156 str += "libMyLibrary.so TMyFunction ";
157 }
158 // add pseudo parameters
159 for (int i=0; i<theoItem->params; i++) {
160 str += QString("%1").arg(i+1) + " ";
161 }
162 // add comment
163 str += theoItem->comment;
164
165 return str;
166}
167
168//----------------------------------------------------------------------------------------------------
193{
194 QString str = getTheoFuncString() + "\n+";
195 fTheoryBlock_plainTextEdit->appendPlainText(str);
196}
197
198//----------------------------------------------------------------------------------------------------
223{
224 QString str = getTheoFuncString();
225 fTheoryBlock_plainTextEdit->appendPlainText(str);
226}
227
228//----------------------------------------------------------------------------------------------------
251{
252 if (fHelpUrl.isEmpty()) {
253 QMessageBox::information(this, "INFO", "Will eventually show a help window");
254 } else {
255 bool ok = QDesktopServices::openUrl(QUrl(fHelpUrl, QUrl::TolerantMode));
256 if (!ok) {
257 QString msg = QString("<p>Sorry: Couldn't open default web-browser for the help.<br>Please try: <a href=\"%1\">musrfit docu</a> in your web-browser.").arg(fHelpUrl);
258 QMessageBox::critical( nullptr, tr("FATAL ERROR"), msg, QMessageBox::Close );
259 }
260 }
261}
262
263//----------------------------------------------------------------------------------------------------
264// END
265//----------------------------------------------------------------------------------------------------
Dialog for creating THEORY blocks in msr files.
Central administration class for musredit configuration management.
Definition PAdmin.h:209
QString getTheoFuncString()
Generates the theory function string for the selected function.
void addPlus()
Adds the selected function followed by a '+' operator.
PAdmin * fAdmin
Pointer to the administration object for accessing theory function definitions.
QString fHelpUrl
URL to the online documentation for THEORY blocks.
void helpContent()
Opens the online help for THEORY blocks.
PGetTheoryBlockDialog(PAdmin *admin=0, const QString helpUrl="")
Constructs a dialog for creating THEORY blocks.
void addMultiply()
Adds the selected function (multiplication with next line).
Structure holding information about a musrfit theory function.
Definition PAdmin.h:90
QString name
Internal function name used in msr files (e.g., "asymmetry", "simplExpo").
Definition PAdmin.h:91
QString comment
Human-readable description of the theory function.
Definition PAdmin.h:92
QString label
Short label for GUI menus and buttons.
Definition PAdmin.h:93
int params
Number of parameters required by this theory function.
Definition PAdmin.h:96
QString pixmapName
Filename of the pixmap image showing the mathematical formula.
Definition PAdmin.h:94