source: src/UIElements/Views/Qt4/QtGeometryList.cpp@ 48eab8

Action_Thermostats Add_AtomRandomPerturbation Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.1 ChangeBugEmailaddress ChemicalSpaceEvaluator EmpiricalPotential_contain_HomologyGraph_documentation Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph Fix_Verbose_Codepatterns ForceAnnealing_oldresults ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks StoppableMakroAction TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps
Last change on this file since 48eab8 was 48eab8, checked in by Frederik Heber <frederik.heber@…>, 8 years ago

Added QtGeometryList to QtMainWindow.

  • this list shows the name and vectors of all GeometryObjects in the Registry.
  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2017 Frederik Heber. All rights reserved.
5 *
6 *
7 * This file is part of MoleCuilder.
8 *
9 * MoleCuilder is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * MoleCuilder is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/*
24 * QtGeometryList.cpp
25 *
26 * Created on: Mar 25, 2017
27 * Author: heber
28 */
29
30// include config.h
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35#include "Views/Qt4/QtGeometryList.hpp"
36
37#include <iostream>
38
39//#include "CodePatterns/MemDebug.hpp"
40
41#include "CodePatterns/Observer/Notification.hpp"
42#include "CodePatterns/toString.hpp"
43
44#include "Geometry/GeometryRegistry.hpp"
45
46#include <QAbstractItemView>
47
48using namespace std;
49
50const int QtGeometryList::COLUMNCOUNT = COLUMNTYPES_MAX;
51const char *QtGeometryList::COLUMNNAMES[QtGeometryList::COLUMNCOUNT]={"Name","Vector"};
52
53QtGeometryList::QtGeometryList(QWidget * _parent) :
54 QTreeWidget (_parent),
55 Observer("QtGeometryList")
56{
57 setColumnCount(COLUMNCOUNT);
58 setSelectionMode(QAbstractItemView::NoSelection);
59
60 QStringList header;
61 for(int i=0; i<COLUMNCOUNT;++i)
62 header << COLUMNNAMES[i];
63 setHeaderLabels(header);
64
65 refill(NULL);
66
67 GeometryRegistry::getInstance().signOn(this);
68 GeometryRegistry::getInstance().signOn(this, GeometryRegistry::GeometryInserted);
69 GeometryRegistry::getInstance().signOn(this, GeometryRegistry::GeometryRemoved);
70}
71
72QtGeometryList::~QtGeometryList()
73{
74 GeometryRegistry::getInstance().signOff(this);
75 GeometryRegistry::getInstance().signOff(this, GeometryRegistry::GeometryInserted);
76 GeometryRegistry::getInstance().signOff(this, GeometryRegistry::GeometryRemoved);
77}
78
79void QtGeometryList::update(Observable *publisher) {}
80
81void QtGeometryList::recieveNotification(Observable *publisher, Notification_ptr notification)
82{
83 if (static_cast<GeometryRegistry*>(publisher) == GeometryRegistry::getPointer()) {
84 switch (notification->getChannelNo()) {
85 case GeometryRegistry::GeometryInserted:
86 {
87 refill(NULL);
88 break;
89 }
90 case GeometryRegistry::GeometryRemoved:
91 {
92 refill(GeometryRegistry::getInstance().lastChanged());
93 break;
94 }
95 default:
96 ASSERT(0, "QtGeometryList::recieveNotification() - we cannot get here.");
97 break;
98 }
99 }
100}
101
102void QtGeometryList::refill(::GeometryObject *ignore)
103{
104 clear();
105
106 GeometryRegistry &reg = GeometryRegistry::getInstance();
107
108 GeometryRegistry::const_iterator iter;
109 for (iter = reg.getBeginIter(); iter != reg.getEndIter(); iter ++){
110 ::GeometryObject *v = iter->second;
111 if (v == ignore)
112 continue;
113
114 QTreeWidgetItem *treeItem = new QTreeWidgetItem(this);
115 treeItem->setText(NAME, QString(v->getName().c_str()));
116 treeItem->setText(VECTOR, QString(toString(v->getVector()).c_str()));
117 }
118}
119
120#if 0
121void QtGeometryList::paintEvent(QPaintEvent * event)
122{
123 /*if (dirty)
124 refill(NULL);*/
125 QtGeometryList::paintEvent(event);
126}
127#endif
128
129void QtGeometryList::subjectKilled(Observable *publisher) {
130}
Note: See TracBrowser for help on using the repository browser.