[Kst] branches/work/kst/portto4/kst/src
Peter Kümmel
syntheticpp at gmx.net
Wed Jan 19 13:27:21 CET 2011
SVN commit 1215712 by kuemmel:
each Primitive could have metas
M +5 -0 libkst/primitive.cpp
M +10 -0 libkst/primitive.h
M +19 -67 libkstapp/scalarmodel.cpp
M +6 -3 libkstapp/scalarmodel.h
--- branches/work/kst/portto4/kst/src/libkst/primitive.cpp #1215711:1215712
@@ -95,6 +95,11 @@
}
+ScalarMap Primitive::scalars() const {return ScalarMap();}
+StringMap Primitive::strings() const {return StringMap();}
+
+
+
}
// vim: et sw=2 ts=2
--- branches/work/kst/portto4/kst/src/libkst/primitive.h #1215711:1215712
@@ -28,6 +28,11 @@
namespace Kst {
+class Scalar;
+class String;
+typedef ObjectMap<String> StringMap;
+typedef ObjectMap<Scalar> ScalarMap;
+
class KSTCORE_EXPORT Primitive : public Object
{
Q_OBJECT
@@ -51,6 +56,11 @@
virtual ObjectList<Primitive> outputPrimitives() const {return ObjectList<Primitive>();}
+ // metas of Primitive
+ virtual ScalarMap scalars() const;
+ virtual StringMap strings() const;
+
+
protected:
Primitive(ObjectStore *store, Object* provider = 0L);
--- branches/work/kst/portto4/kst/src/libkstapp/scalarmodel.cpp #1215711:1215712
@@ -121,46 +121,24 @@
}
-void ScalarModel::addVector(VectorPtr vector, ScalarTreeItem* parent) {
- ScalarTreeItem* item = addScalarTreeItem(QList<QVariant>() << vector->Name(), parent);
- addScalars(vector->scalars(), item);
+void ScalarModel::addPrimitivesScalars(const PrimitivePtr& prim, ScalarTreeItem* parent) {
+ ScalarTreeItem* item = addScalarTreeItem(QList<QVariant>() << prim->Name(), parent);
+ addScalars(prim->scalars(), item);
}
-void ScalarModel::addMatrix(MatrixPtr matrix, ScalarTreeItem* parent) {
- ScalarTreeItem* item = addScalarTreeItem(QList<QVariant>() << matrix->Name(), parent);
- addScalars(matrix->scalars(), item);
-}
-
-
void ScalarModel::addDataObject(DataObjectPtr dataObject, ScalarTreeItem* parent) {
ScalarTreeItem* item = addScalarTreeItem(QList<QVariant>() << dataObject->Name(), parent);
- QMap<QString, ObjectPtr> objectMap;
- foreach(Scalar* scalar, dataObject->outputScalars()) {
- objectMap.insert(scalar->Name(), scalar);
+ ObjectList<Primitive> primitives = dataObject->outputPrimitives();
+ foreach(const PrimitivePtr& prim, primitives) {
+ if (!kst_cast<String>(prim)) {
+ addPrimitivesScalars(prim, item);
}
- foreach(Vector* vector, dataObject->outputVectors()) {
- objectMap.insert(vector->Name(), vector);
}
- foreach(Matrix* matrix, dataObject->outputMatrices()) {
- objectMap.insert(matrix->Name(), matrix);
}
- QMapIterator<QString, ObjectPtr> iObject(objectMap);
- while (iObject.hasNext()) {
- iObject.next();
- if (VectorPtr vector = kst_cast<Vector>(iObject.value())) {
- addVector(vector, item);
- } else if (MatrixPtr matrix = kst_cast<Matrix>(iObject.value())) {
- addMatrix(matrix, item);
- } else if (ScalarPtr scalar = kst_cast<Scalar>(iObject.value())) {
- addScalar(scalar, item);
- }
- }
-}
-
void ScalarModel::addDataSource(DataSourcePtr dataSource, ScalarTreeItem* parent) {
ScalarTreeItem* item = addScalarTreeItem(QList<QVariant>() << dataSource->Name(), parent);
@@ -178,50 +156,24 @@
void ScalarModel::createTree() {
- QMap<QString, ObjectPtr> objectMap;
- foreach(DataVector* vector, _store->getObjects<DataVector>()) {
- objectMap.insert(vector->Name(), vector);
+ QList<ObjectPtr> objects = _store->objectList();
+ foreach(const ObjectPtr& obj, objects) {
+ if (kst_cast<Primitive>(obj)) {
+ if (kst_cast<Scalar>(obj) && !kst_cast<Scalar>(obj)->orphan()) {
+ continue;
}
- foreach(GeneratedVector* vector, _store->getObjects<GeneratedVector>()) {
- objectMap.insert(vector->Name(), vector);
+ addPrimitivesScalars(kst_cast<Primitive>(obj));
+ } else if (kst_cast<DataSource>(obj) && !kst_cast<DataSource>(obj)->scalar().list().isEmpty()) {
+ addDataSource(kst_cast<DataSource>(obj));
+ } else if (kst_cast<DataObject>(obj)) {
+ addDataObject(kst_cast<DataObject>(obj));
}
- foreach(DataMatrix* matrix, _store->getObjects<DataMatrix>()) {
- objectMap.insert(matrix->Name(), matrix);
}
- foreach(GeneratedMatrix* matrix, _store->getObjects<GeneratedMatrix>()) {
- objectMap.insert(matrix->Name(), matrix);
}
- foreach(DataObjectPtr dataObject, _store->getObjects<DataObject>()) {
- objectMap.insert(dataObject->Name(), dataObject);
- }
- foreach(Scalar* scalar, _store->getObjects<Scalar>()) {
- if (scalar->orphan()) {
- objectMap.insert(scalar->Name(), scalar);
- }
- }
- foreach(DataSource* ds, _store->dataSourceList()) {
- if (!ds->scalar().list().isEmpty()) {
- objectMap.insert(ds->shortName(), ds);
- }
- }
- QMapIterator<QString, ObjectPtr> iObject(objectMap);
- while (iObject.hasNext()) {
- iObject.next();
- if (VectorPtr vector = kst_cast<Vector>(iObject.value())) {
- addVector(vector);
- } else if (MatrixPtr matrix = kst_cast<Matrix>(iObject.value())) {
- addMatrix(matrix);
- } else if (DataObjectPtr dataObject = kst_cast<DataObject>(iObject.value())) {
- addDataObject(dataObject);
- } else if (ScalarPtr scalar = kst_cast<Scalar>(iObject.value())) {
- addScalar(scalar);
- } else if (DataSourcePtr dataSource = kst_cast<DataSource>(iObject.value())) {
- addDataSource(dataSource);
- }
- }
-}
+
+
int ScalarModel::rowCount(const QModelIndex& parent) const {
ScalarTreeItem *parentItem;
if (parent.column() > 0)
--- branches/work/kst/portto4/kst/src/libkstapp/scalarmodel.h #1215711:1215712
@@ -58,14 +58,17 @@
QModelIndex index(int row, int col, const QModelIndex& parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex& index) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+
void createTree();
+
void addScalar(ScalarPtr scalar, ScalarTreeItem* parent = 0);
- void addVector(VectorPtr vector, ScalarTreeItem* parent = 0);
- void addMatrix(MatrixPtr matrix, ScalarTreeItem* parent = 0);
+ void addScalars(const QHash<QString, Kst::ScalarPtr> scalarMap, ScalarTreeItem* parent = 0);
+
void addDataObject(DataObjectPtr dataObject, ScalarTreeItem* parent = 0);
void addDataSource(DataSourcePtr dataSource, ScalarTreeItem* parent = 0);
- void addScalars(const QHash<QString, Kst::ScalarPtr> scalarMap, ScalarTreeItem* parent = 0);
+ void addPrimitivesScalars(const PrimitivePtr&, ScalarTreeItem* parent = 0);
+
private:
ObjectStore *_store;
ScalarTreeItem *_rootItem;
More information about the Kst
mailing list