hdt 3.2.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/deps/hdt-it/.cproject +42 -0
  2. package/deps/hdt-it/.project +27 -0
  3. package/deps/hdt-it/Camera.cpp +249 -0
  4. package/deps/hdt-it/Camera.h +77 -0
  5. package/deps/hdt-it/Color.cpp +157 -0
  6. package/deps/hdt-it/Color.h +49 -0
  7. package/deps/hdt-it/Info.plist +58 -0
  8. package/deps/hdt-it/LICENSE +280 -0
  9. package/deps/hdt-it/README.md +73 -0
  10. package/deps/hdt-it/StopWatch.cpp +170 -0
  11. package/deps/hdt-it/StopWatch.hpp +61 -0
  12. package/deps/hdt-it/abouthdt.cpp +14 -0
  13. package/deps/hdt-it/abouthdt.hpp +22 -0
  14. package/deps/hdt-it/abouthdt.ui +173 -0
  15. package/deps/hdt-it/colors.hpp +29 -0
  16. package/deps/hdt-it/constants.h +39 -0
  17. package/deps/hdt-it/createdmg.sh +72 -0
  18. package/deps/hdt-it/dictionarysuggestions.cpp +186 -0
  19. package/deps/hdt-it/dictionarysuggestions.hpp +39 -0
  20. package/deps/hdt-it/doc/hdtit.png +0 -0
  21. package/deps/hdt-it/doc/manual.html +88 -0
  22. package/deps/hdt-it/doc/matrix.png +0 -0
  23. package/deps/hdt-it/editreset.png +0 -0
  24. package/deps/hdt-it/hdt-it.pro +135 -0
  25. package/deps/hdt-it/hdt-it_es.qm +0 -0
  26. package/deps/hdt-it/hdt-it_es.ts +906 -0
  27. package/deps/hdt-it/hdtcachedinfo.cpp +155 -0
  28. package/deps/hdt-it/hdtcachedinfo.hpp +38 -0
  29. package/deps/hdt-it/hdtcontroller.cpp +369 -0
  30. package/deps/hdt-it/hdtcontroller.hpp +103 -0
  31. package/deps/hdt-it/hdtico.icns +0 -0
  32. package/deps/hdt-it/hdtico.rc +1 -0
  33. package/deps/hdt-it/hdtit.cpp +400 -0
  34. package/deps/hdt-it/hdtit.hpp +78 -0
  35. package/deps/hdt-it/hdtit.ui +875 -0
  36. package/deps/hdt-it/hdtoperation.cpp +284 -0
  37. package/deps/hdt-it/hdtoperation.hpp +71 -0
  38. package/deps/hdt-it/hdtresources.qrc +7 -0
  39. package/deps/hdt-it/hdtspecform.cpp +180 -0
  40. package/deps/hdt-it/hdtspecform.hpp +38 -0
  41. package/deps/hdt-it/hdtspecform.ui +361 -0
  42. package/deps/hdt-it/hdtsummarygenerator.cpp +109 -0
  43. package/deps/hdt-it/hdtsummarygenerator.hpp +15 -0
  44. package/deps/hdt-it/hdtwinico.ico +0 -0
  45. package/deps/hdt-it/hdtwinico2.ico +0 -0
  46. package/deps/hdt-it/headermodel.cpp +174 -0
  47. package/deps/hdt-it/headermodel.hpp +38 -0
  48. package/deps/hdt-it/loading.gif +0 -0
  49. package/deps/hdt-it/logo-hdt.png +0 -0
  50. package/deps/hdt-it/logo-hdt2.png +0 -0
  51. package/deps/hdt-it/main.cpp +39 -0
  52. package/deps/hdt-it/matrixviewwidget.cpp +501 -0
  53. package/deps/hdt-it/matrixviewwidget.hpp +81 -0
  54. package/deps/hdt-it/myapplication.cpp +45 -0
  55. package/deps/hdt-it/myapplication.hpp +24 -0
  56. package/deps/hdt-it/predicatestatus.cpp +97 -0
  57. package/deps/hdt-it/predicatestatus.hpp +39 -0
  58. package/deps/hdt-it/qclearlineedit.cpp +48 -0
  59. package/deps/hdt-it/qclearlineedit.hpp +30 -0
  60. package/deps/hdt-it/regexmodel.cpp +132 -0
  61. package/deps/hdt-it/regexmodel.hpp +37 -0
  62. package/deps/hdt-it/resultcounter.cpp +47 -0
  63. package/deps/hdt-it/resultcounter.hpp +30 -0
  64. package/deps/hdt-it/searchresultsmodel.cpp +179 -0
  65. package/deps/hdt-it/searchresultsmodel.hpp +39 -0
  66. package/deps/hdt-it/sparqlform.cpp +27 -0
  67. package/deps/hdt-it/sparqlform.hpp +28 -0
  68. package/deps/hdt-it/sparqlform.ui +112 -0
  69. package/deps/hdt-it/sparqlmodel.cpp +155 -0
  70. package/deps/hdt-it/sparqlmodel.hpp +32 -0
  71. package/deps/hdt-it/stringutils.cpp +48 -0
  72. package/deps/hdt-it/stringutils.hpp +18 -0
  73. package/deps/hdt-it/triplecomponentmodel.cpp +146 -0
  74. package/deps/hdt-it/triplecomponentmodel.hpp +33 -0
  75. package/deps/libcds/Doxyfile +307 -0
  76. package/deps/libcds/tutorial/tutorial.pdf +0 -0
  77. package/deps/libhdt/.cproject +304 -0
  78. package/deps/libhdt/Doxyfile +1630 -0
  79. package/package.json +7 -1
  80. package/.eslintrc +0 -178
  81. package/.github/workflows/ci.yml +0 -73
  82. package/.gitmodules +0 -4
  83. package/.idea/codeStyles/Project.xml +0 -38
  84. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  85. package/.idea/hdt.iml +0 -12
  86. package/.idea/inspectionProfiles/Project_Default.xml +0 -7
  87. package/.idea/jsLinters/jshint.xml +0 -16
  88. package/.idea/modules.xml +0 -8
  89. package/.idea/vcs.xml +0 -7
  90. package/.jshintignore +0 -1
  91. package/.jshintrc +0 -10
  92. package/perf/run.js +0 -43
  93. package/replace-in-file.json +0 -5
