Skip to content

Commit

Permalink
Major re-jigging of the Scale Grid (part deux)
Browse files Browse the repository at this point in the history
- Added option to turn on/off minor scale grid lines.
- Added font size option. 7 preset font sizes availble.
- Added a SG reset option to set everything back to SPIERSview defaults.
- Updated SPV file version from 10 to 11, which now saves all SG options and restores them on load (including whether the SG was turned on/off at time of save).

I've run on of ideas for how to improve this feature now! It now does everything I wnat it too, and a bit more, hopefully all these new option will allow enough customization to make the SG useful at all scales and in all situations.
  • Loading branch information
alanspencer committed Nov 8, 2018
1 parent e6c2ca7 commit 3fd02ce
Show file tree
Hide file tree
Showing 15 changed files with 1,092 additions and 601 deletions.
9 changes: 6 additions & 3 deletions SPIERSview/SPIERSview.pro
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ SOURCES += src/main.cpp \
src/spvwriter.cpp \
src/staticfunctions.cpp \
src/drawglscalegrid.cpp \
src/drawglscaleball.cpp
src/drawglscaleball.cpp \
src/gridfontsizedialog.cpp

HEADERS += src/mainwindow.h \
../SPIERScommon/src/darkstyletheme.h \
Expand Down Expand Up @@ -291,9 +292,11 @@ HEADERS += src/mainwindow.h \
src/spvwriter.h \
src/staticfunctions.h \
src/drawglscalegrid.h \
src/drawglscaleball.h
src/drawglscaleball.h \
src/gridfontsizedialog.h

FORMS += ui/mainwindow.ui \
ui/movetogroup.ui \
ui/quickhelpbox.ui \
ui/aboutdialog.ui
ui/aboutdialog.ui \
ui/gridfontsizedialog.ui
210 changes: 125 additions & 85 deletions SPIERSview/src/drawglscalegrid.cpp

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions SPIERSview/src/drawglscalegrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ class DrawGLScaleGrid

private:
int numOccVertices;
int currentFontScale;

// We need a set of these for each of the 6 font sizes available
GLfloat CharacterWidths[7][15] ; //widths of these characters
GLfloat CharacterLineCounts[7][15] ; //widths of these characters
QOpenGLBuffer VBOcharacters[7][15] ; //0-9 are digits 0-9, 10 is -, 11 is ., 12 is m, 13 is u, 14 = c

GLfloat CharacterWidths[15]; //widths of these characters
GLfloat CharacterLineCounts[15]; //widths of these characters
QOpenGLBuffer VBOcharacters[15]; //0-9 are digits 0-9, 10 is -, 11 is ., 12 is m, 13 is u
QOpenGLBuffer VBOline;
QOpenGLBuffer occBuffer;
QMatrix4x4 scaleMatrix; //Manipulations to scale ball
Expand Down
6 changes: 6 additions & 0 deletions SPIERSview/src/gl3widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ void GlWidget::DrawObjects(bool rightview, bool halfsize)
glfunctions->glDisable(GL_BLEND);
}
for (int i = 0; i < SVObjects.count(); i++)
{

// We must have a file load by this point so set the global to true.
isFileLoaded = true;

if (!(SVObjects[i]->IsGroup))
if (CanISee(i))
{
Expand Down Expand Up @@ -313,6 +318,7 @@ void GlWidget::DrawObjects(bool rightview, bool halfsize)
useshader->release();
}
}
}
}
glfunctions->glDepthMask(true);

Expand Down
4 changes: 4 additions & 0 deletions SPIERSview/src/globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ bool containsPresurfaced = false;
bool containsNonPresurfaced = false;
bool isFirstObject;
bool isVaxmlMode;
bool showScaleGrid = false;
bool showMinorGridValues = false;
bool showMinorGridLines = true;
bool isFileLoaded = false;

double applicationScaleX;
double applicationScaleY;
Expand Down Expand Up @@ -47,6 +50,7 @@ int modelKTr;
int nextActualDlist = 1;
int totalTriangles = 0;
int scaleBallColour[3]; //info stuff
int fontSizeGrid = 3;

