Grids and Overlays (#193)

* start

* It works.

* Updates and feedback

* Fix vanishing guides in place
This commit is contained in:
Jeremy Bullock 2020-09-22 21:03:49 -06:00 committed by GitHub
parent f91ab502b1
commit d8756f4eae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 638 additions and 89 deletions

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="9px" height="18px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g transform="matrix(-1.05195,1.28827e-16,-1.03831e-16,-0.847845,6.99021,15.3123)">
<g id="path8">
<path d="M2.367,3.907L5.694,9.804L-0.96,9.804L2.367,3.907Z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 636 B

View file

@ -2173,7 +2173,7 @@ void MainWindow::defineActions() {
ViewCameraToggleAction ? 1 : 0, MenuViewCommandType); ViewCameraToggleAction ? 1 : 0, MenuViewCommandType);
createToggle(MI_ViewTable, tr("&Table"), "", ViewTableToggleAction ? 1 : 0, createToggle(MI_ViewTable, tr("&Table"), "", ViewTableToggleAction ? 1 : 0,
MenuViewCommandType); MenuViewCommandType);
createToggle(MI_FieldGuide, tr("&Field Guide"), "Shift+G", createToggle(MI_FieldGuide, tr("&Grids and Overlays"), "Shift+G",
FieldGuideToggleAction ? 1 : 0, MenuViewCommandType); FieldGuideToggleAction ? 1 : 0, MenuViewCommandType);
createToggle(MI_ViewBBox, tr("&Raster Bounding Box"), "", createToggle(MI_ViewBBox, tr("&Raster Bounding Box"), "",
ViewBBoxToggleAction ? 1 : 0, MenuViewCommandType); ViewBBoxToggleAction ? 1 : 0, MenuViewCommandType);
@ -3681,9 +3681,10 @@ void MainWindow::makeTransparencyDialog() {
m_transparencySlider->setRange(-100, -30); m_transparencySlider->setRange(-100, -30);
m_transparencySlider->setValue(TransparencySliderValue * -1); m_transparencySlider->setValue(TransparencySliderValue * -1);
m_transparencySlider->setOrientation(Qt::Horizontal); m_transparencySlider->setOrientation(Qt::Horizontal);
connect(m_transparencySlider, &QSlider::valueChanged, connect(m_transparencySlider, &QSlider::valueChanged, [=](int value) {
[=](int value) { TransparencySliderValue = value * -1; TransparencySliderValue = value * -1;
toggleTransparency(true); }); toggleTransparency(true);
});
QVBoxLayout *togglerLayout = new QVBoxLayout(this); QVBoxLayout *togglerLayout = new QVBoxLayout(this);
QHBoxLayout *togglerSliderLayout = new QHBoxLayout(this); QHBoxLayout *togglerSliderLayout = new QHBoxLayout(this);

View file

@ -34,9 +34,30 @@
#include <QDialog> #include <QDialog>
#include <QLineEdit> #include <QLineEdit>
#include <QWidgetAction> #include <QWidgetAction>
#include <QLabel>
#include <QCheckBox>
#include <QGroupBox>
extern TEnv::StringVar EnvSafeAreaName; extern TEnv::StringVar EnvSafeAreaName;
extern TEnv::IntVar CameraViewTransparency; extern TEnv::IntVar CameraViewTransparency;
extern TEnv::IntVar IsometricLeftAngle;
extern TEnv::IntVar IsometricRightAngle;
extern TEnv::IntVar IsometricLeftStep;
extern TEnv::IntVar IsometricRightStep;
extern TEnv::IntVar ShowRuleOfThirds;
extern TEnv::IntVar ShowGoldenRatio;
extern TEnv::IntVar ShowIsometricGrid;
extern TEnv::IntVar ShowHorizontalGrid;
extern TEnv::IntVar ShowVerticalGrid;
extern TEnv::IntVar VerticalSpacing;
extern TEnv::IntVar HorizontalSpacing;
extern TEnv::IntVar ShowFieldGuide;
extern TEnv::IntVar GuideOpacity;
extern TEnv::IntVar HorizontalOffset;
extern TEnv::IntVar VerticalOffset;
//============================================================================= //=============================================================================
// TPanel // TPanel
@ -376,9 +397,10 @@ void TPanelTitleBarButtonForSafeArea::onSetSafeArea() {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void TPanelTitleBarButtonForCameraView::contextMenuEvent(QContextMenuEvent *e) { TPanelTitleBarButtonForCameraView::TPanelTitleBarButtonForCameraView(QWidget* parent,
QMenu menu(this); const QString& standardPixmapName)
: TPanelTitleBarButton(parent, standardPixmapName) {
m_menu = new QMenu(this);
QWidgetAction* sliderAction = new QWidgetAction(this); QWidgetAction* sliderAction = new QWidgetAction(this);
QSlider* transparencySlider = new QSlider(this); QSlider* transparencySlider = new QSlider(this);
transparencySlider->setRange(20, 100); transparencySlider->setRange(20, 100);
@ -389,12 +411,251 @@ void TPanelTitleBarButtonForCameraView::contextMenuEvent(QContextMenuEvent *e) {
emit updateViewer(); emit updateViewer();
}); });
sliderAction->setDefaultWidget(transparencySlider); sliderAction->setDefaultWidget(transparencySlider);
menu.addAction(sliderAction); m_menu->addAction(sliderAction);
menu.exec(e->globalPos());
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void TPanelTitleBarButtonForCameraView::mousePressEvent(QMouseEvent* e) {
m_menu->exec(e->globalPos() + QPoint(-20, 10));
}
//-----------------------------------------------------------------------------
TPanelTitleBarButtonForGrids::TPanelTitleBarButtonForGrids(QWidget* parent,
const QString& standardPixmapName)
: TPanelTitleBarButton(parent, standardPixmapName) {
m_menu = new QMenu(this);
QWidgetAction* gridsAction = new QWidgetAction(this);
QWidget* gridWidget = new QWidget(this);
QGridLayout* gridLayout = new QGridLayout(this);
QCheckBox* thirdsCheckbox = new QCheckBox(tr("Rule of Thirds"), this);
thirdsCheckbox->setChecked(ShowRuleOfThirds != 0);
connect(thirdsCheckbox, &QCheckBox::stateChanged, [=](int value) {
ShowRuleOfThirds = value > 0 ? 1 : 0;
emit updateViewer();
});
QCheckBox* goldenRationCheckbox = new QCheckBox(tr("Golden Ratio"), this);
goldenRationCheckbox->setChecked(ShowGoldenRatio != 0);
connect(goldenRationCheckbox, &QCheckBox::stateChanged, [=](int value) {
ShowGoldenRatio = value > 0 ? 1 : 0;
emit updateViewer();
});
QCheckBox* fieldGuideCheckbox = new QCheckBox(tr("Field Guide"), this);
fieldGuideCheckbox->setChecked(ShowFieldGuide != 0);
connect(fieldGuideCheckbox, &QCheckBox::stateChanged, [=](int value) {
ShowFieldGuide = value > 0 ? 1 : 0;
emit updateViewer();
});
QGroupBox* horizontalCheckbox = new QGroupBox(tr("Horizontal Grid"), this);
horizontalCheckbox->setCheckable(true);
horizontalCheckbox->setChecked(ShowHorizontalGrid != 0);
connect(horizontalCheckbox, &QGroupBox::toggled, [=](bool value) {
ShowHorizontalGrid = value == true ? 1 : 0;
emit updateViewer();
});
QSlider* horizontalSpacingSlider = new QSlider(this);
horizontalSpacingSlider->setRange(10, 250);
horizontalSpacingSlider->setValue(HorizontalSpacing);
horizontalSpacingSlider->setOrientation(Qt::Horizontal);
QLabel* horizontalSpacingLabel = new QLabel(this);
horizontalSpacingLabel->setText(tr("Spacing: ") +
QString::number(HorizontalSpacing));
connect(horizontalSpacingSlider, &QSlider::valueChanged, [=](int value) {
HorizontalSpacing = value;
horizontalSpacingLabel->setText(tr("Spacing: ") +
QString::number(HorizontalSpacing));
emit updateViewer();
});
QSlider* horizontalOffsetSlider = new QSlider(this);
horizontalOffsetSlider->setRange(-100, 100);
horizontalOffsetSlider->setValue(HorizontalOffset);
horizontalOffsetSlider->setOrientation(Qt::Horizontal);
QLabel* horizontalOffsetLabel = new QLabel(this);
horizontalOffsetLabel->setText(tr("Offset: ") +
QString::number(HorizontalOffset));
connect(horizontalOffsetSlider, &QSlider::valueChanged, [=](int value) {
HorizontalOffset = value;
horizontalOffsetLabel->setText(tr("Offset: ") +
QString::number(HorizontalOffset));
emit updateViewer();
});
QGridLayout* horizontalLayout = new QGridLayout(this);
horizontalLayout->addWidget(horizontalSpacingLabel, 0, 0, Qt::AlignRight);
horizontalSpacingLabel->setFixedWidth(110);
horizontalSpacingLabel->setAlignment(Qt::AlignRight);
horizontalLayout->addWidget(horizontalSpacingSlider, 0, 1);
horizontalLayout->addWidget(horizontalOffsetLabel, 1, 0, Qt::AlignRight);
horizontalLayout->addWidget(horizontalOffsetSlider, 1, 1);
horizontalCheckbox->setLayout(horizontalLayout);
QGroupBox* verticalCheckbox = new QGroupBox(tr("Vertical Grid"), this);
verticalCheckbox->setCheckable(true);
verticalCheckbox->setChecked(ShowVerticalGrid != 0);
connect(verticalCheckbox, &QGroupBox::toggled, [=](bool value) {
ShowVerticalGrid = value == true ? 1 : 0;
emit updateViewer();
});
QSlider* verticalSpacingSlider = new QSlider(this);
verticalSpacingSlider->setRange(10, 250);
verticalSpacingSlider->setValue(VerticalSpacing);
verticalSpacingSlider->setOrientation(Qt::Horizontal);
verticalSpacingSlider->setMinimumWidth(300);
QLabel* verticalSpacingLabel = new QLabel(this);
verticalSpacingLabel->setText(tr("Spacing: ") +
QString::number(VerticalSpacing));
connect(verticalSpacingSlider, &QSlider::valueChanged, [=](int value) {
VerticalSpacing = value;
verticalSpacingLabel->setText(tr("Spacing: ") +
QString::number(VerticalSpacing));
emit updateViewer();
});
QSlider* verticalOffsetSlider = new QSlider(this);
verticalOffsetSlider->setRange(-100, 100);
verticalOffsetSlider->setValue(VerticalOffset);
verticalOffsetSlider->setOrientation(Qt::Horizontal);
QLabel* verticalOffsetLabel = new QLabel(this);
verticalOffsetLabel->setText(tr("Offset: ") +
QString::number(VerticalOffset));
connect(verticalOffsetSlider, &QSlider::valueChanged, [=](int value) {
VerticalOffset = value;
verticalOffsetLabel->setText(tr("Offset: ") +
QString::number(VerticalOffset));
emit updateViewer();
});
QGridLayout* verticalLayout = new QGridLayout(this);
verticalLayout->addWidget(verticalSpacingLabel, 0, 0, Qt::AlignRight);
verticalSpacingLabel->setFixedWidth(110);
verticalSpacingLabel->setAlignment(Qt::AlignRight);
verticalLayout->addWidget(verticalSpacingSlider, 0, 1);
verticalLayout->addWidget(verticalOffsetLabel, 1, 0, Qt::AlignRight);
verticalLayout->addWidget(verticalOffsetSlider, 1, 1);
verticalCheckbox->setLayout(verticalLayout);
QGroupBox* isometricCheckbox = new QGroupBox(tr("Isometric Grid"), this);
isometricCheckbox->setCheckable(true);
isometricCheckbox->setChecked(ShowIsometricGrid != 0);
connect(isometricCheckbox, &QGroupBox::toggled, [=](int value) {
ShowIsometricGrid = value == true ? 1 : 0;
emit updateViewer();
});
QSlider* leftAngleSlider = new QSlider(this);
leftAngleSlider->setRange(10, 89);
leftAngleSlider->setValue(IsometricLeftAngle);
leftAngleSlider->setOrientation(Qt::Horizontal);
QLabel* leftAngleLabel = new QLabel(this);
leftAngleLabel->setText(tr("Left Angle: ") +
QString::number(IsometricLeftAngle));
connect(leftAngleSlider, &QSlider::valueChanged, [=](int value) {
IsometricLeftAngle = value;
leftAngleLabel->setText(tr("Left Angle: ") +
QString::number(IsometricLeftAngle));
emit updateViewer();
});
QSlider* rightAngleSlider = new QSlider(this);
rightAngleSlider->setRange(10, 89);
rightAngleSlider->setValue(IsometricRightAngle);
rightAngleSlider->setOrientation(Qt::Horizontal);
QLabel* rightAngleLabel = new QLabel(this);
rightAngleLabel->setText(tr("Right Angle: ") +
QString::number(IsometricRightAngle));
connect(rightAngleSlider, &QSlider::valueChanged, [=](int value) {
IsometricRightAngle = value;
rightAngleLabel->setText(tr("Right Angle: ") +
QString::number(IsometricRightAngle));
emit updateViewer();
});
QSlider* leftStepSlider = new QSlider(this);
leftStepSlider->setRange(1, 100);
leftStepSlider->setValue(IsometricLeftStep / 5);
leftStepSlider->setOrientation(Qt::Horizontal);
QLabel* leftStepLabel = new QLabel(this);
leftStepLabel->setText(tr("Left Spacing: ") +
QString::number(IsometricLeftStep));
connect(leftStepSlider, &QSlider::valueChanged, [=](int value) {
IsometricLeftStep = value * 5;
leftStepLabel->setText(tr("Left Spacing: ") +
QString::number(IsometricLeftStep));
emit updateViewer();
});
QSlider* rightStepSlider = new QSlider(this);
rightStepSlider->setRange(1, 100);
rightStepSlider->setValue(IsometricRightStep / 5);
rightStepSlider->setOrientation(Qt::Horizontal);
QLabel* rightStepLabel = new QLabel(this);
rightStepLabel->setText(tr("Right Spacing: ") +
QString::number(IsometricRightStep));
connect(rightStepSlider, &QSlider::valueChanged, [=](int value) {
IsometricRightStep = value * 5;
rightStepLabel->setText(tr("Right Spacing: ") +
QString::number(IsometricRightStep));
emit updateViewer();
});
QGridLayout* isometricLayout = new QGridLayout(this);
leftAngleLabel->setFixedWidth(110);
leftAngleLabel->setAlignment(Qt::AlignRight);
isometricLayout->addWidget(leftAngleLabel, 0, 0, Qt::AlignRight);
isometricLayout->addWidget(leftAngleSlider, 0, 1);
isometricLayout->addWidget(leftStepLabel, 1, 0, Qt::AlignRight);
isometricLayout->addWidget(leftStepSlider, 1, 1);
isometricLayout->addWidget(rightAngleLabel, 2, 0, Qt::AlignRight);
isometricLayout->addWidget(rightAngleSlider, 2, 1);
isometricLayout->addWidget(rightStepLabel, 3, 0, Qt::AlignRight);
isometricLayout->addWidget(rightStepSlider, 3, 1);
isometricCheckbox->setLayout(isometricLayout);
QSlider* guideOpacitySlider = new QSlider(this);
guideOpacitySlider->setRange(10, 100);
guideOpacitySlider->setValue(GuideOpacity);
guideOpacitySlider->setOrientation(Qt::Horizontal);
QLabel* guideOpacityLabel = new QLabel(this);
guideOpacityLabel->setText(tr("Opacity: ") +
QString::number(GuideOpacity));
connect(guideOpacitySlider, &QSlider::valueChanged, [=](int value) {
GuideOpacity = value;
guideOpacityLabel->setText(tr("Opacity: ") +
QString::number(GuideOpacity));
emit updateViewer();
});
gridLayout->addWidget(thirdsCheckbox, 0, 0, 1, 2);
gridLayout->addWidget(goldenRationCheckbox, 1, 0, 1, 2);
gridLayout->addWidget(fieldGuideCheckbox, 2, 0, 1, 2);
gridLayout->addWidget(horizontalCheckbox, 3, 0, 1, 2);
gridLayout->addWidget(verticalCheckbox, 4, 0, 1, 2);
gridLayout->addWidget(isometricCheckbox, 5, 0, 1, 2);
gridLayout->addWidget(guideOpacityLabel, 6, 0);
gridLayout->addWidget(guideOpacitySlider, 6, 1);
gridWidget->setLayout(gridLayout);
gridsAction->setDefaultWidget(gridWidget);
m_menu->addAction(gridsAction);
}
//-----------------------------------------------------------------------------
void TPanelTitleBarButtonForGrids::mousePressEvent(QMouseEvent *e) {
m_menu->exec(e->globalPos() + QPoint(-100, 12));
}
//============================================================================= //=============================================================================
// TPanelTitleBarButtonSet // TPanelTitleBarButtonSet
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -10,6 +10,7 @@
class TPanelTitleBarButtonSet; class TPanelTitleBarButtonSet;
class Room; class Room;
class QMenu;
//! icon buttons placed on the panel titlebar (cfr. viewerpane.h) //! icon buttons placed on the panel titlebar (cfr. viewerpane.h)
class TPanelTitleBarButton : public QWidget { class TPanelTitleBarButton : public QWidget {
@ -94,19 +95,37 @@ protected slots:
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/*! specialized button for sage area which enables to choose safe area size by
* context menu
*/
class TPanelTitleBarButtonForCameraView final : public TPanelTitleBarButton { class TPanelTitleBarButtonForCameraView final : public TPanelTitleBarButton {
Q_OBJECT Q_OBJECT
QMenu* m_menu;
public: public:
TPanelTitleBarButtonForCameraView(QWidget* parent, TPanelTitleBarButtonForCameraView(QWidget* parent,
const QString &standardPixmapName) const QString& standardPixmapName);
: TPanelTitleBarButton(parent, standardPixmapName) {}
protected: protected:
void contextMenuEvent(QContextMenuEvent *event) override; void mousePressEvent(QMouseEvent* event) override;
signals:
void updateViewer();
};
//-----------------------------------------------------------------------------
class TPanelTitleBarButtonForGrids final : public TPanelTitleBarButton {
Q_OBJECT
QMenu* m_menu;
public:
TPanelTitleBarButtonForGrids(QWidget* parent,
const QString& standardPixmapName);
//: TPanelTitleBarButton(parent, standardPixmapName) {}
protected:
void mousePressEvent(QMouseEvent *event) override;
signals: signals:
void updateViewer(); void updateViewer();
}; };

View file

@ -1559,13 +1559,13 @@ void SceneViewer::drawOverlay() {
glPopMatrix(); glPopMatrix();
} }
// draw FieldGuide //// draw FieldGuide
if (fieldGuideToggle.getStatus()) { // if (fieldGuideToggle.getStatus()) {
glPushMatrix(); // glPushMatrix();
tglMultMatrix(m_drawTableAff); // tglMultMatrix(m_drawTableAff);
ViewerDraw::drawFieldGuide(); // ViewerDraw::drawFieldGuide();
glPopMatrix(); // glPopMatrix();
} //}
if (!m_drawCameraTest) { if (!m_drawCameraTest) {
// draw grid & guides // draw grid & guides
@ -1596,6 +1596,17 @@ void SceneViewer::drawOverlay() {
m_pixelSize = sqrt(tglGetPixelSize2()) * getDevPixRatio(); m_pixelSize = sqrt(tglGetPixelSize2()) * getDevPixRatio();
ViewerDraw::drawCamera(f, m_pixelSize); ViewerDraw::drawCamera(f, m_pixelSize);
glPopMatrix(); glPopMatrix();
if (fieldGuideToggle.getStatus()) {
glPushMatrix();
tglMultMatrix(m_drawCameraAff);
ViewerDraw::drawCameraOverlays(this, f, m_pixelSize);
glPopMatrix();
glPushMatrix();
tglMultMatrix(m_drawTableAff);
if (ViewerDraw::getShowFieldGuide()) ViewerDraw::drawFieldGuide();
ViewerDraw::drawGridsAndOverlays(this, f, m_pixelSize);
glPopMatrix();
}
} }
} }

View file

@ -411,6 +411,7 @@
<file>icons/dark/actions/20/pane_table.svg</file> <file>icons/dark/actions/20/pane_table.svg</file>
<file>icons/dark/actions/20/pane_safe.svg</file> <file>icons/dark/actions/20/pane_safe.svg</file>
<file>icons/dark/actions/20/pane_grid.svg</file> <file>icons/dark/actions/20/pane_grid.svg</file>
<file>icons/dark/actions/9/pane_more.svg</file>
<file>icons/dark/actions/20/pane_cam.svg</file> <file>icons/dark/actions/20/pane_cam.svg</file>
<file>icons/dark/actions/20/pane_freeze.svg</file> <file>icons/dark/actions/20/pane_freeze.svg</file>
<file>icons/dark/actions/20/pane_preview.svg</file> <file>icons/dark/actions/20/pane_preview.svg</file>

View file

@ -37,6 +37,21 @@
TEnv::StringVar EnvSafeAreaName("SafeAreaName", "PR_safe"); TEnv::StringVar EnvSafeAreaName("SafeAreaName", "PR_safe");
TEnv::IntVar CameraViewTransparency("CameraViewTransparency", 100); TEnv::IntVar CameraViewTransparency("CameraViewTransparency", 100);
TEnv::IntVar IsometricLeftAngle("IsometricLeftAngle", 30);
TEnv::IntVar IsometricRightAngle("IsometricRightAngle", 30);
TEnv::IntVar IsometricLeftStep("IsometricLeftStep", 100);
TEnv::IntVar IsometricRightStep("IsometricRightStep", 100);
TEnv::IntVar ShowRuleOfThirds("ShowRuleOfThirds", 1);
TEnv::IntVar ShowGoldenRatio("ShowGoldenRatio", 0);
TEnv::IntVar ShowIsometricGrid("ShowIsometricGrid", 0);
TEnv::IntVar ShowVerticalGrid("ShowVerticalGrid", 0);
TEnv::IntVar ShowHorizontalGrid("ShowHorizontalGrid", 0);
TEnv::IntVar VerticalSpacing("VerticalSpacing", 100);
TEnv::IntVar HorizontalSpacing("HorizontalSpacing", 100);
TEnv::IntVar HorizontalOffset("HorizontalOffset", 0);
TEnv::IntVar VerticalOffset("VerticalOffset", 0);
TEnv::IntVar ShowFieldGuide("ShowFieldGuide", 1);
TEnv::IntVar GuideOpacity("GuideOpacity", 70);
/* TODO, move to include */ /* TODO, move to include */
void getSafeAreaSizeList(QList<QList<double>> &_sizeList); void getSafeAreaSizeList(QList<QList<double>> &_sizeList);
@ -413,8 +428,8 @@ void ViewerDraw::drawPerspectiveGuides(SceneViewer *viewer, double sc,
bounds.y1 = p.y; bounds.y1 = p.y;
} }
double interval = 150; // *sc; double interval = 150;
glEnable(GL_BLEND); // Enable blending. glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH); glEnable(GL_LINE_SMOOTH);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -424,46 +439,23 @@ void ViewerDraw::drawPerspectiveGuides(SceneViewer *viewer, double sc,
for (int j = 0; j < assistantPoints.size(); j++) { for (int j = 0; j < assistantPoints.size(); j++) {
TPointD p = assistantPoints.at(j); TPointD p = assistantPoints.at(j);
if (j < 5) glColor4d(reds.at(j), greens.at(j), blues.at(j), 0.2); if (j < 5) glColor4d(reds.at(j), greens.at(j), blues.at(j), (double)GuideOpacity / 100.0);
TPointD end; TPointD end;
bool useX = true; double distanceToLeft = std::abs(p.x - bounds.x0);
for (double i = bounds.x0; i < bounds.x1; i += interval) { double distanceToRight = std::abs(p.x - bounds.x1);
end.y = bounds.y0; double distanceToTop = std::abs(p.y - bounds.y1);
end.x = i; double distanceToBottom = std::abs(p.y - bounds.y0);
double xDistance = std::max(distanceToLeft, distanceToRight);
double yDistance = std::max(distanceToTop, distanceToBottom);
double totalDistance = std::sqrt(std::pow(xDistance, 2) +
std::pow(yDistance, 2));
for (int i = 0; i < 360; i += 5) {
double yLength = std::sin(i * (3.14159 / 180)) * totalDistance;
double xLength = std::cos(i * (3.14159 / 180)) * totalDistance;
end.x = p.x + xLength;
end.y = p.y + yLength;
tglDrawSegment(p, end); tglDrawSegment(p, end);
} }
for (double i = bounds.x0; i < bounds.x1; i += interval) {
end.y = bounds.y1;
end.x = i;
tglDrawSegment(p, end);
}
for (double i = bounds.y0; i < bounds.y1; i += interval) {
end.y = i;
end.x = bounds.x0;
tglDrawSegment(p, end);
}
for (double i = bounds.y0; i < bounds.y1; i += interval) {
end.y = i;
end.x = bounds.x1;
tglDrawSegment(p, end);
}
// double distanceToLeft = std::abs(p.x - bounds.x0);
// double distanceToRight = std::abs(p.x - bounds.x1);
// double distanceToTop = std::abs(p.y - bounds.y1);
// double distanceToBottom = std::abs(p.y - bounds.y0);
// double xDistance = std::max(distanceToLeft, distanceToRight);
// double yDistance = std::max(distanceToTop, distanceToBottom);
// double totalDistance = std::sqrt(std::pow(xDistance, 2) +
// std::pow(yDistance, 2));
// for (int i = 0; i < 360; i += 15) {
//
// //double slope = std::tan(i * (3.14159 / 180));
// double yLength = std::sin(i * (3.14159 / 180)) * totalDistance;
// double xLength = std::cos(i * (3.14159 / 180)) * totalDistance;
// end.x = p.x + xLength;
// end.y = p.y + yLength;
// tglDrawSegment(p, end);
//}
} }
glDisable(GL_LINE_SMOOTH); glDisable(GL_LINE_SMOOTH);
@ -678,6 +670,242 @@ void ViewerDraw::drawSafeArea() {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void ViewerDraw::drawGridsAndOverlays(SceneViewer *viewer, unsigned long flags,
double pixelSize) {
TRectD rect = getCameraRect();
int x1, x2, y1, y2;
viewer->rect().getCoords(&x1, &y1, &x2, &y2);
TRect clipRect = TRect(x1, y1, x2 + 1, y2 + 1);
GLfloat modelView[16];
glGetFloatv(GL_MODELVIEW_MATRIX, modelView);
TAffine modelViewAff(modelView[0], modelView[4], modelView[12], modelView[1],
modelView[5], modelView[13]);
TPointD clipCorner[] = {
modelViewAff.inv() * TPointD(clipRect.x0, clipRect.y0),
modelViewAff.inv() * TPointD(clipRect.x1, clipRect.y0),
modelViewAff.inv() * TPointD(clipRect.x1, clipRect.y1),
modelViewAff.inv() * TPointD(clipRect.x0, clipRect.y1)};
TRectD bounds;
bounds.x0 = bounds.x1 = clipCorner[0].x;
bounds.y0 = bounds.y1 = clipCorner[0].y;
int i;
for (i = 1; i < 4; i++) {
const TPointD &p = clipCorner[i];
if (p.x < bounds.x0)
bounds.x0 = p.x;
else if (p.x > bounds.x1)
bounds.x1 = p.x;
if (p.y < bounds.y0)
bounds.y0 = p.y;
else if (p.y > bounds.y1)
bounds.y1 = p.y;
}
glEnable(GL_BLEND); // Enable blending.
glEnable(GL_LINE_SMOOTH);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4d(1.0, 0.3, 1.0, (double)GuideOpacity / 100.0);
glLineWidth(0.5f);
double lengthX = rect.x1 - rect.x0;
double lengthY = rect.y1 - rect.y0;
double halfX = (rect.x1 - rect.x0) / 2.0;
double halfY = (rect.y1 - rect.y0) / 2.0;
double thirdX = (rect.x1 - rect.x0) / 3.0;
double thirdY = (rect.y1 - rect.y0) / 3.0;
double phiX = (rect.x1 - rect.x0) / 1.618;
double phiY = (rect.y1 - rect.y0) / 1.618;
if (ShowVerticalGrid) {
tglDrawSegment(TPointD(rect.x0 + halfX + (VerticalOffset / Stage::standardDpi * Stage::inch), bounds.y0),
TPointD(rect.x0 + halfX + (VerticalOffset / Stage::standardDpi * Stage::inch), bounds.y1));
int step = std::max(1, (int)VerticalSpacing);
double currentX = rect.x0 + halfX;
for (int i = 1; currentX > bounds.x0; i++) {
currentX =
(rect.x0 + halfX) - ((step * i - VerticalOffset) / Stage::standardDpi * Stage::inch);
glBegin(GL_LINES);
glVertex2d(currentX, bounds.y0);
glVertex2d(currentX, bounds.y1);
glEnd();
}
currentX = rect.x0 + halfX;
for (int i = 1; currentX < bounds.x1; i++) {
currentX =
(rect.x0 + halfX) + ((step * i + VerticalOffset) / Stage::standardDpi * Stage::inch);
glBegin(GL_LINES);
glVertex2d(currentX, bounds.y0);
glVertex2d(currentX, bounds.y1);
glEnd();
}
}
if (ShowHorizontalGrid) {
tglDrawSegment(TPointD(bounds.x0, rect.y0 + halfY + (HorizontalOffset / Stage::standardDpi * Stage::inch)),
TPointD(bounds.x1, rect.y0 + halfY + (HorizontalOffset / Stage::standardDpi * Stage::inch)));
int step = std::max(1, (int)HorizontalSpacing);
double currentY = rect.y0 + halfY;
for (int i = 1; currentY > bounds.y0; i++) {
currentY =
rect.y0 + halfY - ((step * i - HorizontalOffset) / Stage::standardDpi * Stage::inch);
// double xInPixels =
glBegin(GL_LINES);
glVertex2d(bounds.x0, currentY);
glVertex2d(bounds.x1, currentY);
glEnd();
}
currentY = rect.y0 + halfY;
for (int i = 1; currentY < bounds.y1; i++) {
currentY =
rect.y0 + halfY + ((step * i + HorizontalOffset)/ Stage::standardDpi * Stage::inch);
glBegin(GL_LINES);
glVertex2d(bounds.x0, currentY);
glVertex2d(bounds.x1, currentY);
glEnd();
}
}
if (ShowIsometricGrid) {
double rightTheta = (double)IsometricRightAngle * (3.14159 / 180);
double rightStep = IsometricRightStep;
double rightRun = std::cos(rightTheta) * rightStep;
double rightRise = std::sin(rightTheta) * rightStep;
double rightSlope = rightRise / rightRun;
{
double topRightX = bounds.y1 / rightSlope;
double bottomRightX = bounds.y0 / rightSlope;
TPointD startRight = TPointD(topRightX, bounds.y1);
TPointD endRight = TPointD(bottomRightX, bounds.y0);
while (startRight.x > bounds.x0) {
glBegin(GL_LINES);
glVertex2d(startRight.x, startRight.y);
glVertex2d(endRight.x, endRight.y);
glEnd();
startRight.x -= rightStep / Stage::standardDpi * Stage::inch;
endRight.x -= rightStep / Stage::standardDpi * Stage::inch;
}
startRight = TPointD(topRightX, bounds.y1);
endRight = TPointD(bottomRightX, bounds.y0);
while (endRight.x < bounds.x1) {
startRight.x += rightStep / Stage::standardDpi * Stage::inch;
endRight.x += rightStep / Stage::standardDpi * Stage::inch;
glBegin(GL_LINES);
glVertex2d(startRight.x + 0.25, startRight.y);
glVertex2d(endRight.x + 0.25, endRight.y);
glEnd();
}
}
double leftTheta = (double)IsometricLeftAngle * (3.14159 / 180);
double leftStep = IsometricLeftStep;
double leftRun = std::cos(leftTheta) * leftStep;
double leftRise = std::sin(leftTheta) * leftStep;
double leftSlope = leftRise / leftRun;
{
double topLeftX = bounds.y1 / -leftSlope;
double bottomLeftX = bounds.y0 / -leftSlope;
TPointD startLeft = TPointD(topLeftX, bounds.y1);
TPointD endLeft = TPointD(bottomLeftX, bounds.y0);
while (startLeft.x < bounds.x1) {
glBegin(GL_LINES);
glVertex2d(startLeft.x, startLeft.y);
glVertex2d(endLeft.x, endLeft.y);
glEnd();
startLeft.x += leftStep / Stage::standardDpi * Stage::inch;
endLeft.x += leftStep / Stage::standardDpi * Stage::inch;
}
startLeft = TPointD(topLeftX, bounds.y1);
endLeft = TPointD(bottomLeftX, bounds.y0);
while (endLeft.x > bounds.x0) {
startLeft.x -= leftStep / Stage::standardDpi * Stage::inch;
endLeft.x -= leftStep / Stage::standardDpi * Stage::inch;
glBegin(GL_LINES);
glVertex2d(startLeft.x, startLeft.y);
glVertex2d(endLeft.x, endLeft.y);
glEnd();
}
}
}
glLineWidth(1.0f);
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
}
//-----------------------------------------------------------------------------
void ViewerDraw::drawCameraOverlays(SceneViewer* viewer, unsigned long flags,
double pixelSize) {
TRectD rect = getCameraRect();
glEnable(GL_BLEND); // Enable blending.
glEnable(GL_LINE_SMOOTH);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4d(1.0, 0.3, 1.0, (double)GuideOpacity/100.0);
glLineWidth(0.5f);
double lengthX = rect.x1 - rect.x0;
double lengthY = rect.y1 - rect.y0;
double halfX = (rect.x1 - rect.x0) / 2.0;
double halfY = (rect.y1 - rect.y0) / 2.0;
double thirdX = (rect.x1 - rect.x0) / 3.0;
double thirdY = (rect.y1 - rect.y0) / 3.0;
double phiX = (rect.x1 - rect.x0) / 1.618;
double phiY = (rect.y1 - rect.y0) / 1.618;
if (ShowRuleOfThirds) {
// vertical thirds
glBegin(GL_LINES);
glVertex2d(rect.x0 + thirdX, rect.y0);
glVertex2d(rect.x0 + thirdX, rect.y1);
glVertex2d(rect.x0 + (thirdX * 2), rect.y0);
glVertex2d(rect.x0 + (thirdX * 2), rect.y1);
// horizontal thirds
glVertex2d(rect.x0, rect.y0 + thirdY);
glVertex2d(rect.x1, rect.y0 + thirdY);
glVertex2d(rect.x0, rect.y0 + (thirdY * 2));
glVertex2d(rect.x1, rect.y0 + (thirdY * 2));
glEnd();
}
if (ShowGoldenRatio) {
// phi thirds
glBegin(GL_LINES);
glVertex2d(rect.x0 + phiX, rect.y0);
glVertex2d(rect.x0 + phiX, rect.y1);
glVertex2d(rect.x1 - phiX, rect.y0);
glVertex2d(rect.x1 - phiX, rect.y1);
glVertex2d(rect.x0, rect.y0 + phiY);
glVertex2d(rect.x1, rect.y0 + phiY);
glVertex2d(rect.x0, rect.y1 - phiY);
glVertex2d(rect.x1, rect.y1 - phiY);
glEnd();
}
glLineWidth(1.0f);
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
}
//-----------------------------------------------------------------------------
bool ViewerDraw::getShowFieldGuide() {
return ShowFieldGuide == 1 ? true : false;
}
//-----------------------------------------------------------------------------
void ViewerDraw::drawCamera(unsigned long flags, double pixelSize) { void ViewerDraw::drawCamera(unsigned long flags, double pixelSize) {
bool cameraRef = 0 != (flags & ViewerDraw::CAMERA_REFERENCE); bool cameraRef = 0 != (flags & ViewerDraw::CAMERA_REFERENCE);
bool camera3d = 0 != (flags & ViewerDraw::CAMERA_3D); bool camera3d = 0 != (flags & ViewerDraw::CAMERA_3D);

View file

@ -40,12 +40,15 @@ void drawPerspectiveGuides(SceneViewer *viewer, double viewerScale,
void draw3DCamera(unsigned long flags, double zmin, double phi); void draw3DCamera(unsigned long flags, double zmin, double phi);
void drawCamera(unsigned long flags, double pixelSize); void drawCamera(unsigned long flags, double pixelSize);
void drawGridsAndOverlays(SceneViewer *viewer, unsigned long flags,
double pixelSize);
void drawCameraOverlays(SceneViewer* viewer, unsigned long flags,
double pixelSize);
void draw3DFrame(double zmin, double phi); void draw3DFrame(double zmin, double phi);
void drawDisk(int &tableDLId); void drawDisk(int &tableDLId);
void drawFieldGuide(); void drawFieldGuide();
void drawColorcard(UCHAR channel); void drawColorcard(UCHAR channel);
bool getShowFieldGuide();
void drawSafeArea(); void drawSafeArea();
unsigned int createDiskDisplayList(); unsigned int createDiskDisplayList();

View file

@ -426,7 +426,7 @@ void SceneViewerPanel::initializeTitleBar(TPanelTitleBar *titleBar) {
TPanelTitleBarButtonSet *viewModeButtonSet; TPanelTitleBarButtonSet *viewModeButtonSet;
m_referenceModeBs = viewModeButtonSet = new TPanelTitleBarButtonSet(); m_referenceModeBs = viewModeButtonSet = new TPanelTitleBarButtonSet();
int x = -232; int x = -272;
int iconWidth = 20; int iconWidth = 20;
TPanelTitleBarButton *button; TPanelTitleBarButton *button;
@ -448,18 +448,29 @@ void SceneViewerPanel::initializeTitleBar(TPanelTitleBar *titleBar) {
button = new TPanelTitleBarButton( button = new TPanelTitleBarButton(
titleBar, getIconThemePath("actions/20/pane_grid.svg")); titleBar, getIconThemePath("actions/20/pane_grid.svg"));
button->setToolTip(tr("Field Guide")); button->setToolTip(tr("Grids and Overlays\nRight click to adjust."));
x += 1 + iconWidth; x += 1 + iconWidth;
titleBar->add(QPoint(x, 0), button); titleBar->add(QPoint(x, 0), button);
ret = ret && connect(button, SIGNAL(toggled(bool)), ret = ret && connect(button, SIGNAL(toggled(bool)),
CommandManager::instance()->getAction(MI_FieldGuide), CommandManager::instance()->getAction(MI_FieldGuide),
SLOT(trigger())); SLOT(trigger()));
ret = ret && connect(CommandManager::instance()->getAction(MI_FieldGuide), ret = ret &&
connect(CommandManager::instance()->getAction(MI_FieldGuide),
SIGNAL(triggered(bool)), button, SLOT(setPressed(bool))); SIGNAL(triggered(bool)), button, SLOT(setPressed(bool)));
// initialize state // initialize state
button->setPressed( button->setPressed(
CommandManager::instance()->getAction(MI_FieldGuide)->isChecked()); CommandManager::instance()->getAction(MI_FieldGuide)->isChecked());
TPanelTitleBarButtonForGrids* gridMoreButton = new TPanelTitleBarButtonForGrids(
titleBar, getIconThemePath("actions/9/pane_more.svg"));
gridMoreButton->setToolTip(tr("Grids and Overlays Settings"));
x += 1 + iconWidth;
titleBar->add(QPoint(x, 0), gridMoreButton);
connect(gridMoreButton, &TPanelTitleBarButtonForGrids::updateViewer,
[=]() { m_sceneViewer->update(); });
// view mode toggles // view mode toggles
button = new TPanelTitleBarButton( button = new TPanelTitleBarButton(
titleBar, getIconThemePath("actions/20/pane_table.svg")); titleBar, getIconThemePath("actions/20/pane_table.svg"));
@ -476,14 +487,19 @@ void SceneViewerPanel::initializeTitleBar(TPanelTitleBar *titleBar) {
titleBar->add(QPoint(x, 0), button); titleBar->add(QPoint(x, 0), button);
button->setButtonSet(viewModeButtonSet, SceneViewer::CAMERA3D_REFERENCE); button->setButtonSet(viewModeButtonSet, SceneViewer::CAMERA3D_REFERENCE);
TPanelTitleBarButtonForCameraView *camButton = button = new TPanelTitleBarButton(
new TPanelTitleBarButtonForCameraView(
titleBar, getIconThemePath("actions/20/pane_cam.svg")); titleBar, getIconThemePath("actions/20/pane_cam.svg"));
camButton->setToolTip(tr("Camera View")); button->setToolTip(tr("Camera View"));
x += +1 + iconWidth; x += +1 + iconWidth;
titleBar->add(QPoint(x, 0), camButton); titleBar->add(QPoint(x, 0), button);
camButton->setButtonSet(viewModeButtonSet, SceneViewer::CAMERA_REFERENCE); button->setButtonSet(viewModeButtonSet, SceneViewer::CAMERA_REFERENCE);
connect(camButton, &TPanelTitleBarButtonForCameraView::updateViewer,
TPanelTitleBarButtonForCameraView* camTransparencyButton = new TPanelTitleBarButtonForCameraView(
titleBar, getIconThemePath("actions/9/pane_more.svg"));
camTransparencyButton->setToolTip(tr("Change camera view transparency."));
x += 1 + iconWidth;
titleBar->add(QPoint(x, 0), camTransparencyButton);
connect(camTransparencyButton, &TPanelTitleBarButtonForCameraView::updateViewer,
[=]() { m_sceneViewer->update(); }); [=]() { m_sceneViewer->update(); });
ret = ret && connect(viewModeButtonSet, SIGNAL(selected(int)), m_sceneViewer, ret = ret && connect(viewModeButtonSet, SIGNAL(selected(int)), m_sceneViewer,

View file

@ -70,7 +70,7 @@ typedef std::vector<Player> PlayerSet;
images .pli. images .pli.
*/ */
const double Stage::inch = 53.33333; const double Stage::inch = 53.33333;
const double Stage::standardDpi = 120; const double Stage::standardDpi = 120.0;
namespace { namespace {
void updateOnionSkinSize(const PlayerSet &players) { void updateOnionSkinSize(const PlayerSet &players) {