File: MaterialsDatabaseTab.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 (118 lines) | stat: -rw-r--r-- 4,335 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/* 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_MaterialsDatabaseTab.h"
#include "MaterialsDatabase.h"
#include "QtDialog.h"
#include <QSettings>

class CMaterialsDatabaseTab
	: public CQtDialog
{
	Q_OBJECT

private:
	enum ECompTable { CT_NAME_COL = 0, CT_KEY_COL = 1 };
	enum EPropTable { PT_CONST_COL = 0, PT_NAME_COL = 1, PT_UNITS_COL = 2, PT_VALUE_COL = 3, PT_INFO_COL = 4 };

	Ui::CMaterialsDatabaseTab ui;

	CMaterialsDatabase* m_materialsDB;

	bool m_bMaterialsDatabaseChanged=false;

public:
	CMaterialsDatabaseTab(CMaterialsDatabase* _pMaterialsDatabase, QWidget* _parent = nullptr);

	void InitializeConnections();

	/**
	 * \brief Select the given compound.
	 * \param _key Unique key of the compound.
	 */
	void SelectCompound(const std::string& _key) const;

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

private slots:
	void NewDatabase();
	void LoadDatabase();
	void SaveDatabase();
	void SaveDatabaseAs();
	bool SaveToFile(const QString& _fileName);

	void AddCompound();
	void DuplicateCompound();
	void RemoveCompound();
	void ShiftCompoundUp();		// Moves selected compound upwards in the list of compounds.
	void ShiftCompoundDown();	// Moves selected compound downwards in the list of compounds.

	void NewCompoundSelected() const;
	void CompoundChanged(QTableWidgetItem* _pItem);

	void AddProperty();
	void DuplicateProperty();
	void RemoveProperty();
	void EditProperty();

	void NewPropertySelected() const;
	void PropertyValueChanged(int _iRow, int _iCol);
	void PropertyConstFlagChanged(int _iRow);
	void PropertyInfoClicked(int _iRow);

	void AddInterProperty();
	void DuplicateInterProperty();
	void RemoveInterProperty();
	void EditInterProperty();

	void NewCompound1Selected() const;
	void NewCompound2Selected() const;
	void NewInteractionSelected() const;
	void InteractionValueChanged(int _iRow, int _iCol);
	void InteractionConstFlagChanged(int _iRow);
	void InteractionInfoClicked(int _iRow);

protected:
	void closeEvent(QCloseEvent* _event) override;	// closing of the MDB window event
	void keyPressEvent(QKeyEvent* _event) override; // override of method keyPressEvent

private:
	void UpdateWindowTitle();
	void UpdateFileButtonsActivity() const;	// Update activity of new/save/save as/load buttons

	void UpdateCompoundsList() const;
	void UpdateCompoundProperties() const;

	void UpdateInteractionsCompoundsLists() const;
	void UpdateInteractionProperties() const;

	void CreateCompoundPropertiesTable();		// Create entries of the table that do not change.
	void CreateInteractionPropertiesTable();	// Create entries of the table that do not change.
	void AddCheckBoxOnTable(CQtTable* _pTable, int _iRow, int _iCol, bool _bChecked, bool _bEnabled = true);
	void AddToolButtonOnTable(CQtTable* _pTable, int _iRow, int _iCol);

	CCompound* GetSelectedCompound(int _row = -1) const;					// Returns pointer to a currently selected compound (if _row == -1) or to a compound from specified row.
	std::pair<CCompound*, CCompound*> GetSelectedInterCompounds() const;	// Returns pointers to currently selected compounds on Interactions tab.
	CInteraction* GetSelectedInteraction() const;							// Returns pointers to currently selected interaction.
	static unsigned GetPropertyKey(const CQtTable* _pTable, int _iRow);
	bool IsConstProperty(int _iRow) const;										// Returns true if the property in the specified row is constant.

	void SelectCompound(const CCompound* _pCompound) const;	// Makes specified compound currently selected.
	void TogglePropertyConstancy(CQtTable* _pTable, int _iRow, CTPDProperty* _pProp);

	void SetMaterialsDatabaseModified(bool _bModified);//set value for state MDB flag
	bool IsUserConfirm(); // Asks user about saving of current database state and saves it if needed. Returns false if user pressed Cancel.

	// Returns a list of user defined properties of all types.
	std::vector<unsigned> ActiveUDProps() const;
	// Retunrs the first available user defined property of a specified type.
	unsigned FirstAvailableUDProp(MDBDescriptors::EPropertyType _type) const;

signals:
	void MaterialDatabaseWasChanged();	// Called when material database has been changed.
};