Changeset f2d5ce for src/UIElements/Views/Qt4
- Timestamp:
- Dec 26, 2025, 9:40:14 PM (4 days ago)
- Branches:
- Candidate_v1.7.1, stable
- Children:
- c8cb0d
- Parents:
- bdd1d0
- git-author:
- Frederik Heber <frederik.heber@…> (12/10/25 10:20:56)
- git-committer:
- Frederik Heber <frederik.heber@…> (12/26/25 21:40:14)
- Location:
- src/UIElements/Views/Qt4
- Files:
-
- 2 edited
-
QtTimeLine.cpp (modified) (5 diffs)
-
QtTimeLine.hpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/QtTimeLine.cpp
rbdd1d0 rf2d5ce 46 46 #include "WorldTime.hpp" 47 47 48 QtTimeLine::QtTimeLine(QWidget * _parent) : 48 #include "UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp" 49 50 QtTimeLine::QtTimeLine(QtObservedInstanceBoard *_instanceBoard, QWidget * _parent) : 49 51 QWidget(_parent), 50 Observer("QtTimeLine"), 51 atomobserver_enlisted(false), 52 worldtime_enlisted(false), 52 instanceBoard(_instanceBoard), 53 53 SetWorldTime_called(false) 54 54 { … … 71 71 layout->addWidget(spinbox); 72 72 73 // sign on to observable74 WorldTime::getInstance().signOn(this, WorldTime::TimeChanged);75 worldtime_enlisted = true;76 AtomObserver::getInstance().signOn(this, AtomObservable::TrajectoryChanged);77 atomobserver_enlisted = true;78 79 73 // connect to QSlider's valueChanged() signal 80 74 bool result = connect(slider,SIGNAL(valueChanged(int)),this,SLOT(StepUpdate(int))); … … 82 76 if (!result) 83 77 ELOG(0, "Could not connect to QSlider::valueChanged."); 78 79 connect(instanceBoard, SIGNAL(WorldTimeChanged()), this, SLOT(WorldTimeChanged())); 80 connect(instanceBoard, SIGNAL(MaximumAtomTrajectoryChanged()), this, SLOT(MaximumAtomTrajectoryChanged())); 84 81 } 85 82 86 83 QtTimeLine::~QtTimeLine() 87 { 88 if (worldtime_enlisted) 89 WorldTime::getInstance().signOff(this, WorldTime::TimeChanged); 90 if (atomobserver_enlisted) 91 AtomObserver::getInstance().signOff(this, AtomObservable::TrajectoryChanged); 92 } 84 {} 93 85 94 86 void QtTimeLine::paintEvent(QPaintEvent * event) … … 99 91 } 100 92 101 void QtTimeLine::subjectKilled(Observable *publisher) 102 { 103 // as long as we are enlisted to only one channel, we have nothing to worry. 104 // Otherwise we should also signOn to global changes for subjectKilled() and 105 // sign off from the channels 106 if (static_cast<AtomObserver *>(publisher) == AtomObserver::getPointer()) { 107 atomobserver_enlisted = false; 108 } else if (static_cast<WorldTime *>(publisher) == WorldTime::getPointer()) { 109 worldtime_enlisted = false; 110 } 111 } 112 113 void QtTimeLine::update(Observable *publisher) 114 { 115 ELOG(0, "We are not enlisted for general updates."); 116 } 117 118 void QtTimeLine::recieveNotification(Observable *publisher, Notification_ptr notification) 93 void QtTimeLine::WorldTimeChanged() 119 94 { 120 95 boost::recursive_mutex::scoped_lock lock(refill_mutex); 121 96 122 if (static_cast<WorldTime *>(publisher) == WorldTime::getPointer()) {123 SetWorldTime_called = false;124 const int timestep = WorldTime::getTime();125 // check whether we are beyond maximum126 if (timestep > slider->maximum()) {127 slider->setMaximum(timestep);128 spinbox->setMaximum(timestep);129 }130 // set slider position to new time step131 slider->setValue( timestep );132 spinbox->setValue( timestep ); 133 } else 134 //if (static_cast<AtomObserver *>(publisher) == AtomObserver::getPointer())135 {136 // calculate max trajectory (need dynamic_cast due to virtual base)137 const atom *_atom = dynamic_cast<const atom *>(publisher); 138 const int MaxTrajectory = _atom->getTrajectorySize()-1;139 if (MaxTrajectory > slider->maximum()) {140 slider->setMaximum(MaxTrajectory);141 spinbox->setMaximum(MaxTrajectory);142 }97 SetWorldTime_called = false; 98 const int timestep = instanceBoard->getObservedWorldTime().get(); 99 // check whether we are beyond maximum 100 if (timestep > slider->maximum()) { 101 slider->setMaximum(timestep); 102 spinbox->setMaximum(timestep); 103 } 104 // set slider position to new time step 105 slider->setValue( timestep ); 106 spinbox->setValue( timestep ); 107 } 108 109 void QtTimeLine::MaximumAtomTrajectoryChanged() 110 { 111 boost::recursive_mutex::scoped_lock lock(refill_mutex); 112 113 // calculate max trajectory (need dynamic_cast due to virtual base) 114 const int MaxTrajectory = instanceBoard->getObservedMaximumAtomTrajectorySize().get(); 115 if (MaxTrajectory > slider->maximum()) { 116 slider->setMaximum(MaxTrajectory); 117 spinbox->setMaximum(MaxTrajectory); 143 118 } 144 119 } … … 149 124 150 125 if (!SetWorldTime_called) { 151 if ( WorldTime::getTime() != (unsigned int)position) {126 if (instanceBoard->getObservedWorldTime().get() != (unsigned int)position) { 152 127 SetWorldTime_called = true; 153 128 MoleCuilder::WorldSetWorldTime(position); -
src/UIElements/Views/Qt4/QtTimeLine.hpp
rbdd1d0 rf2d5ce 20 20 #include <boost/thread/recursive_mutex.hpp> 21 21 22 #include "CodePatterns/Observer/Observer.hpp" 22 class QtObservedInstanceBoard; 23 23 24 class QtTimeLine : public QWidget , public Observer24 class QtTimeLine : public QWidget 25 25 { 26 26 Q_OBJECT 27 27 28 28 public: 29 QtTimeLine(Q Widget * _parent=0);29 QtTimeLine(QtObservedInstanceBoard *_instanceBoard, QWidget * _parent=0); 30 30 virtual ~QtTimeLine(); 31 31 32 32 protected: 33 virtual void update(Observable *publisher);34 virtual void recieveNotification(Observable *publisher, Notification_ptr notification);35 virtual void subjectKilled(Observable *publisher);36 33 virtual void paintEvent(QPaintEvent * event); 37 34 … … 39 36 void StepUpdate(int position); 40 37 38 public slots: 39 void WorldTimeChanged(); 40 void MaximumAtomTrajectoryChanged(); 41 41 42 private: 42 //!> whether AtomObserver knows about us or not43 bool atomobserver_enlisted;44 //!> whether WorldTime knows about us or not45 bool worldtime_enlisted;46 47 43 QSlider *slider; 48 44 QSpinBox *spinbox; 49 45 QHBoxLayout *layout; 46 47 //!> instance board with observed world time 48 QtObservedInstanceBoard *instanceBoard; 50 49 51 50 //!> states whether we are expecting a notification from the worldtime
Note:
See TracChangeset
for help on using the changeset viewer.
