Skip to content

Commit

Permalink
More color adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Denvi committed Sep 20, 2015
1 parent 1af088b commit 7b587b3
Show file tree
Hide file tree
Showing 12 changed files with 299 additions and 144 deletions.
5 changes: 5 additions & 0 deletions frmmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,8 @@ void frmMain::applySettings() {
ui->glwVisualizer->setMsaa(m_frmSettings.msaa());
ui->glwVisualizer->setZBuffer(m_frmSettings.zBuffer());
ui->glwVisualizer->setFps(m_frmSettings.fps());
ui->glwVisualizer->setColorBackground(m_frmSettings.colors("VisualizerBackground"));
ui->glwVisualizer->setColorText(m_frmSettings.colors("VisualizerText"));

ui->txtSpindleSpeed->setMinimum(m_frmSettings.spindleSpeedMin());
ui->txtSpindleSpeed->setMaximum(m_frmSettings.spindleSpeedMax());
Expand All @@ -1556,6 +1558,9 @@ void frmMain::applySettings() {
m_codeDrawer->setColorDrawn(m_frmSettings.colors("ToolpathDrawn"));
m_codeDrawer->setColorHighlight(m_frmSettings.colors("ToolpathHighlight"));
m_codeDrawer->setColorZMovement(m_frmSettings.colors("ToolpathZMovement"));
m_codeDrawer->setColorStart(m_frmSettings.colors("ToolpathStart"));
m_codeDrawer->setColorEnd(m_frmSettings.colors("ToolpathEnd"));

m_codeDrawer->update();
}

Expand Down
32 changes: 16 additions & 16 deletions frmmain.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2725,22 +2725,6 @@ QDoubleSpinBox:focus {
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>StyledToolButton</class>
<extends>QToolButton</extends>
<header>styledtoolbutton.h</header>
</customwidget>
<customwidget>
<class>GLWidget</class>
<extends>QWidget</extends>
<header>glwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ComboBox</class>
<extends>QComboBox</extends>
<header>combobox.h</header>
</customwidget>
<customwidget>
<class>ScrollArea</class>
<extends>QScrollArea</extends>
Expand All @@ -2759,6 +2743,22 @@ QDoubleSpinBox:focus {
<header>groupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>StyledToolButton</class>
<extends>QToolButton</extends>
<header>styledtoolbutton.h</header>
</customwidget>
<customwidget>
<class>GLWidget</class>
<extends>QWidget</extends>
<header>glwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ComboBox</class>
<extends>QComboBox</extends>
<header>combobox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>cmdTop</tabstop>
Expand Down
6 changes: 6 additions & 0 deletions frmsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,14 @@ void frmSettings::on_cmdDefaults_clicked()
setPanelSpindle(true);

ui->clpTool->setColor(QColor(255, 153, 0));

ui->clpVisualizerBackground->setColor(QColor(255, 255, 255));
ui->clpVisualizerText->setColor(QColor(0, 0, 0));

ui->clpToolpathNormal->setColor(QColor(0, 0, 0));
ui->clpToolpathDrawn->setColor(QColor(217, 217, 217));
ui->clpToolpathHighlight->setColor(QColor(145, 130, 230));
ui->clpToolpathZMovement->setColor(QColor(255, 0, 0));
ui->clpToolpathStart->setColor(QColor(255, 0, 0));
ui->clpToolpathEnd->setColor(QColor(0, 255, 0));
}
89 changes: 68 additions & 21 deletions frmsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ QScrollArea QScrollBar::sub-line:vertical {
<property name="geometry">
<rect>
<x>0</x>
<y>-486</y>
<y>-528</y>
<width>344</width>
<height>923</height>
<height>986</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
Expand Down Expand Up @@ -951,62 +951,109 @@ padding-top: 3;</string>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QGridLayout" name="gridLayout_6" columnstretch="0,0,0,0">
<item row="2" column="0">
<item row="6" column="2">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Z-movement:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_23">
<property name="text">
<string>Normal:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Toolpath</string>
</property>
</widget>
</item>
<item row="2" column="2">
<item row="5" column="2">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Drawn:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="ColorPicker" name="clpTool" native="true"/>
<item row="6" column="3">
<widget class="ColorPicker" name="clpToolpathZMovement" native="true"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_19">
<item row="2" column="0">
<widget class="QLabel" name="label_24">
<property name="text">
<string>Tool:</string>
<string>Background:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="5" column="3">
<widget class="ColorPicker" name="clpToolpathDrawn" native="true"/>
</item>
<item row="6" column="1">
<widget class="ColorPicker" name="clpToolpathHighlight" native="true"/>
</item>
<item row="5" column="1">
<widget class="ColorPicker" name="clpToolpathNormal" native="true"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_25">
<property name="text">
<string>Highlight:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="ColorPicker" name="clpToolpathNormal" native="true"/>
<item row="7" column="0">
<widget class="QLabel" name="label_26">
<property name="text">
<string>Start point:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="ColorPicker" name="clpToolpathHighlight" native="true"/>
<item row="7" column="1">
<widget class="ColorPicker" name="clpToolpathStart" native="true"/>
</item>
<item row="7" column="2">
<widget class="QLabel" name="label_27">
<property name="text">
<string>End point:</string>
</property>
</widget>
</item>
<item row="7" column="3">
<widget class="ColorPicker" name="clpToolpathEnd" native="true"/>
</item>
<item row="2" column="1">
<widget class="ColorPicker" name="clpVisualizerBackground" native="true"/>
</item>
<item row="2" column="3">
<widget class="ColorPicker" name="clpToolpathDrawn" native="true"/>
<widget class="ColorPicker" name="clpVisualizerText" native="true"/>
</item>
<item row="3" column="2">
<widget class="QLabel" name="label_20">
<item row="1" column="0">
<widget class="QLabel" name="label_22">
<property name="text">
<string>Z-movement:</string>
<string>Visualizer</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="ColorPicker" name="clpToolpathZMovement" native="true"/>
<item row="2" column="2">
<widget class="QLabel" name="label_28">
<property name="text">
<string>Text:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Tool:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="ColorPicker" name="clpTool" native="true"/>
</item>
</layout>
</item>
Expand Down
24 changes: 22 additions & 2 deletions gcodedrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool GcodeDrawer::updateData()
if (std::isnan(list->at(i)->getEnd().x()) || std::isnan(list->at(i)->getEnd().y())) continue;

// Draw first toolpath point
vertex.color = /*list->at(i)->drawn() ? QVector3D(0.85, 0.85, 0.85) : */QVector3D(1.0, 0.0, 0.0);
vertex.color = Util::colorToVector(m_colorStart);
vertex.position = list->at(i)->getEnd();
vertex.start = QVector3D(sNan, sNan, sNan);
m_points.append(vertex);
Expand Down Expand Up @@ -99,7 +99,7 @@ bool GcodeDrawer::updateData()

// Draw last toolpath point
if (i == list->count() - 1) {
vertex.color = /*list->at(i)->drawn() ? QVector3D(0.85, 0.85, 0.85) : */QVector3D(0.0, 1.0, 0.0);
vertex.color = Util::colorToVector(m_colorEnd);
vertex.position = list->at(i)->getEnd();
vertex.start = QVector3D(sNan, sNan, sNan);
m_points.append(vertex);
Expand Down Expand Up @@ -251,6 +251,26 @@ void GcodeDrawer::setColorDrawn(const QColor &colorDrawn)
{
m_colorDrawn = colorDrawn;
}
QColor GcodeDrawer::colorStart() const
{
return m_colorStart;
}

void GcodeDrawer::setColorStart(const QColor &colorStart)
{
m_colorStart = colorStart;
}
QColor GcodeDrawer::colorEnd() const
{
return m_colorEnd;
}

void GcodeDrawer::setColorEnd(const QColor &colorEnd)
{
m_colorEnd = colorEnd;
}





Expand Down
8 changes: 8 additions & 0 deletions gcodedrawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ class GcodeDrawer : public ShaderDrawable
QColor colorDrawn() const;
void setColorDrawn(const QColor &colorDrawn);

QColor colorStart() const;
void setColorStart(const QColor &colorStart);

QColor colorEnd() const;
void setColorEnd(const QColor &colorEnd);

signals:

public slots:
Expand All @@ -60,6 +66,8 @@ public slots:
QColor m_colorDrawn;
QColor m_colorHighlight;
QColor m_colorZMovement;
QColor m_colorStart;
QColor m_colorEnd;

QList<int> m_indexes;

Expand Down
33 changes: 27 additions & 6 deletions glwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,26 @@ void GLWidget::beginViewAnimation() {
void GLWidget::stopViewAnimation() {
m_animateView = false;
}
QColor GLWidget::colorText() const
{
return m_colorText;
}

void GLWidget::setColorText(const QColor &colorText)
{
m_colorText = colorText;
}

QColor GLWidget::colorBackground() const
{
return m_colorBackground;
}

void GLWidget::setColorBackground(const QColor &colorBackground)
{
m_colorBackground = colorBackground;
}


void GLWidget::setFps(int fps)
{
Expand Down Expand Up @@ -307,14 +327,12 @@ void GLWidget::initializeGL()

if (m_shaderProgram) {
// Compile vertex shader
qDebug() << m_shaderProgram->addShaderFromSourceFile(QOpenGLShader::Vertex, ":/shaders/vshader.glsl");
m_shaderProgram->addShaderFromSourceFile(QOpenGLShader::Vertex, ":/shaders/vshader.glsl");
// Compile fragment shader
qDebug() << m_shaderProgram->addShaderFromSourceFile(QOpenGLShader::Fragment, ":/shaders/fshader.glsl");
m_shaderProgram->addShaderFromSourceFile(QOpenGLShader::Fragment, ":/shaders/fshader.glsl");
// Link shader pipeline
qDebug() << m_shaderProgram->link();
m_shaderProgram->link();
qDebug() << "shader program created";
} else {
qDebug() << "error creating shader program";
}
}

Expand Down Expand Up @@ -370,7 +388,7 @@ void GLWidget::paintEvent(QPaintEvent *pe)
painter.beginNativePainting();

// Clear viewport
glClearColor(1.0, 1.0, 1.0, 1);
glClearColor(m_colorBackground.redF(), m_colorBackground.greenF(), m_colorBackground.blueF(), 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// Update settings
Expand Down Expand Up @@ -418,6 +436,9 @@ void GLWidget::paintEvent(QPaintEvent *pe)

painter.endNativePainting();

QPen pen(m_colorText);
painter.setPen(pen);

double x = 10;
double y = this->height() - 60;

Expand Down
10 changes: 9 additions & 1 deletion glwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ class GLWidget : public QGLWidget
bool msaa() const;
void setMsaa(bool msaa);

QColor colorBackground() const;
void setColorBackground(const QColor &colorBackground);

QColor colorText() const;
void setColorText(const QColor &colorText);

signals:
void rotationChanged();
void resized();
Expand Down Expand Up @@ -90,7 +96,6 @@ private slots:
int m_animationFrame;
QTime m_spendTime;
QTime m_estimatedTime;
// QTimer m_changeViewTimer;
QBasicTimer m_timerAnimation;
double m_xRotTarget, m_yRotTarget;
double m_xRotStored, m_yRotStored;
Expand All @@ -109,6 +114,9 @@ private slots:
QMatrix4x4 m_projectionMatrix;
QMatrix4x4 m_viewMatrix;

QColor m_colorBackground;
QColor m_colorText;

protected:
void initializeGL();
void resizeGL(int width, int height);
Expand Down
2 changes: 0 additions & 2 deletions shaderdrawable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include <GLES/gl.h>
#endif

#include <QTime>

ShaderDrawable::ShaderDrawable()
{
m_needsUpdateGeometry = true;
Expand Down
Binary file modified translations/grblControl_ru.qm
Binary file not shown.
Loading

0 comments on commit 7b587b3

Please sign in to comment.