QList<QScreen *> availableScreens;
QOpenGLBuffer cubeBuffer;
Expand Down
7 changes: 6 additions & 1 deletion SPIERSview/src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ class MainWindow;
#define SENSITIVITY 5
#define SPINTIMERINTERVAL 10
#define SPINRATE .02
#define SPVFILEVERSION 10
#define SPVFILEVERSION 11
#define GL_MAJOR 2
#define GL_MINOR 1
#define STEREO_SEPARATION_MODIFIER 15.0
#define SHININESS 0.0
#define FONT_SCALE_FACTOR 24.0 // Eqates to roughtly the same font size as the default used by the QT GUI

// SPIERSview extrerns
extern MainWindow *mainWindow;
Expand All @@ -54,7 +55,10 @@ extern bool containsPresurfaced;
extern bool containsNonPresurfaced;
extern bool isVaxmlMode;
extern bool isFirstObject;
extern bool showScaleGrid;
extern bool showMinorGridValues;
extern bool showMinorGridLines;
extern bool isFileLoaded;

extern double applicationScaleX;
extern double applicationScaleY;
Expand Down Expand Up @@ -91,6 +95,7 @@ extern int colorGridMinorGreen;
extern int colorGridMinorBlue;
extern int scaleBallColour[3];
extern int modelKTr;
extern int fontSizeGrid;

extern QList<QScreen *> availableScreens;
extern QMatrix4x4 globalMatrix;
Expand Down
41 changes: 41 additions & 0 deletions SPIERSview/src/gridfontsizedialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "gridfontsizedialog.h"
#include "ui_gridfontsizedialog.h"

/**
* @brief GridFontSizeDialog::GridFontSizeDialog
* @param parent
*/
GridFontSizeDialog::GridFontSizeDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::GridFontSizeDialog)
{
ui->setupUi(this);

ui->comboBox->setCurrentIndex(fontSizeGrid);
}

/**
* @brief GridFontSizeDialog::~GridFontSizeDialog
*/
GridFontSizeDialog::~GridFontSizeDialog()
{
delete ui;
}

/**
* @brief GridFontSizeDialog::on_buttonBox_accepted
*/
void GridFontSizeDialog::on_buttonBox_accepted()
{
fontSizeGrid = ui->comboBox->currentIndex();

mainWindow->UpdateGL();
}

/**
* @brief GridFontSizeDialog::on_buttonBox_rejected
*/
void GridFontSizeDialog::on_buttonBox_rejected()
{
return;
}
28 changes: 28 additions & 0 deletions SPIERSview/src/gridfontsizedialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef GRIDFONTSIZEDIALOG_H
#define GRIDFONTSIZEDIALOG_H

#include <QDialog>
#include "mainwindow.h"

namespace Ui {
class GridFontSizeDialog;
}

class GridFontSizeDialog : public QDialog
{
Q_OBJECT

public:
explicit GridFontSizeDialog(QWidget *parent = nullptr);
~GridFontSizeDialog();

private slots:
void on_buttonBox_accepted();

void on_buttonBox_rejected();

private:
Ui::GridFontSizeDialog *ui;
};

#endif // GRIDFONTSIZEDIALOG_H
144 changes: 113 additions & 31 deletions SPIERSview/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "../SPIERScommon/src/netmodule.h"
#include <vtkProperty2D.h>
#include "movetogroup.h"
#include "gridfontsizedialog.h"

