Skip to content

Commit

Permalink
Merge pull request #31 from dvinc/master
Browse files Browse the repository at this point in the history
For v0.1.0-alpha
  • Loading branch information
dvinc committed Dec 16, 2013
2 parents e8815ad + 143d57c commit 50e8f88
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/client-api/C++/examples/build/
.SyncIgnore
/viewer-build
*-build/
2 changes: 1 addition & 1 deletion viewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ SET(VIBes_viewer_FORMS vibeswindow.ui)

QT5_WRAP_UI(VIBes_viewer_FORMS_HEADERS ${VIBes_viewer_FORMS})

ADD_EXECUTABLE(VIBes-viewer ${VIBes_viewer_SOURCES} ${VIBes_viewer_FORMS_HEADERS})
ADD_EXECUTABLE(VIBes-viewer WIN32 MACOSX_BUNDLE ${VIBes_viewer_SOURCES} ${VIBes_viewer_FORMS_HEADERS})
QT5_USE_MODULES(VIBes-viewer Widgets Gui Core Svg)
11 changes: 10 additions & 1 deletion viewer/figure2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Figure2D::Figure2D(QWidget *parent) :
setDragMode(ScrollHandDrag);
// Force full viewport update (avoid problems with axes)
setViewportUpdateMode(FullViewportUpdate);
// Never show the scrollbars
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
}

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

void Figure2D::wheelEvent(QWheelEvent *event)
{
double s = qPow(2.0, 0.05*event->delta()/8.0);
// Scales the view to zoom according to mouse wheel
double s = qPow(2.0, 0.04*event->angleDelta().y()/8.0);
this->scale(s,s);
// double dx = sceneRect().width() * (s - 1.0);
// double dy = sceneRect().height() * (s - 1.0);
// this->setSceneRect(sceneRect().adjusted(-dx,-dy,dx,dy));
// qDebug() << sceneRect();
// fitInView(sceneRect());
}

void Figure2D::exportGraphics(QString fileName)
Expand Down
2 changes: 1 addition & 1 deletion viewer/vibestreemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class VibesTreeModel : public QAbstractItemModel

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


void forceUpdate() {beginResetModel();endResetModel();}
signals:

public slots:
Expand Down
19 changes: 10 additions & 9 deletions viewer/vibeswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,16 @@ VibesWindow::processMessage(const QByteArray &msg_data)
// Remove from the list of figures an delete
figures.remove(fig_name);
delete fig;
static_cast<VibesTreeModel*>(ui->treeView->model())->forceUpdate();
}
// Create a new figure
// Create a new figure
else if (action == "new")
{
// Create a new figure (previous with the same name will be destroyed)
fig = newFigure(fig_name);
static_cast<VibesTreeModel*>(ui->treeView->model())->forceUpdate();
}
// Clear the contents of a figure
// Clear the contents of a figure
else if (action == "clear")
{
// Figure has to exist
Expand Down Expand Up @@ -293,7 +295,7 @@ VibesWindow::processMessage(const QByteArray &msg_data)
}
}
}
// Unknown action
// Unknown action
else
{
return false;
Expand Down Expand Up @@ -324,7 +326,6 @@ VibesWindow::readFile()
ui->statusBar->showMessage("Receiving data...", 200);

// Read and process data
QByteArray message;
while (!file.atEnd())
{
QByteArray line = file.readLine();
Expand All @@ -333,19 +334,19 @@ VibesWindow::readFile()
{
continue;
}
// Empty new line ("\n\n") is message separator
else if (line[0] == '\n')
// Empty new line ("\n\n") is message separator
else if (line[0] == '\n' && message.endsWith('\n'))
{
processMessage(message);
message.clear();
}
// Add this line to the current message
// Add this line to the current message
else
{
message.append(line);
}
}

// Program new file-read try in 200 ms.
QTimer::singleShot(200, this, SLOT(readFile()));
// Program new file-read try in 50 ms.
QTimer::singleShot(50, this, SLOT(readFile()));
}
1 change: 1 addition & 0 deletions viewer/vibeswindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public slots:
QPen defaultPen;

void initDefaultBrushes();
QByteArray message;
};

#endif // VIBESWINDOW_H

0 comments on commit 50e8f88

Please sign in to comment.