Skip to content

Commit 50e8f88

Browse files
committed
Merge pull request #31 from dvinc/master
For v0.1.0-alpha
2 parents e8815ad + 143d57c commit 50e8f88

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/client-api/C++/examples/build/
66
.SyncIgnore
77
/viewer-build
8+
*-build/

viewer/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ SET(VIBes_viewer_FORMS vibeswindow.ui)
1313

1414
QT5_WRAP_UI(VIBes_viewer_FORMS_HEADERS ${VIBes_viewer_FORMS})
1515

16-
ADD_EXECUTABLE(VIBes-viewer ${VIBes_viewer_SOURCES} ${VIBes_viewer_FORMS_HEADERS})
16+
ADD_EXECUTABLE(VIBes-viewer WIN32 MACOSX_BUNDLE ${VIBes_viewer_SOURCES} ${VIBes_viewer_FORMS_HEADERS})
1717
QT5_USE_MODULES(VIBes-viewer Widgets Gui Core Svg)

viewer/figure2d.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Figure2D::Figure2D(QWidget *parent) :
1515
setDragMode(ScrollHandDrag);
1616
// Force full viewport update (avoid problems with axes)
1717
setViewportUpdateMode(FullViewportUpdate);
18+
// Never show the scrollbars
19+
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
20+
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
1821
}
1922

2023
void Figure2D::drawForeground(QPainter *painter, const QRectF &rect)
@@ -62,8 +65,14 @@ void Figure2D::drawForeground(QPainter *painter, const QRectF &rect)
6265

6366
void Figure2D::wheelEvent(QWheelEvent *event)
6467
{
65-
double s = qPow(2.0, 0.05*event->delta()/8.0);
68+
// Scales the view to zoom according to mouse wheel
69+
double s = qPow(2.0, 0.04*event->angleDelta().y()/8.0);
6670
this->scale(s,s);
71+
// double dx = sceneRect().width() * (s - 1.0);
72+
// double dy = sceneRect().height() * (s - 1.0);
73+
// this->setSceneRect(sceneRect().adjusted(-dx,-dy,dx,dy));
74+
// qDebug() << sceneRect();
75+
// fitInView(sceneRect());
6776
}
6877

6978
void Figure2D::exportGraphics(QString fileName)

viewer/vibestreemodel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class VibesTreeModel : public QAbstractItemModel
2020

2121
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
2222

23-
23+
void forceUpdate() {beginResetModel();endResetModel();}
2424
signals:
2525

2626
public slots:

viewer/vibeswindow.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,16 @@ VibesWindow::processMessage(const QByteArray &msg_data)
171171
// Remove from the list of figures an delete
172172
figures.remove(fig_name);
173173
delete fig;
174+
static_cast<VibesTreeModel*>(ui->treeView->model())->forceUpdate();
174175
}
175-
// Create a new figure
176+
// Create a new figure
176177
else if (action == "new")
177178
{
178179
// Create a new figure (previous with the same name will be destroyed)
179180
fig = newFigure(fig_name);
181+
static_cast<VibesTreeModel*>(ui->treeView->model())->forceUpdate();
180182
}
181-
// Clear the contents of a figure
183+
// Clear the contents of a figure
182184
else if (action == "clear")
183185
{
184186
// Figure has to exist
@@ -293,7 +295,7 @@ VibesWindow::processMessage(const QByteArray &msg_data)
293295
}
294296
}
295297
}
296-
// Unknown action
298+
// Unknown action
297299
else
298300
{
299301
return false;
@@ -324,7 +326,6 @@ VibesWindow::readFile()
324326
ui->statusBar->showMessage("Receiving data...", 200);
325327

326328
// Read and process data
327-
QByteArray message;
328329
while (!file.atEnd())
329330
{
330331
QByteArray line = file.readLine();
@@ -333,19 +334,19 @@ VibesWindow::readFile()
333334
{
334335
continue;
335336
}
336-
// Empty new line ("\n\n") is message separator
337-
else if (line[0] == '\n')
337+
// Empty new line ("\n\n") is message separator
338+
else if (line[0] == '\n' && message.endsWith('\n'))
338339
{
339340
processMessage(message);
340341
message.clear();
341342
}
342-
// Add this line to the current message
343+
// Add this line to the current message
343344
else
344345
{
345346
message.append(line);
346347
}
347348
}
348349

349-
// Program new file-read try in 200 ms.
350-
QTimer::singleShot(200, this, SLOT(readFile()));
350+
// Program new file-read try in 50 ms.
351+
QTimer::singleShot(50, this, SLOT(readFile()));
351352
}

viewer/vibeswindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public slots:
3939
QPen defaultPen;
4040

4141
void initDefaultBrushes();
42+
QByteArray message;
4243
};
4344

4445
#endif // VIBESWINDOW_H

0 commit comments

Comments
 (0)