Binary file
Binary file
Binary file
@@ -0,0 +1,39 @@
1
+
2
+ #include <QTranslator>
3
+ #include <QLibraryInfo>
4
+ #include <QLocale>
5
+ #include "myapplication.hpp"
6
+ #include "hdtit.hpp"
7
+
8
+ #include <iostream>
9
+
10
+ int main(int argc, char *argv[])
11
+ {
12
+ MyApplication a(argc, argv);
13
+
14
+ QTranslator qtTranslator;
15
+ qtTranslator.load("qt_" + QLocale::system().name(),
16
+ QLibraryInfo::location(QLibraryInfo::TranslationsPath));
17
+ a.installTranslator(&qtTranslator);
18
+
19
+ QTranslator myappTranslator;
20
+ #ifdef __APPLE__
21
+ myappTranslator.load("../Resources/hdt-it_"+QLocale::system().name());
22
+ #else
23
+ myappTranslator.load("hdt-it_"+QLocale::system().name());
24
+ #endif
25
+ a.installTranslator(&myappTranslator);
26
+
27
+ HDTit w;
28
+
29
+ a.setHDTit(&w);
30
+
31
+ w.show();
32
+
33
+ if(argc>1) {
34
+ QString str(argv[1]);
35
+ w.openHDTFile(str);
36
+ }
37
+
38
+ return a.exec();
39
+ }
@@ -0,0 +1,501 @@
1
+ #include "matrixviewwidget.hpp"
2
+
3
+ #include "Color.h"
4
+ #include <fstream>
5
+ #include "stringutils.hpp"
6
+
7
+
8
+ MatrixViewWidget::MatrixViewWidget(QWidget *parent) :
9
+ QGLWidget(parent)
10
+ {
11
+ setMouseTracking(true);
12
+ connect(&camera, SIGNAL(cameraChanged()), (QObject *)this, SLOT(updateGL()));
13
+ connect(&camera, SIGNAL(rotationChanged()), (QObject *)this, SIGNAL(rotationChanged()));
14
+
15
+ timer.setInterval(20);
16
+ connect(&timer, SIGNAL(timeout()), this, SLOT(updateGL()));
17
+
18
+ //timer.start();
19
+
20
+ #ifdef GESTURES
21
+ //grabGesture(Qt::PanGesture);
22
+ grabGesture(Qt::PinchGesture);
23
+ //grabGesture(Qt::SwipeGesture);
24
+ #endif
25
+ }
26
+
27
+ MatrixViewWidget::~MatrixViewWidget() {
28
+
29
+ }
30
+
31
+ void MatrixViewWidget::setManager(HDTController *hdtManager)
32
+ {
33
+ this->hdtController = hdtManager;
34
+ }
35
+
36
+ Camera & MatrixViewWidget::getCamera()
37
+ {
38
+ return camera;
39
+ }
40
+
41
+ void MatrixViewWidget::initializeGL()
42
+ {
43
+ glClearColor(BACKGROUND_COLOR);
44
+ //glClearDepth(1.0f);
45
+
46
+ //glEnable(GL_DEPTH_TEST);
47
+ //glDepthFunc(GL_LEQUAL);
48
+
49
+ // FIXME: Check support of alpha blending
50
+ glEnable (GL_BLEND);
51
+ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
52
+ }
53
+
54
+ void MatrixViewWidget::paintShared()
55
+ {
56
+ size_t nshared = hdtController->getHDT()->getDictionary()->getNshared();
57
+
58
+ glColor4d(SHARED_AREA_COLOR);
59
+ glBegin(GL_QUADS);
60
+ glVertex3f(0, 0, 0);
61
+ glVertex3f(0, nshared, 0);
62
+ glVertex3f(nshared, nshared, 0);
63
+ glVertex3f(nshared, 0, 0);
64
+ glEnd();
65
+
66
+ glColor4d(SHARED_AREA_BORDER_COLOR);
67
+ glBegin(GL_LINE_STRIP);
68
+ glVertex3f(0, nshared, 0);
69
+ glVertex3f(nshared, nshared, 0);
70
+ glVertex3f(nshared, 0, 0);
71
+ glEnd();
72
+ }
73
+
74
+ void MatrixViewWidget::paintScales()
75
+ {
76
+ hdt::Dictionary *dict = hdtController->getHDT()->getDictionary();
77
+ size_t nsubjects = dict->getMaxSubjectID();
78
+ size_t nobjects = dict->getMaxObjectID();
79
+ size_t npredicates = dict->getMaxPredicateID();
80
+
81
+ // Draw subject scale
82
+ for (size_t i = 0; i <= nsubjects; i += 1+nsubjects / 15) {
83
+ QString str;
84
+ if (nsubjects > 20000) {
85
+ str.append(QString("%1K").arg(i/1000));
86
+ } else {
87
+ str.append(QString("%1").arg(i));
88
+ }
89
+ glColor4d(TEXT_COLOR);
90
+ this->renderText(0.0, i+nsubjects*0.01, 0, str);
91
+
92
+ glColor4d(GRID_COLOR);
93
+ glBegin(GL_LINES);
94
+ glVertex3f(0, i, 0);
95
+ glVertex3f(nobjects, i, 0);
96
+ glVertex3f(0, i, 0);
97
+ glVertex3f(0, i, npredicates);
98
+ glEnd();
99
+ }
100
+
101
+ // Draw object scale
102
+ for (size_t i = 0; i <= nobjects; i += 1+ nobjects / 15) {
103
+ QString str;
104
+ if (nobjects > 20000) {
105
+ str.append(QString("%1K").arg(i/1000));
106
+ } else {
107
+ str.append(QString("%1").arg(i));
108
+ }
109
+ glColor4d(TEXT_COLOR);
110
+ this->renderText(i, 0.0, 0, str);
111
+
112
+ glColor4d(GRID_COLOR);
113
+ glBegin(GL_LINES);
114
+ glVertex3f(i, 0, 0);
115
+ glVertex3f(i, nsubjects, 0);
116
+ glVertex3f(i, 0, 0);
117
+ glVertex3f(i, 0, npredicates);
118
+ glEnd();
119
+ }
120
+
121
+ // Draw predicate scale
122
+ for (size_t i = 0; i <= npredicates; i += 1+npredicates / 10) {
123
+ QString str = QString::number(i);
124
+ //texto(str, 0, 0, i);
125
+ glColor4d(TEXT_COLOR);
126
+ this->renderText(0, 0, i, str, QFont());
127
+
128
+ glColor4d(GRID_COLOR);
129
+ glBegin(GL_LINES);
130
+ glVertex3f(0, 0, i);
131
+ glVertex3f(nobjects, 0, i);
132
+ glVertex3f(0, 0, i);
133
+ glVertex3f(0, nsubjects, i);
134
+ glEnd();
135
+ }
136
+
137
+ // Draw outter axis
138
+ glColor4d(AXIS_COLOR);
139
+ glBegin(GL_LINES);
140
+ glVertex3f(0, 0, 0);
141
+ glVertex3f(0, nsubjects, 0);
142
+ glVertex3f(0, 0, 0);
143
+ glVertex3f(nobjects, 0, 0);
144
+
145
+ glVertex3f(0, 0, npredicates);
146
+ glVertex3f(0, nsubjects, npredicates);
147
+ glVertex3f(0, 0, npredicates);
148
+ glVertex3f(nobjects, 0, npredicates);
149
+
150
+ glVertex3f(0, 0, 0);
151
+ glVertex3f(0, 0, npredicates);
152
+
153
+ glVertex3f(0, nsubjects, 0);
154
+ glVertex3f(0, nsubjects, npredicates);
155
+
156
+ glVertex3f(nobjects, 0, 0);
157
+ glVertex3f(nobjects, 0, npredicates);
158
+
159
+ glVertex3f(nobjects, 0, 0);
160
+ glVertex3f(nobjects, nsubjects, 0);
161
+
162
+ glVertex3f(nobjects, nsubjects, 0);
163
+ glVertex3f(0, nsubjects, 0);
164
+ glEnd();
165
+
166
+ // Draw labels
167
+ glColor4d(TEXT_COLOR);
168
+ renderText(0, nsubjects * 1.04, 0, "Subjects");
169
+ renderText(nobjects * 1.05, 0, 0, "Objects");
170
+ renderText(0, 0, npredicates*1.05, "Predicates");
171
+ }
172
+
173
+ void MatrixViewWidget::paintPoints()
174
+ {
175
+ if(hdtController->getNumResults()==0) {
176
+ // Do not render anything
177
+ } else if(hdtController->getNumResults()<5000) {
178
+ // Render directly from iterator.
179
+ hdt::IteratorTripleID *it = hdtController->getHDT()->getTriples()->search(hdtController->getSearchPatternID());
180
+
181
+ glPointSize(3);
182
+ glBegin(GL_POINTS);
183
+ while(it->hasNext()) {
184
+ hdt::TripleID *tid = it->next();
185
+
186
+ Color *c = hdtController->getHDTCachedInfo()->getPredicateColor(tid->getPredicate()-1);
187
+
188
+ if(hdtController->getPredicateStatus()->isPredicateActive(tid->getPredicate()-1)) {
189
+ glColor4d(c->r, c->g, c->b, 1.0);
190
+ } else {
191
+ glColor4d(c->r/4, c->g/4, c->b/4, 0.3);
192
+ }
193
+
194
+ glVertex3f((float)tid->getObject(), (float)tid->getSubject(), (float)tid->getPredicate());
195
+ }
196
+ glEnd();
197
+ delete it;
198
+
199
+ } else {
200
+ // Render from cached points.
201
+ glPointSize(RDF_POINT_SIZE);
202
+ glBegin(GL_POINTS);
203
+ vector<hdt::TripleID> triples = hdtController->getTriples();
204
+ for(size_t i=0;i<triples.size();i++) {
205
+ hdt::TripleID *tid = &triples[i];
206
+
207
+ if(tid->match(hdtController->getSearchPatternID())) {
208
+ Color *c = hdtController->getHDTCachedInfo()->getPredicateColor(tid->getPredicate()-1);
209
+
210
+ if(hdtController->getPredicateStatus()->isPredicateActive(tid->getPredicate()-1)) {
211
+ glColor4d(c->r, c->g, c->b, 1.0);
212
+ } else {
213
+ glColor4d(c->r/4, c->g/4, c->b/4, 0.3);
214
+ }
215
+
216
+ glVertex3f((float)tid->getObject(), (float)tid->getSubject(), (float)tid->getPredicate());
217
+ }
218
+ }
219
+ glEnd();
220
+ }
221
+
222
+ }
223
+
224
+
225
+
226
+ void MatrixViewWidget::paintSelected()
227
+ {
228
+ hdt::TripleID selectedTriple = hdtController->getSelectedTriple();
229
+
230
+ // Draw selected triple
231
+ if (selectedTriple.isValid()) {
232
+ size_t nsubjects = hdtController->getHDT()->getDictionary()->getMaxSubjectID();
233
+ size_t npredicates = hdtController->getHDT()->getDictionary()->getMaxPredicateID();
234
+ size_t nobjects = hdtController->getHDT()->getDictionary()->getMaxObjectID();
235
+
236
+ float x = selectedTriple.getObject();
237
+ float y = selectedTriple.getSubject();
238
+ float z = selectedTriple.getPredicate();
239
+
240
+ glColor4f(CROSS_COLOR);
241
+ glBegin(GL_LINES);
242
+
243
+ // Draw +
244
+ glVertex3f(0, y, z);
245
+ glVertex3f(nobjects, y, z);
246
+ glVertex3f(x, 0, z);
247
+ glVertex3f(x, nsubjects, z);
248
+
249
+ glEnd();
250
+
251
+ // Draw point
252
+ glPointSize(5);
253
+ glBegin(GL_POINTS);
254
+ Color c;
255
+ ColorRamp2 cr;
256
+ cr.apply(&c, z, 0, npredicates);
257
+ glColor4f(c.r, c.g, c.b, c.a);
258
+ glVertex3f(x, y, z);
259
+ glEnd();
260
+ }
261
+ }
262
+
263
+ void MatrixViewWidget::paintGL()
264
+ {
265
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
266
+
267
+ if(!hdtController->hasHDT()) {
268
+ return;
269
+ }
270
+
271
+ glLoadIdentity();
272
+
273
+ camera.applyTransform();
274
+
275
+ size_t nsubjects = hdtController->getHDT()->getDictionary()->getMaxSubjectID();
276
+ size_t nobjects = hdtController->getHDT()->getDictionary()->getMaxObjectID();
277
+ size_t npredicates = hdtController->getHDT()->getDictionary()->getMaxPredicateID();
278
+
279
+ glScalef(1.0f / (float) nobjects, 1.0f / (float) nsubjects, 1.0f / (float) npredicates);
280
+
281
+ // PAINT SHARED AREA
282
+ paintShared();
283
+
284
+ // RENDER SCALES
285
+ paintScales();
286
+
287
+ // RENDER POINTS
288
+ paintPoints();
289
+
290
+ // RENDER SELECTED
291
+ paintSelected();
292
+ }
293
+
294
+ void MatrixViewWidget::resizeGL(int w, int h)
295
+ {
296
+ //std::cout << "Widget resize: " << w << ", " << h << std::endl;
297
+ camera.setScreenSize(w,h);
298
+ this->updateGL();
299
+ }
300
+
301
+ void MatrixViewWidget::mousePressEvent(QMouseEvent *event)
302
+ {
303
+ //std::cout << event->type() << "DOW Btn: "<< event->buttons() << " Mod: " << event->modifiers() << " " << event->x() << ", " << event->y() << std::endl;
304
+
305
+ lastClickX = lastX = event->x();
306
+ lastClickY = lastY = event->y();
307
+ buttonClick = event->buttons();
308
+ }
309
+
310
+ void MatrixViewWidget::mouseReleaseEvent(QMouseEvent *event)
311
+ {
312
+ //std::cout << event->type() << "REL Btn: "<< event->buttons() << " Mod: " << event->modifiers() << " " << event->x() << ", " << event->y() << std::endl;
313
+
314
+ if(event->x()==lastClickX && event->y()==lastClickY) {
315
+ //std::cout << "Mouse CLICK" << std::endl;
316
+ if(buttonClick & Qt::LeftButton) {
317
+ //std::cout << "Left Mouse CLICK" << std::endl;
318
+ if(hdtController->getSelectedTriple().isValid()) {
319
+ hdtController->getPredicateStatus()->selectPredicate(hdtController->getSelectedTriple().getPredicate());
320
+ }
321
+ } else if (buttonClick & Qt::RightButton) {
322
+ //std::cout << "Right Mouse CLICK" << std::endl;
323
+ hdtController->getPredicateStatus()->selectAllPredicates();
324
+ }
325
+ }
326
+ }
327
+
328
+ void MatrixViewWidget::unProject(int x, int y, double *outx, double *outy, double *outz)
329
+ {
330
+
331
+ glMatrixMode(GL_MODELVIEW);
332
+ glLoadIdentity();
333
+
334
+ camera.applyTransform();
335
+
336
+ hdt::Dictionary *dict = hdtController->getHDT()->getDictionary();
337
+
338
+ glScalef(1.0f / (float) dict->getMaxObjectID(),
339
+ 1.0f / (float) dict->getMaxSubjectID(),
340
+ 1.0f / (float) dict->getMaxPredicateID());
341
+
342
+ // UnProject
343
+ GLint viewport[4];
344
+ GLdouble modelview[16], projection[16];
345
+ GLdouble wx = x, wy, wz;
346
+
347
+ glGetIntegerv(GL_VIEWPORT, viewport);
348
+ y = viewport[3] - y;
349
+ wy = y;
350
+
351
+ glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
352
+ glGetDoublev(GL_PROJECTION_MATRIX, projection);
353
+ glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &wz);
354
+ //printf("Orig: %f %f %f\n", wx, wy, wz);
355
+ gluUnProject(wx, wy, 0, modelview, projection, viewport, outx, outy, outz);
356
+ //printf("Dest: %f %f %f\n", *outx, *outy, *outz);
357
+ }
358
+
359
+ void MatrixViewWidget::mouseMoveEvent(QMouseEvent *event)
360
+ {
361
+ //std::cout << event->type() << "MOV Btn: "<< event->buttons() << " Mod: " << event->modifiers() << " " << event->x() << ", " << event->y() << std::endl;
362
+
363
+ int diffx = event->x() - lastX;
364
+ int diffy = event->y() - lastY;
365
+
366
+ lastX = event->x();
367
+ lastY = event->y();
368
+
369
+ bool left = event->buttons() & Qt::LeftButton;
370
+ bool right = event->buttons() & Qt::RightButton;
371
+ bool shift = event->modifiers() & Qt::ShiftModifier;
372
+
373
+ if(right || (left && shift)) {
374
+ camera.moveOffset(1.8*diffx, 1.8*diffy);
375
+ emit cameraChanged();
376
+ } else if(left) {
377
+ camera.rotateCamera(diffx, diffy);
378
+ emit cameraChanged();
379
+ }
380
+
381
+ if(hdtController->getHDT()==NULL)
382
+ return;
383
+
384
+ if(!camera.isFrontView()) {
385
+ hdtController->clearSelectedTriple();
386
+ return;
387
+ }
388
+
389
+ GLdouble subject, predicate, object;
390
+ this->unProject(event->x(), event->y(), &object, &subject, &predicate);
391
+
392
+ hdt::Dictionary *dictionary = hdtController->getHDT()->getDictionary();
393
+ if ( (subject > 0 && subject < dictionary->getMaxSubjectID()) &&
394
+ (object > 0 && object <= dictionary->getMaxObjectID())
395
+ ) {
396
+ hdtController->selectNearestTriple(subject,predicate, object);
397
+
398
+ QString subjStr = stringutils::escapeHTML(stringutils::toQString(dictionary->idToString(hdtController->getSelectedTriple().getSubject(), hdt::SUBJECT).c_str()));
399
+ QString predStr = stringutils::escapeHTML(stringutils::toQString(dictionary->idToString(hdtController->getSelectedTriple().getPredicate(), hdt::PREDICATE).c_str()));
400
+ QString objStr = stringutils::escapeHTML(stringutils::toQString(dictionary->idToString(hdtController->getSelectedTriple().getObject(), hdt::OBJECT).c_str()));
401
+ stringutils::cut(objStr, 1000);
402
+ QString tooltip = QString("<p style='white-space:pre'><b>S</b>: %1</p><p style='white-space:pre'><b>P</b>: %2</p><p><b>O</b>:&nbsp;%3</p>").arg(subjStr).arg(predStr).arg(objStr);
403
+ QPoint point = this->mapToGlobal(event->pos());
404
+ QRect rect = QRect(point.x()-10, point.y()+10, 20, 20);
405
+ QToolTip::showText(point, tooltip, this, rect);
406
+ } else {
407
+ hdtController->clearSelectedTriple();
408
+ QToolTip::hideText();
409
+ }
410
+
411
+ updateGL();
412
+ }
413
+
414
+
415
+ void MatrixViewWidget::wheelEvent( QWheelEvent* e )
416
+ {
417
+ int delta = e->delta();
418
+ if (e->orientation() == Qt::Horizontal) {
419
+ #ifdef GESTURES
420
+ camera.moveOffset(delta/2, 0);
421
+ #endif
422
+ } else {
423
+ #ifdef GESTURES
424
+ camera.moveOffset(0, delta/2);
425
+ #else
426
+ camera.increaseZoom(delta);
427
+ #endif
428
+ }
429
+ hdtController->clearSelectedTriple();
430
+ e->accept();
431
+ }
432
+
433
+ #ifdef GESTURES
434
+ bool MatrixViewWidget::event(QEvent *event)
435
+ {
436
+ static qreal previousZoom;
437
+ if (event->type() == QEvent::Gesture) {
438
+ QGestureEvent *gestureEvent = static_cast<QGestureEvent*>(event);
439
+ if (QGesture *swipe = gestureEvent->gesture(Qt::SwipeGesture)) {
440
+ QSwipeGesture *swipeGesture = static_cast<QSwipeGesture *>(swipe);
441
+ } else if (QGesture *pan = gestureEvent->gesture(Qt::PanGesture)) {
442
+ QPanGesture *panGesture = static_cast<QPanGesture *>(pan);
443
+ if(panGesture->state() == Qt::GestureStarted) {
444
+ //cout << "Panning start" << endl;
445
+ }
446
+ if(panGesture->state() == Qt::GestureFinished) {
447
+ //cout << "Panning end" << endl;
448
+ }
449
+ return true;
450
+ } else if (QGesture *pinch = gestureEvent->gesture(Qt::PinchGesture)) {
451
+ QPinchGesture *pinchGesture = static_cast<QPinchGesture *>(pinch);
452
+
453
+ QPinchGesture::ChangeFlags changeFlags = pinchGesture->changeFlags();
454
+ if (changeFlags & QPinchGesture::RotationAngleChanged) {
455
+ qreal value = pinchGesture->property("rotationAngle").toReal();
456
+ qreal lastValue = pinchGesture->property("lastRotationAngle").toReal();
457
+ camera.rotateCamera(2.0*(lastValue-value), 0);
458
+ return true;
459
+ }
460
+
461
+ if (changeFlags & QPinchGesture::ScaleFactorChanged) {
462
+ if(pinchGesture->state() == Qt::GestureStarted) {
463
+ previousZoom = camera.getZoom();
464
+ }
465
+ qreal value = pinchGesture->property("scaleFactor").toReal();
466
+ camera.setZoom(previousZoom*value);
467
+ return true;
468
+ }
469
+ }
470
+ }
471
+ return QGLWidget::event(event);
472
+ }
473
+ #endif
474
+
475
+ QSize MatrixViewWidget::minimumSizeHint() const
476
+ {
477
+ return QSize(300,150);
478
+ }
479
+
480
+ QSize MatrixViewWidget::sizeHint() const
481
+ {
482
+ return QSize(800,600);
483
+ }
484
+
485
+ void MatrixViewWidget::reloadHDTInfo()
486
+ {
487
+ if(hdtController->getHDT()==NULL) {
488
+ return;
489
+ }
490
+
491
+ updateGL();
492
+ }
493
+
494
+
495
+
496
+
497
+
498
+
499
+
500
+
501
+
@@ -0,0 +1,81 @@
1
+ #ifndef MATRIXVIEWWIDGET_HPP
2
+ #define MATRIXVIEWWIDGET_HPP
3
+
4
+ #include <QtGui>
5
+ #include <QtOpenGL>
6
+ #include <QGLWidget>
7
+
8
+ #ifdef __APPLE__
9
+ #include <glu.h>
10
+ #else
11
+ #include <GL/glu.h>
12
+ #endif
13
+
14
+ #include <HDT.hpp>
15
+ #include <HDTSpecification.hpp>
16
+
17
+ #include "colors.hpp"
18
+ #include "Camera.h"
19
+ #include "StopWatch.hpp"
20
+
21
+ #include "hdtcontroller.hpp"
22
+ #include "searchresultsmodel.hpp"
23
+ #include "triplecomponentmodel.hpp"
24
+
25
+ class SearchResultsModel;
26
+ class TripleComponentModel;
27
+ class HDTController;
28
+
29
+ #ifdef __APPLE__
30
+ //#define GESTURES
31
+ #endif
32
+
33
+ class MatrixViewWidget : public QGLWidget
34
+ {
35
+ Q_OBJECT
36
+
37
+ private:
38
+ QTimer timer;
39
+ Camera camera;
40
+ int lastX, lastY, lastClickX, lastClickY, buttonClick;
41
+ HDTController *hdtController;
42
+
43
+ void unProject(int x, int y, double *outx, double *outy, double *outz);
44
+
45
+ void paintShared();
46
+ void paintScales();
47
+ void paintPoints();
48
+ void paintSelected();
49
+
50
+ public:
51
+ explicit MatrixViewWidget(QWidget *parent = 0);
52
+ ~MatrixViewWidget();
53
+
54
+ void setManager(HDTController *hdtManager);
55
+
56
+ QSize minimumSizeHint() const;
57
+ QSize sizeHint() const;
58
+
59
+ Camera &getCamera();
60
+ protected:
61
+ void initializeGL();
62
+ void paintGL();
63
+ void resizeGL(int width, int height);
64
+ void mousePressEvent(QMouseEvent *event);
65
+ void mouseReleaseEvent(QMouseEvent *event);
66
+ void mouseMoveEvent(QMouseEvent *event);
67
+ void wheelEvent( QWheelEvent* e );
68
+ #ifdef GESTURES
69
+ bool event(QEvent *);
70
+ #endif
71
+
72
+ public slots:
73
+ void reloadHDTInfo();
74
+
75
+ signals:
76
+ void rotationChanged();
77
+ void cameraChanged();
78
+ };
79
+
80
+
81
+ #endif // MATRIXVIEWWIDGET_HPP
@@ -0,0 +1,45 @@
1
+ #include "myapplication.hpp"
2
+
3
+ MyApplication::MyApplication(int &argc, char **argv) : QApplication(argc, argv), hdtIt(NULL)
4
+ {
5
+ }
6
+
7
+ bool MyApplication::event(QEvent *event)
8
+ {
9
+ switch (event->type()) {
10
+ case QEvent::FileOpen:
11
+ loadFile(static_cast<QFileOpenEvent *>(event)->file());
12
+ return true;
13
+ default:
14
+ return QApplication::event(event);
15
+ }
16
+ }
17
+
18
+ void MyApplication::loadFile(QString fileName)
19
+ {
20
+ if(hdtIt) {
21
+ hdtIt->openHDTFile(fileName);
22
+ }
23
+ }
24
+
25
+ void MyApplication::setHDTit(HDTit *hdtIt)
26
+ {
27
+ this->hdtIt=hdtIt;
28
+ }
29
+
30
+ bool MyApplication::notify(QObject *o, QEvent *e)
31
+ {
32
+ try {
33
+ return QApplication::notify(o, e);
34
+ } catch (char *err) {
35
+ std::cerr << "Exception caugth in notify (char *): " << err << endl;
36
+ } catch (const char *err) {
37
+ std::cerr << "Exception caugth in notify (const char *): " << err << endl;
38
+ } catch (const std::exception& ex) {
39
+ std::cerr << "Exception caugth in notify (std::exception &): " << ex.what() << endl;
40
+ } catch (const std::string& ex) {
41
+ std::cerr << "Exception caugth in notify (std::string &): " << ex << endl;
42
+ } catch (...) {
43
+ std::cerr << "Unknown Exception caugth in notify: " << endl;
44
+ }
45
+ }
@@ -0,0 +1,24 @@
1
+ #ifndef MYAPPLICATION_HPP
2
+ #define MYAPPLICATION_HPP
3
+
4
+ #include <QApplication>
5
+ #include "hdtit.hpp"
6
+
7
+ class MyApplication : public QApplication
8
+ {
9
+ Q_OBJECT
10
+ private:
11
+ HDTit *hdtIt;
12
+ void loadFile(QString fileName);
13
+ public:
14
+ explicit MyApplication(int &argc, char **argv);
15
+ bool event(QEvent *);
16
+ void setHDTit(HDTit *hdtIt);
17
+ bool notify(QObject *, QEvent *);
18
+ signals:
19
+
20
+ public slots:
21
+
22
+ };
23
+
24
+ #endif // MYAPPLICATION_HPP