This commit is contained in:
Sergiusz Bazanski 2018-07-13 11:38:49 +01:00
parent b5498c8a53
commit 309a533b7c
2 changed files with 35 additions and 51 deletions

View File

@ -242,22 +242,13 @@ void LineShader::draw(const LineShaderData &line, const QMatrix4x4 &projection)
FPGAViewWidget::FPGAViewWidget(QWidget *parent) : QOpenGLWidget(parent), lineShader_(this), zoom_(500.f), ctx_(nullptr) FPGAViewWidget::FPGAViewWidget(QWidget *parent) : QOpenGLWidget(parent), lineShader_(this), zoom_(500.f), ctx_(nullptr)
{ {
/* backgroundColor_ = QColor("#000000");
backgroundColor = QColor("#ffffff"); gridColor_ = QColor("#333");
gridColor = QColor("#ddd"); gFrameColor_ = QColor("#d0d0d0");
gFrameColor = QColor("#303030"); gHiddenColor_ = QColor("#606060");
gHiddenColor = QColor("#a0a0a0"); gInactiveColor_ = QColor("#303030");
gInactiveColor = QColor("#d0d0d0"); gActiveColor_ = QColor("#f0f0f0");
gActiveColor = QColor("#101010"); frameColor_ = QColor("#0066ba");
frameColor = QColor("#0066ba");
*/
backgroundColor = QColor("#000000");
gridColor = QColor("#333");
gFrameColor = QColor("#d0d0d0");
gHiddenColor = QColor("#606060");
gInactiveColor = QColor("#303030");
gActiveColor = QColor("#f0f0f0");
frameColor = QColor("#0066ba");
auto fmt = format(); auto fmt = format();
fmt.setMajorVersion(3); fmt.setMajorVersion(3);
@ -293,7 +284,7 @@ void FPGAViewWidget::initializeGL()
log_error("Could not compile shader.\n"); log_error("Could not compile shader.\n");
} }
initializeOpenGLFunctions(); initializeOpenGLFunctions();
glClearColor(backgroundColor.red() / 255, backgroundColor.green() / 255, backgroundColor.blue() / 255, 0.0); glClearColor(backgroundColor_.red() / 255, backgroundColor_.green() / 255, backgroundColor_.blue() / 255, 0.0);
} }
void FPGAViewWidget::drawDecal(LineShaderData &out, const DecalXY &decal) void FPGAViewWidget::drawDecal(LineShaderData &out, const DecalXY &decal)
@ -338,15 +329,11 @@ void FPGAViewWidget::drawDecal(LineShaderData out[], const DecalXY &decal)
line.point(offsetX + scale * el.x1, offsetY + scale * el.y2); line.point(offsetX + scale * el.x1, offsetY + scale * el.y2);
switch (el.style) { switch (el.style) {
case GraphicElement::G_FRAME: case GraphicElement::G_FRAME:
line.build(out[0]);
break;
case GraphicElement::G_HIDDEN:
break;
case GraphicElement::G_INACTIVE: case GraphicElement::G_INACTIVE:
line.build(out[2]);
break;
case GraphicElement::G_ACTIVE: case GraphicElement::G_ACTIVE:
line.build(out[3]); line.build(out[el.style]);
break;
default:
break; break;
} }
} }
@ -356,15 +343,11 @@ void FPGAViewWidget::drawDecal(LineShaderData out[], const DecalXY &decal)
offsetY + scale * el.y2); offsetY + scale * el.y2);
switch (el.style) { switch (el.style) {
case GraphicElement::G_FRAME: case GraphicElement::G_FRAME:
line.build(out[0]);
break;
case GraphicElement::G_HIDDEN:
break;
case GraphicElement::G_INACTIVE: case GraphicElement::G_INACTIVE:
line.build(out[2]);
break;
case GraphicElement::G_ACTIVE: case GraphicElement::G_ACTIVE:
line.build(out[3]); line.build(out[el.style]);
break;
default:
break; break;
} }
} }
@ -397,17 +380,17 @@ void FPGAViewWidget::paintGL()
float thick11Px = mouseToWorldCoordinates(1.1, 0).x(); float thick11Px = mouseToWorldCoordinates(1.1, 0).x();
// Draw grid. // Draw grid.
auto grid = LineShaderData(thick1Px, gridColor); auto grid = LineShaderData(thick1Px, gridColor_);
for (float i = -100.0f; i < 100.0f; i += 1.0f) { for (float i = -100.0f; i < 100.0f; i += 1.0f) {
PolyLine(-100.0f, i, 100.0f, i).build(grid); PolyLine(-100.0f, i, 100.0f, i).build(grid);
PolyLine(i, -100.0f, i, 100.0f).build(grid); PolyLine(i, -100.0f, i, 100.0f).build(grid);
} }
lineShader_.draw(grid, matrix); lineShader_.draw(grid, matrix);
LineShaderData shaders[4] = {LineShaderData(thick11Px, gFrameColor), // GraphicElement::G_FRAME LineShaderData shaders[4] = {[GraphicElement::G_FRAME] = LineShaderData(thick11Px, gFrameColor_),
LineShaderData(thick11Px, gHiddenColor), // GraphicElement::G_HIDDEN [GraphicElement::G_HIDDEN] = LineShaderData(thick11Px, gHiddenColor_),
LineShaderData(thick11Px, gInactiveColor), // GraphicElement::G_INACTIVE [GraphicElement::G_INACTIVE] = LineShaderData(thick11Px, gInactiveColor_),
LineShaderData(thick11Px, gActiveColor)}; // GraphicElement::G_ACTIVE [GraphicElement::G_ACTIVE] = LineShaderData(thick11Px, gActiveColor_)};
if (ctx_) { if (ctx_) {
// Draw Bels. // Draw Bels.
@ -433,7 +416,7 @@ void FPGAViewWidget::paintGL()
lineShader_.draw(shaders[3], matrix); lineShader_.draw(shaders[3], matrix);
// Draw Frame Graphics. // Draw Frame Graphics.
auto frames = LineShaderData(thick11Px, frameColor); auto frames = LineShaderData(thick11Px, frameColor_);
if (ctx_) { if (ctx_) {
drawDecal(frames, ctx_->getFrameDecal()); drawDecal(frames, ctx_->getFrameDecal());
lineShader_.draw(frames, matrix); lineShader_.draw(frames, matrix);

View File

@ -216,13 +216,13 @@ class LineShader
class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QColor backgroundColor MEMBER backgroundColor DESIGNABLE true) Q_PROPERTY(QColor backgroundColor MEMBER backgroundColor_ DESIGNABLE true)
Q_PROPERTY(QColor gridColor MEMBER gridColor DESIGNABLE true) Q_PROPERTY(QColor gridColor MEMBER gridColor_ DESIGNABLE true)
Q_PROPERTY(QColor gFrameColor MEMBER gFrameColor DESIGNABLE true) Q_PROPERTY(QColor gFrameColor MEMBER gFrameColor_ DESIGNABLE true)
Q_PROPERTY(QColor gHiddenColor MEMBER gHiddenColor DESIGNABLE true) Q_PROPERTY(QColor gHiddenColor MEMBER gHiddenColor_ DESIGNABLE true)
Q_PROPERTY(QColor gInactiveColor MEMBER gInactiveColor DESIGNABLE true) Q_PROPERTY(QColor gInactiveColor MEMBER gInactiveColor_ DESIGNABLE true)
Q_PROPERTY(QColor gActiveColor MEMBER gActiveColor DESIGNABLE true) Q_PROPERTY(QColor gActiveColor MEMBER gActiveColor_ DESIGNABLE true)
Q_PROPERTY(QColor frameColor MEMBER frameColor DESIGNABLE true) Q_PROPERTY(QColor frameColor MEMBER frameColor_ DESIGNABLE true)
public: public:
FPGAViewWidget(QWidget *parent = 0); FPGAViewWidget(QWidget *parent = 0);
@ -266,13 +266,14 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
const float zoomLvl2_ = 50.0f; const float zoomLvl2_ = 50.0f;
Context *ctx_; Context *ctx_;
QColor backgroundColor;
QColor gridColor; QColor backgroundColor_;
QColor gFrameColor; QColor gridColor_;
QColor gHiddenColor; QColor gFrameColor_;
QColor gInactiveColor; QColor gHiddenColor_;
QColor gActiveColor; QColor gInactiveColor_;
QColor frameColor; QColor gActiveColor_;
QColor frameColor_;
}; };
NEXTPNR_NAMESPACE_END NEXTPNR_NAMESPACE_END