SedSat3 1.1.6
Sediment Source Apportionment Tool - Advanced statistical methods for environmental pollution research
Loading...
Searching...
No Matches
cmbvectorsetset.cpp
Go to the documentation of this file.
1#include "cmbvectorsetset.h"
2#include <QFile>
3#include <gsl/gsl_cdf.h>
4
14{
15 map<string,CMBVectorSet>::operator=(mp);
17 return *this;
18}
20{
21 QJsonObject out;
22 for (map<string,CMBVectorSet>::const_iterator it = cbegin(); it!=cend();it++)
23 {
24 out[QString::fromStdString(it->first)]=it->second.toJsonObject();
25 }
26 return out;
27}
28bool CMBVectorSetSet::ReadFromJsonObject(const QJsonObject &jsonobject)
29{
30 for(QString key: jsonobject.keys() ) {
31 CMBVectorSet column;
32 column.ReadFromJsonObject(jsonobject[key].toObject());
33 operator[](key.toStdString()) = column;
34 }
35 return true;
36}
38{
39 string s;
40 for (map<string,CMBVectorSet>::const_iterator it = cbegin(); it!=cend();it++)
41 {
42 s+= "\n";
43 s+=it->first + ":\n";
44 s+=it->second.ToString()+="\n";
45 }
46 return s;
47}
48
49unsigned int CMBVectorSetSet::MaxSize() const
50{
51 int max_size=0;
52 for (map<string,CMBVectorSet>::const_iterator it = begin(); it!=end();it++)
53 {
54 if (it->second.MaxSize()>max_size)
55 max_size = it->second.MaxSize();
56 }
57 return max_size;
58}
59
61{
62 double out = -1e23;
63 for (map<string,CMBVectorSet>::const_iterator it = cbegin(); it!=cend();it++)
64 {
65 out = std::max(out,it->second.max());
66 }
67 return out;
68};
70{
71 double out = 1e23;
72 for (map<string,CMBVectorSet>::const_iterator it = cbegin(); it!=cend();it++)
73 {
74 out = std::min(out,it->second.min());
75 }
76 return out;
77}
78
79
81{
82 QTableWidget *tablewidget = new QTableWidget();
83 tablewidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
84 int column_count=0;
85 for (map<string,CMBVectorSet>::iterator vectorset=begin(); vectorset!=end(); vectorset++)
86 column_count += vectorset->second.size();
87 tablewidget->setColumnCount(column_count*2);
88 tablewidget->setRowCount(MaxSize());
89 QStringList rowheaders;
90 QStringList colheaders;
91 int colno = 0;
92 for (map<string,CMBVectorSet>::iterator vectorset=begin(); vectorset!=end(); vectorset++)
93 {
94 for (map<string,CMBVector>::iterator column=vectorset->second.begin(); column!=vectorset->second.end(); column++)
95 {
96 colheaders<<QString::fromStdString(vectorset->first)+":"+QString::fromStdString(column->first)<<QString::fromStdString(vectorset->first)+":"+QString::fromStdString(column->first)+"-Value";
97 for (int i=0; i<column->second.getsize(); i++)
98 {
99 tablewidget->setItem(i,colno*2,new QTableWidgetItem(QString::fromStdString(column->second.Label(i))));
100 tablewidget->setItem(i,colno*2+1,new QTableWidgetItem(QString::number(column->second[i])));
101 }
102 colno++;
103 }
104 }
105
106 tablewidget->setHorizontalHeaderLabels(colheaders);
107 //tablewidget->setVerticalHeaderLabels(rowheaders);
108 return tablewidget;
109}
111{
112 file->write(QString::fromStdString(ToString()).toUtf8());
113 return true;
114}
115
116string CMBVectorSetSet::Label(const string &vectorset,const string &column, int j) const
117{
118 if (count(vectorset)!=0)
119 return (at(vectorset).Label(column,j));
120 else
121 return "";
122}
123double CMBVectorSetSet::valueAt(const string &vectorset, const string &columnlabel, int j) const
124{
125 if (count(columnlabel)!=0)
126 return (at(vectorset).valueAt(columnlabel,j));
127 else
128 return 0;
129}
130CMBVector &CMBVectorSetSet::GetColumn(const string &vectorset, const string &columnlabel)
131{
132 return at(vectorset).GetColumn(columnlabel);
133}
134void CMBVectorSetSet::Append(const string &columnlabel,const CMBVectorSet &vectorset)
135{
136 this->operator[](columnlabel) = vectorset;
137}
138
Collection of named CMBVectorSet objects for hierarchical data organization.
double min() const
Finds the minimum value across all vectors in all sets.
CMBVector & GetColumn(const string &vectorset, const string &columnlabel)
Gets reference to a named column vector within a vector set.
double max() const
Finds the maximum value across all vectors in all sets.
string ToString() const override
Converts vector set set to string representation.
double valueAt(const string &vectorset, const string &columnlabel, int j) const
Gets value at specified position in a column within a vector set.
QTableWidget * ToTable() override
Creates a QTableWidget for displaying vector set set data.
bool ReadFromJsonObject(const QJsonObject &jsonobject) override
Deserializes vector set set from JSON format.
string Label(const string &vectorset, const string &column, int j) const
Gets label at specified position in a column within a vector set.
void Append(const string &columnlabel, const CMBVectorSet &vectorset)
Adds or replaces a vector set in the collection.
CMBVectorSetSet()
Default constructor - creates an empty vector set set.
unsigned int MaxSize() const
Finds the maximum size among all vectors in all sets.
bool writetofile(QFile *file) override
Writes vector set set to file.
QJsonObject toJsonObject() const override
Serializes vector set set to JSON format.
CMBVectorSetSet & operator=(const CMBVectorSetSet &mp)
Assignment operator.
Collection of named CMBVector objects for multi-variable analysis.
string ToString() const override
Converts vector set to string representation.
bool ReadFromJsonObject(const QJsonObject &jsonobject) override
Deserializes vector set from JSON format.
Vector class with string labels for Chemical Mass Balance analysis.
Definition cmbvector.h:17
Abstract base class providing common serialization and visualization interface.
Definition interface.h:65
Interface & operator=(const Interface &intf)
Assignment operator.
Definition interface.cpp:14