File: CalculationSequenceEditor.h

package info (click to toggle)
dyssol 1.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,184 kB
  • sloc: cpp: 53,870; sh: 85; python: 59; makefile: 11
file content (79 lines) | stat: -rw-r--r-- 3,615 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* Copyright (c) 2020, Dyssol Development Team.
 * Copyright (c) 2023, DyssolTEC GmbH.
 * All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */

#pragma once

#include "ui_CalculationSequenceEditor.h"
#include "QtDialog.h"

class CCalculationSequence;
class CFlowsheet;

class CCalculationSequenceEditor
	: public CQtDialog
{
	Q_OBJECT

	// Describes a selection in the tree table.
	struct SSelection
	{
		enum class EType { PARTITION, MODEL, STREAM, UNKNOWN };
		size_t partition; // Index of a partition.
		EType type;       // PARTITION, MODEL or STREAM.
		size_t index;     // Index of a model or stream within a partition or a partition itself.
	};

	Ui::CCalculationSequenceEditorClass ui;

	CFlowsheet* m_pFlowsheet;          // Pointer to the flowsheet.
	CCalculationSequence* m_pSequence; // Pointer to the calculation sequence.

public:
	CCalculationSequenceEditor(CFlowsheet* _pFlowsheet, QWidget* _parent = nullptr, Qt::WindowFlags _flags = Qt::WindowFlags());

	void InitializeConnections() const;

public slots:
	void setVisible(bool _bVisible) override;
	void UpdateWholeView() const;

private slots:
	void AddItem();    // Add new item depending on the current selection.
	void RemoveItem(); // Remove an item depending on the current selection.
	void UpItem();     // Move an item upwards depending on the current selection.
	void DownItem();   // Move an item downwards depending on the current selection.

	void ChangeItem(const QComboBox* _combo, QTreeWidgetItem* _item); // Change unique key of an item.

	void CalculateSequence(); // Recalculate calculation sequence.

private:
	void UpdatePartitionsList() const; // Update the list of partitions.

	void AddPartition();                                    // Add new partition.
	void RemovePartition(size_t _iPartition);               // Remove partition.
	void UpPartition(size_t _iPartition);                   // Move selected partition upwards.
	void DownPartition(size_t _iPartition);                 // Move selected partition downwards.

	void AddModel(size_t _iPartition);                      // Add new model to the specified partition.
	void RemoveModel(size_t _iPartition, size_t _iModel);   // Remove model from the specified partition.
	void UpModel(size_t _iPartition, size_t _iModel);       // Move selected model upwards.
	void DownModel(size_t _iPartition, size_t _iModel);     // Move selected model downwards.

	void AddStream(size_t _iPartition);                     // Add new tear stream to the specified partition.
	void RemoveStream(size_t _iPartition, size_t _iStream); // Remove tear stream from the specified partition.
	void UpStream(size_t _iPartition, size_t _iStream);     // Move selected tear stream upwards.
	void DownStream(size_t _iPartition, size_t _iStream);   // Move selected tear stream downwards.

	void SetNewModel(size_t _iPartition, size_t _iModel, const std::string& _key);   // Set new model key to the selected model in the specified partition.
	void SetNewStream(size_t _iPartition, size_t _iStream, const std::string& _key); // Set new stream key to the selected tear stream in the specified partition.

	SSelection ParseSelection(QTreeWidgetItem* _item) const;
	size_t SelectedPartition(QTreeWidgetItem* _item) const;       // Returns index of a partition for a given item.
	SSelection::EType SelectedType(QTreeWidgetItem* _item) const; // Returns type of a given item (PARTITION/STREAM/MODEL).
	size_t SelectedIndex(QTreeWidgetItem* _item) const;           // Returns index of a model or stream within a partition.

signals:
	void DataChanged();
};