BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ParameterContainerItem Class Reference

Description

The ParameterContainerItem is a top item to hold all ParameterItem, represents an entry point to parameter tuning tree. Part of JobItem.

Definition at line 81 of file ParameterTreeItems.h.

Collaboration diagram for ParameterContainerItem:
[legend]

Public Member Functions

 ParameterContainerItem ()
 
ParameterItemfindParameterItem (const QString &link) const
 
QObject * parameterTreeRoot ()
 
void readContentFrom (QXmlStreamReader *reader)
 
void restoreBackupValues ()
 
void setBackupValue (const QString &link, double d)
 
void writeContentTo (QXmlStreamWriter *writer) const
 

Private Member Functions

void restoreBackupValue (QObject *item)
 

Private Attributes

QMap< QString, double > m_backupValues
 
std::unique_ptr< QObject > m_parameterTreeRoot
 

Constructor & Destructor Documentation

◆ ParameterContainerItem()

ParameterContainerItem::ParameterContainerItem ( )

Definition at line 148 of file ParameterTreeItems.cpp.

149 {
150  m_parameterTreeRoot.reset(new QObject());
151 }
std::unique_ptr< QObject > m_parameterTreeRoot

References m_parameterTreeRoot.

Member Function Documentation

◆ findParameterItem()

ParameterItem * ParameterContainerItem::findParameterItem ( const QString &  link) const

Definition at line 215 of file ParameterTreeItems.cpp.

216 {
217  return ::findParameterItem(m_parameterTreeRoot.get(), link);
218 }

References m_parameterTreeRoot.

Referenced by FitParameterContainerItem::setValuesInParameterContainer().

◆ parameterTreeRoot()

QObject * ParameterContainerItem::parameterTreeRoot ( )

Definition at line 220 of file ParameterTreeItems.cpp.

221 {
222  return m_parameterTreeRoot.get();
223 }

References m_parameterTreeRoot.

◆ readContentFrom()

void ParameterContainerItem::readContentFrom ( QXmlStreamReader *  reader)

Definition at line 167 of file ParameterTreeItems.cpp.

168 {
169  m_backupValues.clear();
170  const int version = reader->attributes().value(GUI::Session::XML::Version).toInt();
171 
172  if (version < 1)
174 
175  if (version > 1)
177 
178  while (reader->readNextStartElement()) {
179  if (reader->name().toString() == Tags::BackupValues) {
180  while (reader->readNextStartElement()) {
181  ASSERT(reader->name().toString() == Tags::BackupValue);
182  QString link;
183  double d;
184  GUI::Session::XML::readAttribute(reader, Tags::Link, &link);
186  m_backupValues[link] = d;
187  reader->skipCurrentElement();
188  }
189  }
190  }
191 }
static DeserializationException tooOld()
static DeserializationException tooNew()
QMap< QString, double > m_backupValues
void readAttribute(QXmlStreamReader *reader, const QString &attributeName, double *d)
Definition: UtilXML.cpp:193
constexpr auto Version("Version")
constexpr auto Value("value")

References m_backupValues, GUI::Session::XML::readAttribute(), DeserializationException::tooNew(), DeserializationException::tooOld(), XML::Tags::Value(), and GUI::Session::XML::Version().

Referenced by JobItem::readNonSessionItems().

Here is the call graph for this function:

◆ restoreBackupValue()

void ParameterContainerItem::restoreBackupValue ( QObject *  item)
private

Definition at line 198 of file ParameterTreeItems.cpp.

199 {
200  ASSERT(item);
201  if (auto* parameter = dynamic_cast<ParameterItem*>(item))
202  if (m_backupValues.contains(parameter->link()))
203  parameter->propagateValueToLink(m_backupValues[parameter->link()]);
204 
205  for (auto* child : item->children())
206  restoreBackupValue(child);
207 }
void restoreBackupValue(QObject *item)
The ParameterItem class represent a tuning value in a parameter tuning tree.

References m_backupValues.

Referenced by restoreBackupValues().

◆ restoreBackupValues()

void ParameterContainerItem::restoreBackupValues ( )

Definition at line 209 of file ParameterTreeItems.cpp.

210 {
211  for (auto* child : m_parameterTreeRoot->children())
212  restoreBackupValue(child);
213 }

References m_parameterTreeRoot, and restoreBackupValue().

Referenced by JobModel::restore().

Here is the call graph for this function:

◆ setBackupValue()

void ParameterContainerItem::setBackupValue ( const QString &  link,
double  d 
)

Definition at line 193 of file ParameterTreeItems.cpp.

194 {
195  m_backupValues[link] = d;
196 }

References m_backupValues.

Referenced by ParameterTreeBuilder::addParameterItem().

◆ writeContentTo()

void ParameterContainerItem::writeContentTo ( QXmlStreamWriter *  writer) const

Definition at line 153 of file ParameterTreeItems.cpp.

154 {
156 
157  writer->writeStartElement(Tags::BackupValues);
158 
159  for (auto v = m_backupValues.cbegin(); v != m_backupValues.cend(); v++) {
160  writer->writeEmptyElement(Tags::BackupValue);
161  GUI::Session::XML::writeAttribute(writer, Tags::Link, v.key());
163  }
164  writer->writeEndElement();
165 }
void writeAttribute(QXmlStreamWriter *writer, const QString &attributeName, const QVariant &variant)
Write the variant's value as an attribute.
Definition: UtilXML.cpp:65

References m_backupValues, XML::Tags::Value(), GUI::Session::XML::Version(), and GUI::Session::XML::writeAttribute().

Referenced by JobItem::writeNonSessionItems().

Here is the call graph for this function:

Member Data Documentation

◆ m_backupValues

QMap<QString, double> ParameterContainerItem::m_backupValues
private

◆ m_parameterTreeRoot

std::unique_ptr<QObject> ParameterContainerItem::m_parameterTreeRoot
private

The documentation for this class was generated from the following files: