00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "MonitorWindow.h"
00025 #include "Debug.h"
00026
00027
00028 #include <qlabel.h>
00029 #include <qlayout.h>
00030 #include <qpushbutton.h>
00031 #include <qwidget.h>
00032
00033
00034 #include <iostream>
00035 using namespace std;
00036
00037
00038
00039 MonitorWindow::MonitorWindow(SimulationManager *simMan, QWidget *parent) : QDockWindow (parent, "New monitor window") {
00040
00041 simulationMode = true;
00042
00043
00044 simulationManager = simMan;
00045
00046
00047 monitorNeurons = true;
00048
00049
00050 windowWidth = 200;
00051 windowHeight = 200;
00052 xPos = 20;
00053 yPos = 20;
00054 finishedUndockingWindow = false;
00055 oldVisibility = false;
00056
00057
00058 setResizeEnabled(true);
00059 setFixedExtentWidth(100);
00060 setFixedExtentHeight(100);
00061 setCloseMode(QDockWindow::Always);
00062 hide();
00063
00064
00065 connect(this, SIGNAL(placeChanged(QDockWindow::Place)), this, SLOT(windowPlaceChanged(QDockWindow::Place)));
00066
00067
00068 connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(windowVisibilityChanged(bool)));
00069 }
00070
00071
00072
00073 MonitorWindow::MonitorWindow(QWidget *parent) : QDockWindow (parent, "New monitor window"){
00074 simulationMode = false;
00075
00076
00077 setResizeEnabled(true);
00078 setFixedExtentWidth(100);
00079 show();
00080
00081
00082 windowWidth = 200;
00083 windowHeight = 200;
00084 finishedUndockingWindow = false;
00085
00086
00087 connect(this, SIGNAL(placeChanged(QDockWindow::Place)), this, SLOT(windowPlaceChanged(QDockWindow::Place)));
00088 }
00089
00090
00091
00092 MonitorWindow::~MonitorWindow(){
00093 #ifdef MEMORY_DEBUG
00094 cout<<"DESTROYING MONITOR WINDOW"<<endl;
00095 #endif//MEMORY_DEBUG
00096 }
00097
00098
00099
00100
00101
00102
00103
00104
00105 unsigned int MonitorWindow::getNeuronGrpID(){
00106 return neuronGrpID;
00107 }
00108
00109
00110
00111
00112 void MonitorWindow::setMonitorType(bool monNeurs){
00113 if(monitorNeurons != monNeurs){
00114
00115 if(this->isVisible()){
00116 simulationManager->stopMonitoringNeuronGroup(neuronGrpID, monitorNeurons);
00117 simulationManager->monitorNeuronGroup(neuronGrpID, monNeurs);
00118 }
00119
00120
00121 monitorNeurons = monNeurs;
00122 }
00123 }
00124
00125
00126
00127 void MonitorWindow::setNeuronGrpID(unsigned int neurGrpID){
00128 neuronGrpID = neurGrpID;
00129 }
00130
00131
00132
00133
00134
00135
00136
00137
00138 void MonitorWindow::moveEvent(QMoveEvent *){
00139 if(this->place() == QDockWindow::OutsideDock){
00140 if(finishedUndockingWindow){
00141 xPos = this->pos().x();
00142 yPos = this->pos().y();
00143 }
00144 }
00145 }
00146
00147
00148
00149
00150 void MonitorWindow::resizeEvent(QResizeEvent *){
00151
00152 if(this->place() == QDockWindow::OutsideDock){
00153 if(finishedUndockingWindow){
00154 windowWidth = this->size().width();
00155 windowHeight = this->size().height();
00156 }
00157 }
00158 }
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 void MonitorWindow::windowPlaceChanged(QDockWindow::Place place){
00169 if(place == QDockWindow::OutsideDock){
00170
00171 resize(windowWidth, windowHeight);
00172 move(xPos, yPos);
00173
00174
00175 if(!finishedUndockingWindow)
00176 finishedUndockingWindow = true;
00177 }
00178 else
00179 finishedUndockingWindow = false;
00180 }
00181
00182
00183
00184
00185 void MonitorWindow::windowVisibilityChanged(bool newVisibility){
00186
00187
00188 if(newVisibility == oldVisibility)
00189 return;
00190 oldVisibility = newVisibility;
00191
00192
00193 if(!simulationMode){
00194 cerr<<"MonitorWindow: THIS SHOULD NOT BE CALLED IN ARCHIVE MODE"<<endl;
00195 return;
00196 }
00197
00198 if(newVisibility){
00199 simulationManager->monitorNeuronGroup(neuronGrpID, monitorNeurons);
00200 }
00201 else{
00202 simulationManager->stopMonitoringNeuronGroup(neuronGrpID, monitorNeurons);
00203 }
00204 }
00205
00206