/**
* @brief MainWindow::MainWindow
Expand Down Expand Up @@ -425,39 +426,56 @@ void MainWindow::SpinTimer_fired()
Framenumbs.append(millisecs);
if (Framenumbs.count() > 10)
{
double tot = 0;
for (int i = 0; i < 10; i++)
{
tot += static_cast<double>(Framenumbs[i]);
}
tot /= 10; //tot is average ms
tot += 1;
int framerate = static_cast<int>(1000.0 / tot);
QString message;
QTextStream string(&message);

QString XrotS = DegConvert(rotationX);
QString YrotS = DegConvert(rotationY);
QString ZrotS = DegConvert(rotationZ);
// If there is a model loaded in the GL widget...
if (isFileLoaded)
{
double tot = 0;
for (int i = 0; i < 10; i++)
{
tot += static_cast<double>(Framenumbs[i]);
}
tot /= 10; //tot is average ms
tot += 1;
int framerate = static_cast<int>(1000.0 / tot);

QString XtransS = TransConvert(transformX);
QString YtransS = TransConvert(transformY);
QString ZtransS = TransConvert(transformZ);

string << "Frame rate: " << framerate;
string << " Rotations: X = " << XrotS;
string << " Y = " << YrotS;
string << " Z = " << ZrotS;
string << " Translations: X = " << XtransS;
string << " Y = " << YtransS;
string << " Z = " << ZtransS;
string << " FOV: " << gl3widget->getFOV() << "mm";
QString XrotS = DegConvert(rotationX);
QString YrotS = DegConvert(rotationY);
QString ZrotS = DegConvert(rotationZ);

QString XtransS = TransConvert(transformX);
QString YtransS = TransConvert(transformY);
QString ZtransS = TransConvert(transformZ);

string << "Frame rate: " << framerate;
string << " Rotations: X = " << XrotS;
string << " Y = " << YrotS;
string << " Z = " << ZrotS;
string << " Translations: X = " << XtransS;
string << " Y = " << YtransS;
string << " Z = " << ZtransS;
string << " FOV: " << gl3widget->getFOV() << "mm";
}
else
{
string << "Frame rate: 0";
string << " Rotations: X = 000.0";
string << " Y = 000.0";
string << " Z = 000.0" ;
string << " Translations: X = 00.0";
string << " Y = 00.0";
string << " Z = 00.0";
string << " FOV: 0.0mm";
}

ui->statusBar->showMessage(message);//should be m
Framenumbs.clear();
}

//also a good place to recalc the width of output
// Also a good place to recalc the width of output
int wheight = gl3widget->height();
int wwidth = gl3widget->width();

Expand Down Expand Up @@ -527,14 +545,6 @@ void MainWindow::SpinTimer_fired()
ktrlabel->setText(mess);
}

/**
* @brief MainWindow::on_actionShow_Scale_Grid_triggered
*/
void MainWindow::on_actionShow_Scale_Grid_triggered()
{
UpdateGL();
}

/**
* @brief MainWindow::on_ClipStart_valueChanged
* @param clip
Expand Down Expand Up @@ -3972,6 +3982,23 @@ void MainWindow::on_actionFull_Screen_triggered()
}
}

/**
* @brief MainWindow::on_actionShow_Scale_Grid_triggered
*/
void MainWindow::on_actionShow_Scale_Grid_triggered()
{
if (ui->actionShow_Scale_Grid->isChecked())
{
showScaleGrid = true;
}
else
{
showScaleGrid = false;
}

UpdateGL();
}

/**
* @brief MainWindow::on_actionShow_Minor_Values_triggered
*/
Expand All @@ -3988,3 +4015,58 @@ void MainWindow::on_actionShow_Minor_Values_triggered()

UpdateGL();
}

/**
* @brief MainWindow::on_actionScale_Grid_Font_Size_triggered
*/
void MainWindow::on_actionScale_Grid_Font_Size_triggered()
{
GridFontSizeDialog gridFontSizeDialog;
FilterKeys = false;
gridFontSizeDialog.exec();
FilterKeys = true;
}

/**
* @brief MainWindow::on_actionShow_Minor_Scale_Lines_triggered
*/
void MainWindow::on_actionShow_Minor_Scale_Lines_triggered()
{
if (ui->actionShow_Minor_Scale_Lines->isChecked())
{
showMinorGridLines = true;
}
else
{
showMinorGridLines = false;
}

UpdateGL();
}

/**
* @brief MainWindow::on_actionReset_Scale_Grid_to_Defaults_triggered
*/
void MainWindow::on_actionReset_Scale_Grid_to_Defaults_triggered()
{
// Reset minor gridline values show status
ui->actionShow_Minor_Values->setChecked(false);
showMinorGridValues = false;

// Reset minor gridline show status
ui->actionShow_Minor_Scale_Lines->setChecked(true);
showMinorGridLines = true;

// Reset gridline colors
colorGridRed = 255;
colorGridGreen = 255;
colorGridBlue = 255;
colorGridMinorRed = 168;
colorGridMinorGreen = 181;
colorGridMinorBlue = 212;

// Reset grid font size
fontSizeGrid = 3;

UpdateGL();
}

0 comments on commit 3fd02ce

Please sign in to comment.