00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef NETWORKVIEWER_H
00024 #define NETWORKVIEWER_H
00025
00026
00027 #include "DBInterface.h"
00028 #include "NeuronGroupHolder.h"
00029 #include "ConnectionGroupHolder.h"
00030 #include "SpikeStreamApplication.h"
00031
00032
00033 #include <qaccel.h>
00034 #include <qgl.h>
00035 #include <qsplashscreen.h>
00036 #include <qprogressbar.h>
00037 #include <qprogressdialog.h>
00038 #include <qevent.h>
00039 #include <qtimer.h>
00040
00041
00042 #include <vector>
00043 #include <map>
00044 #include <google/dense_hash_map>
00045 using HASH_NAMESPACE::hash;
00046 using GOOGLE_NAMESPACE::dense_hash_map;
00047 using namespace std;
00048
00049
00050
00051
00052 struct RGBColor {
00053 float red;
00054 float green;
00055 float blue;
00056 };
00057
00058
00059
00060 typedef dense_hash_map<unsigned int, RGBColor*> HighlightNeuronMap;
00061
00062
00063 typedef map<RGBColor*, bool> HighlightColorMap;
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 class NetworkViewer : public QGLWidget {
00078 Q_OBJECT
00079
00080 public:
00081 NetworkViewer(QWidget *parent, QSplashScreen*, DBInterface*, unsigned int);
00082 ~NetworkViewer();
00083 void addHighlight(unsigned int neurID, RGBColor* highlightColor);
00084 void cancelRenderProgress();
00085 void clearHighlights();
00086 void deleteConnectionGroup(unsigned int ID);
00087 void deleteNeuronGroup(unsigned int ID);
00088 vector<unsigned int>* getConnectionViewVector();
00089 void loadConnectionGroup(unsigned int, bool);
00090 void loadDefaultClippingVolume();
00091 void loadNeuronGroup(unsigned int, bool);
00092 void reloadEverything();
00093 void refresh();
00094 void resetView();
00095 void setConnectionView(vector<unsigned int>);
00096 void setFullRenderMode(bool);
00097 void setLayerView(vector<unsigned int>);
00098 void setMaxAutoLoadConnGrpSize(unsigned int);
00099 void setNetworkViewerProperties(QWidget*);
00100 void setNeuronConnectionMode(bool mode, unsigned int neuronGroup1, bool betwMode, unsigned int neuronGroup2);
00101 void setNeuronFilterMode(bool mode, char minWeight, char maxWeight, bool showFrom, bool showTo, bool updateDisplay);
00102 void setRenderDelay(double);
00103 void setRenderProgressBar(QProgressBar*);
00104 void showConnections(bool);
00105 void zoomAboveLayer(unsigned int layID);
00106 void zoomToLayer(unsigned int layID);
00107
00108
00109 protected:
00110
00111 void initializeGL();
00112 void paintGL();
00113 void resizeGL(int width, int height);
00114
00115
00116 private slots:
00117 void acceleratorKeyPressed (int acceleratorID);
00118 void setFullRender();
00119
00120
00121 private:
00122
00123
00124 QAccel *keyboardAccelerator;
00125
00126
00127
00128
00129
00130
00131 QWidget *networkViewerProperties;
00132
00133
00134 SpikeStreamApplication *spikeStrApp;
00135
00136
00137 DBInterface* dbInterface;
00138
00139
00140 GLfloat perspective_angle;
00141
00142
00143 GLfloat perspective_near;
00144
00145
00146 GLfloat perspective_far;
00147
00148
00149 GLfloat sceneRotateX;
00150
00151
00152 GLfloat sceneRotateZ;
00153
00154
00155 GLfloat cameraMatrix [16];
00156
00157
00158 GLfloat rotationMatrix [16];
00159
00160
00161 ClippingVolume defaultClippingVol;
00162
00163
00164 HighlightNeuronMap highlightNeuronMap;
00165
00166
00167
00168 HighlightColorMap highlightColorMap;
00169
00170
00171 bool highlightMode;
00172
00173
00174 float* xPosPtr;
00175 float* yPosPtr;
00176 float* zPosPtr;
00177 unsigned int *neuronIDPtr;
00178 float* fromXPtr;
00179 float* fromYPtr;
00180 float* fromZPtr;
00181 float* toXPtr;
00182 float* toYPtr;
00183 float* toZPtr;
00184 char* weightPtr;
00185 unsigned int *fromNeuronIDPtr;
00186 unsigned int *toNeuronIDPtr;
00187
00188
00189
00190 bool fullRenderMode;
00191
00192
00193 bool fullRender;
00194
00195
00196 int renderDelay_ms;
00197
00198
00199 QTimer *renderTimer;
00200
00201
00202 bool cancelRender;
00203
00204
00205 QProgressBar *renderProgressBar;
00206
00207
00208 QProgressDialog *loadProgressDialog;
00209
00210
00211 bool drawConnections;
00212
00213
00214
00215
00216 bool neuronConnectionMode;
00217 bool neuronFilterMode;
00218
00219
00220 map<unsigned int, NeuronGroupHolder*> neuronGrpMap;
00221
00222
00223 map<unsigned int, ConnectionGroupHolder*> connectionGrpMap;
00224
00225
00226 vector<unsigned int> layerViewVector;
00227
00228
00229 vector<unsigned int> connectionViewVector;
00230
00231
00232 unsigned int firstSingleNeuronID;
00233
00234
00235 unsigned int secondSingleNeuronID;
00236
00237
00238 unsigned int maxFirstSingleNeuronID;
00239 unsigned int minFirstSingleNeuronID;
00240 unsigned int firstSingleNeuronGroupWidth;
00241 unsigned int maxSecondSingleNeuronID;
00242 unsigned int minSecondSingleNeuronID;
00243 unsigned int secondSingleNeuronGroupWidth;
00244 unsigned int firstSingleNeurGrpID;
00245 unsigned int secondSingleNeurGrpID;
00246
00247
00248 char maxWeight;
00249
00250
00251 char minWeight;
00252
00253
00254 bool showFromConnections;
00255
00256
00257 bool showToConnections;
00258
00259
00260 bool showBetweenConnections;
00261
00262
00263 map<unsigned int, bool>fromNeuronMap;
00264
00265
00266 map<unsigned int, bool>toNeuronMap;
00267
00268
00269
00270 unsigned int maxAutoLoadConnGrpSize;
00271
00272
00273
00274 bool viewStateChanged;
00275
00276
00277
00278 GLuint mainDisplayList;
00279
00280
00281
00282 bool paintingGL;
00283
00284
00285
00286
00287
00288 bool resizeSkipped;
00289
00290
00291
00292
00293
00294 bool paintSkipped;
00295 int newTempScreenWidth;
00296 int newTempScreenHeight;
00297
00298
00299
00300
00301 NetworkViewer (const NetworkViewer&);
00302
00303
00304 NetworkViewer operator = (const NetworkViewer&);
00305
00306 void checkOpenGLErrors();
00307 void deleteAllConnectionGroups();
00308 void deleteAllNeuronGroups();
00309 void disableFullRender();
00310 void drawAxes();
00311 void drawSolidSphere(GLdouble radius, GLint slices, GLint stacks);
00312 void fillRotationMatrix(float, float, float, float);
00313 float getFloat(string s);
00314 void initialiseCameraParameters();
00315 void initialiseFullRender();
00316 void loadAllConnectionGroups(QSplashScreen* splashScreen = 0);
00317 void loadAllNeuronGroups(QSplashScreen* splashScreen = 0);
00318 void rotateVector(float, float, float, GLfloat[]);
00319 void rotateXAxis(float angle);
00320 void rotateZAxis(float angle);
00321 void viewClippingVolume_Horizontal(ClippingVolume);
00322 void viewClippingVolume_Vertical(ClippingVolume);
00323
00324 };
00325
00326
00327 #endif//NETWORKVIEWER_H