mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-10 23:46:00 -06:00
#3573 Draw axis lines across the whole view for 2d Contour Maps.
This commit is contained in:
parent
e9de865c1f
commit
78d81d2630
@ -62,14 +62,15 @@ using namespace cvf;
|
||||
/// Constructor
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivWindowEdgeAxesOverlayItem::RivWindowEdgeAxesOverlayItem(Font* font)
|
||||
: m_windowSize(600, 600),
|
||||
m_textColor(Color3::BLACK),
|
||||
m_lineColor(Color3::BLACK),
|
||||
m_frameColor(Color3::WHITE),
|
||||
m_lineWidth(1),
|
||||
m_font(font),
|
||||
m_isSwitchingYAxisValueSign(true),
|
||||
m_domainAxes(XZ_AXES)
|
||||
: m_windowSize(600, 600)
|
||||
, m_textColor(Color3::BLACK)
|
||||
, m_lineColor(Color3::BLACK)
|
||||
, m_frameColor(Color3::WHITE)
|
||||
, m_lineWidth(1)
|
||||
, m_font(font)
|
||||
, m_isSwitchingYAxisValueSign(true)
|
||||
, m_showAxisLines(false)
|
||||
, m_domainAxes(XZ_AXES)
|
||||
{
|
||||
CVF_ASSERT(font);
|
||||
CVF_ASSERT(!font->isEmpty());
|
||||
@ -423,7 +424,8 @@ void RivWindowEdgeAxesOverlayItem::renderSoftwareFrameAndTickLines(OpenGLContext
|
||||
// Render Line around
|
||||
|
||||
{
|
||||
glColor3fv(m_lineColor.ptr());
|
||||
cvf::Color4f lineColorWithAlpha(m_lineColor, m_showAxisLines ? 0.25f : 1.0f);
|
||||
glColor4fv(lineColorWithAlpha.ptr());
|
||||
glBegin(GL_LINES);
|
||||
// Frame lines
|
||||
glVertex3fv(vertexArray[7].ptr());
|
||||
@ -438,47 +440,79 @@ void RivWindowEdgeAxesOverlayItem::renderSoftwareFrameAndTickLines(OpenGLContext
|
||||
// X - axis Tick lines
|
||||
for (double txpos : m_windowTickXValues)
|
||||
{
|
||||
Vec3f p1(Vec3f::ZERO);
|
||||
Vec3f p2(Vec3f::ZERO);
|
||||
if (m_showAxisLines)
|
||||
{
|
||||
Vec3f p1(Vec3f::ZERO);
|
||||
Vec3f p2(Vec3f::ZERO);
|
||||
|
||||
p1[0] = (float)txpos;
|
||||
p1[1] = m_frameBorderHeight;
|
||||
p2[0] = (float)txpos;
|
||||
p2[1] = m_frameBorderHeight - m_tickLineLength;
|
||||
p1[0] = (float)txpos;
|
||||
p1[1] = m_frameBorderHeight - m_tickLineLength;
|
||||
p2[0] = (float)txpos;
|
||||
p2[1] = m_windowSize.y() - m_frameBorderHeight + m_tickLineLength;
|
||||
|
||||
glVertex3fv(p1.ptr());
|
||||
glVertex3fv(p2.ptr());
|
||||
glVertex3fv(p1.ptr());
|
||||
glVertex3fv(p2.ptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
Vec3f p1(Vec3f::ZERO);
|
||||
Vec3f p2(Vec3f::ZERO);
|
||||
|
||||
p1[0] = (float)txpos;
|
||||
p1[1] = m_windowSize.y() - m_frameBorderHeight;
|
||||
p2[0] = (float)txpos;
|
||||
p2[1] = m_windowSize.y() - m_frameBorderHeight + m_tickLineLength;
|
||||
p1[0] = (float)txpos;
|
||||
p1[1] = m_frameBorderHeight;
|
||||
p2[0] = (float)txpos;
|
||||
p2[1] = m_frameBorderHeight - m_tickLineLength;
|
||||
|
||||
glVertex3fv(p1.ptr());
|
||||
glVertex3fv(p2.ptr());
|
||||
glVertex3fv(p1.ptr());
|
||||
glVertex3fv(p2.ptr());
|
||||
|
||||
p1[0] = (float)txpos;
|
||||
p1[1] = m_windowSize.y() - m_frameBorderHeight;
|
||||
p2[0] = (float)txpos;
|
||||
p2[1] = m_windowSize.y() - m_frameBorderHeight + m_tickLineLength;
|
||||
|
||||
glVertex3fv(p1.ptr());
|
||||
glVertex3fv(p2.ptr());
|
||||
}
|
||||
}
|
||||
|
||||
// Left Y - axis Tick lines
|
||||
for (double typos : m_windowTickYValues)
|
||||
{
|
||||
Vec3f p1(Vec3f::ZERO);
|
||||
Vec3f p2(Vec3f::ZERO);
|
||||
if (m_showAxisLines)
|
||||
{
|
||||
Vec3f p1(Vec3f::ZERO);
|
||||
Vec3f p2(Vec3f::ZERO);
|
||||
|
||||
p1[0] = m_frameBorderWidth;
|
||||
p1[1] = (float)typos;
|
||||
p2[0] = m_frameBorderWidth - m_tickLineLength;
|
||||
p2[1] = (float)typos;
|
||||
p1[0] = m_frameBorderWidth - m_tickLineLength;
|
||||
p1[1] = (float)typos;
|
||||
p2[0] = m_windowSize.x() - m_frameBorderWidth + m_tickLineLength;
|
||||
p2[1] = (float)typos;
|
||||
|
||||
glVertex3fv(p1.ptr());
|
||||
glVertex3fv(p2.ptr());
|
||||
glVertex3fv(p1.ptr());
|
||||
glVertex3fv(p2.ptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
Vec3f p1(Vec3f::ZERO);
|
||||
Vec3f p2(Vec3f::ZERO);
|
||||
|
||||
p1[0] = m_windowSize.x() - m_frameBorderWidth;
|
||||
p1[1] = (float)typos;
|
||||
p2[0] = m_windowSize.x() - m_frameBorderWidth + m_tickLineLength;
|
||||
p2[1] = (float)typos;
|
||||
p1[0] = m_frameBorderWidth;
|
||||
p1[1] = (float)typos;
|
||||
p2[0] = m_frameBorderWidth - m_tickLineLength;
|
||||
p2[1] = (float)typos;
|
||||
|
||||
glVertex3fv(p1.ptr());
|
||||
glVertex3fv(p2.ptr());
|
||||
glVertex3fv(p1.ptr());
|
||||
glVertex3fv(p2.ptr());
|
||||
|
||||
p1[0] = m_windowSize.x() - m_frameBorderWidth;
|
||||
p1[1] = (float)typos;
|
||||
p2[0] = m_windowSize.x() - m_frameBorderWidth + m_tickLineLength;
|
||||
p2[1] = (float)typos;
|
||||
|
||||
glVertex3fv(p1.ptr());
|
||||
glVertex3fv(p2.ptr());
|
||||
}
|
||||
}
|
||||
|
||||
glEnd();
|
||||
@ -547,7 +581,7 @@ void RivWindowEdgeAxesOverlayItem::renderShaderFrameAndTickLines(OpenGLContext*
|
||||
|
||||
// Draw frame border lines
|
||||
|
||||
UniformFloat uniformColor("u_color", Color4f(m_lineColor));
|
||||
UniformFloat uniformColor("u_color", Color4f(m_lineColor, m_showAxisLines ? 0.25f : 1.0f));
|
||||
shaderProgram->applyUniform(oglContext, uniformColor);
|
||||
|
||||
static const ushort frameLineIndices[] = { 7, 4,
|
||||
@ -565,38 +599,62 @@ void RivWindowEdgeAxesOverlayItem::renderShaderFrameAndTickLines(OpenGLContext*
|
||||
|
||||
for (double txpos : m_windowTickXValues)
|
||||
{
|
||||
vertexArray[0][0] = (float)txpos;
|
||||
vertexArray[0][1] = m_frameBorderHeight;
|
||||
vertexArray[1][0] = (float)txpos;
|
||||
vertexArray[1][1] = m_frameBorderHeight - m_tickLineLength;
|
||||
if (m_showAxisLines)
|
||||
{
|
||||
vertexArray[0][0] = (float)txpos;
|
||||
vertexArray[0][1] = m_frameBorderHeight - m_tickLineLength;
|
||||
vertexArray[1][0] = (float)txpos;
|
||||
vertexArray[1][1] = m_windowSize.y() - m_frameBorderHeight + m_tickLineLength;
|
||||
|
||||
glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices);
|
||||
glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices);
|
||||
}
|
||||
else
|
||||
{
|
||||
vertexArray[0][0] = (float)txpos;
|
||||
vertexArray[0][1] = m_frameBorderHeight;
|
||||
vertexArray[1][0] = (float)txpos;
|
||||
vertexArray[1][1] = m_frameBorderHeight - m_tickLineLength;
|
||||
|
||||
vertexArray[0][0] = (float)txpos;
|
||||
vertexArray[0][1] = m_windowSize.y() - m_frameBorderHeight;
|
||||
vertexArray[1][0] = (float)txpos;
|
||||
vertexArray[1][1] = m_windowSize.y() - m_frameBorderHeight + m_tickLineLength;
|
||||
glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices);
|
||||
|
||||
glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices);
|
||||
vertexArray[0][0] = (float)txpos;
|
||||
vertexArray[0][1] = m_windowSize.y() - m_frameBorderHeight;
|
||||
vertexArray[1][0] = (float)txpos;
|
||||
vertexArray[1][1] = m_windowSize.y() - m_frameBorderHeight + m_tickLineLength;
|
||||
|
||||
glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices);
|
||||
}
|
||||
}
|
||||
|
||||
// Left Y - axis Tick lines
|
||||
|
||||
for (double typos : m_windowTickYValues)
|
||||
{
|
||||
vertexArray[0][0] = m_frameBorderWidth;
|
||||
vertexArray[0][1] = (float)typos;
|
||||
vertexArray[1][0] = m_frameBorderWidth - m_tickLineLength;
|
||||
vertexArray[1][1] = (float)typos;
|
||||
if (m_showAxisLines)
|
||||
{
|
||||
vertexArray[0][0] = m_frameBorderWidth - m_tickLineLength;
|
||||
vertexArray[0][1] = (float)typos;
|
||||
vertexArray[1][0] = m_windowSize.x() - m_frameBorderWidth + m_tickLineLength;
|
||||
vertexArray[1][1] = (float)typos;
|
||||
glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices);
|
||||
|
||||
glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices);
|
||||
}
|
||||
else
|
||||
{
|
||||
vertexArray[0][0] = m_frameBorderWidth;
|
||||
vertexArray[0][1] = (float)typos;
|
||||
vertexArray[1][0] = m_frameBorderWidth - m_tickLineLength;
|
||||
vertexArray[1][1] = (float)typos;
|
||||
|
||||
vertexArray[0][0] = m_windowSize.x() - m_frameBorderWidth;
|
||||
vertexArray[0][1] = (float)typos;
|
||||
vertexArray[1][0] = m_windowSize.x() - m_frameBorderWidth + m_tickLineLength;
|
||||
vertexArray[1][1] = (float)typos;
|
||||
glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices);
|
||||
|
||||
glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices);
|
||||
vertexArray[0][0] = m_windowSize.x() - m_frameBorderWidth;
|
||||
vertexArray[0][1] = (float)typos;
|
||||
vertexArray[1][0] = m_windowSize.x() - m_frameBorderWidth + m_tickLineLength;
|
||||
vertexArray[1][1] = (float)typos;
|
||||
|
||||
glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices);
|
||||
}
|
||||
}
|
||||
|
||||
glDisableVertexAttribArray(ShaderProgram::VERTEX);
|
||||
@ -649,3 +707,11 @@ void RivWindowEdgeAxesOverlayItem::setIsSwitchingYAxisSign(bool switchSign)
|
||||
m_isSwitchingYAxisValueSign = switchSign;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivWindowEdgeAxesOverlayItem::setShowAxisLines(bool showAxisLines)
|
||||
{
|
||||
m_showAxisLines = showAxisLines;
|
||||
}
|
||||
|
||||
|
@ -105,6 +105,7 @@ public:
|
||||
int frameBorderWidth() { return static_cast<int>( m_frameBorderWidth); }
|
||||
int frameBorderHeight() { return static_cast<int>( m_frameBorderHeight); }
|
||||
|
||||
void setShowAxisLines(bool showAxisLines);
|
||||
protected:
|
||||
Vec2ui sizeHint() override;
|
||||
void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override;
|
||||
@ -135,6 +136,7 @@ private:
|
||||
float m_tickLineLength;
|
||||
float m_pixelSpacing;
|
||||
bool m_isSwitchingYAxisValueSign;
|
||||
bool m_showAxisLines;
|
||||
DomainAxes m_domainAxes;
|
||||
|
||||
std::vector<double> m_domainCoordsXValues;
|
||||
|
@ -51,6 +51,8 @@ Rim2dEclipseView::Rim2dEclipseView()
|
||||
CAF_PDM_InitFieldNoDefault(&m_2dGridProjection, "Grid2dProjection", "2d Grid Projection", "", "", "");
|
||||
m_2dGridProjection = new Rim2dGridProjection();
|
||||
|
||||
CAF_PDM_InitField(&m_showAxisLines, "ShowAxisLines", true, "Show Axis Lines", "", "", "");
|
||||
|
||||
m_overlayInfoConfig->setIsActive(false);
|
||||
m_gridCollection->setActive(false); // This is also not added to the tree view, so cannot be enabled.
|
||||
wellCollection()->isActive = false;
|
||||
@ -76,6 +78,7 @@ void Rim2dEclipseView::initAfterRead()
|
||||
{
|
||||
m_gridCollection->setActive(false); // This is also not added to the tree view, so cannot be enabled.
|
||||
disablePerspectiveProjectionField();
|
||||
setShowGridBox(false);
|
||||
meshMode.setValue(NO_MESH);
|
||||
surfaceMode.setValue(FAULTS);
|
||||
}
|
||||
@ -101,7 +104,7 @@ void Rim2dEclipseView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering
|
||||
caf::PdmUiGroup* viewGroup = uiOrdering.addNewGroup("Viewer");
|
||||
viewGroup->add(this->userDescriptionField());
|
||||
viewGroup->add(this->backgroundColorField());
|
||||
viewGroup->add(this->showGridBoxField());
|
||||
viewGroup->add(&m_showAxisLines);
|
||||
uiOrdering.skipRemainingFields(true);
|
||||
}
|
||||
|
||||
@ -177,7 +180,7 @@ void Rim2dEclipseView::updateLegends()
|
||||
void Rim2dEclipseView::updateViewWidgetAfterCreation()
|
||||
{
|
||||
m_viewer->showAxisCross(false);
|
||||
m_viewer->showEdgeTickMarksXY(true);
|
||||
m_viewer->showEdgeTickMarksXY(true, m_showAxisLines());
|
||||
m_viewer->enableNavigationRotation(false);
|
||||
|
||||
Rim3dView::updateViewWidgetAfterCreation();
|
||||
@ -203,3 +206,19 @@ void Rim2dEclipseView::onLoadDataAndUpdate()
|
||||
m_viewer->setView(cvf::Vec3d(0, 0, -1), cvf::Vec3d(0, 1, 0));
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim2dEclipseView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &m_showAxisLines)
|
||||
{
|
||||
m_viewer->showEdgeTickMarksXY(true, m_showAxisLines());
|
||||
scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
else
|
||||
{
|
||||
RimEclipseView::fieldChangedByUi(changedField, oldValue, newValue);
|
||||
}
|
||||
}
|
||||
|
@ -39,10 +39,12 @@ protected:
|
||||
void updateViewWidgetAfterCreation() override;
|
||||
void updateViewFollowingRangeFilterUpdates() override;
|
||||
void onLoadDataAndUpdate() override;
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
||||
private:
|
||||
cvf::ref<Riv2dGridProjectionPartMgr> m_grid2dProjectionPartMgr;
|
||||
caf::PdmChildField<Rim2dGridProjection*> m_2dGridProjection;
|
||||
caf::PdmField<bool> m_showAxisLines;
|
||||
|
||||
};
|
||||
|
||||
|
@ -763,6 +763,14 @@ void Rim3dView::setBackgroundColor(const cvf::Color3f& newBackgroundColor)
|
||||
m_backgroundColor = newBackgroundColor;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::setShowGridBox(bool showGridBox)
|
||||
{
|
||||
m_showGridBox = showGridBox;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -107,6 +107,7 @@ public:
|
||||
void setFaultMeshSurfDrawstyle();
|
||||
void setSurfaceDrawstyle();
|
||||
void setBackgroundColor(const cvf::Color3f& newBackgroundColor);
|
||||
void setShowGridBox(bool showGridBox);
|
||||
|
||||
void disableLighting(bool disable);
|
||||
bool isLightingDisabled() const;
|
||||
@ -206,7 +207,6 @@ private:
|
||||
protected:
|
||||
caf::PdmFieldHandle* userDescriptionField() override { return &m_name; }
|
||||
caf::PdmFieldHandle* backgroundColorField() { return &m_backgroundColor; }
|
||||
caf::PdmFieldHandle* showGridBoxField() { return &m_showGridBox; }
|
||||
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
|
@ -826,7 +826,7 @@ void RiuViewer::updateGridBoxData(double scaleZ,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::showEdgeTickMarksXY(bool enable)
|
||||
void RiuViewer::showEdgeTickMarksXY(bool enable, bool showAxisLines)
|
||||
{
|
||||
m_mainRendering->removeOverlayItem(m_windowEdgeAxisOverlay.p());
|
||||
|
||||
@ -834,16 +834,16 @@ void RiuViewer::showEdgeTickMarksXY(bool enable)
|
||||
{
|
||||
m_windowEdgeAxisOverlay->setDomainAxes(RivWindowEdgeAxesOverlayItem::XY_AXES);
|
||||
m_windowEdgeAxisOverlay->setIsSwitchingYAxisSign(false);
|
||||
m_windowEdgeAxisOverlay->setShowAxisLines(showAxisLines);
|
||||
m_mainRendering->addOverlayItem(m_windowEdgeAxisOverlay.p());
|
||||
}
|
||||
|
||||
m_showWindowEdgeAxes = enable;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::showEdgeTickMarksXZ(bool enable)
|
||||
void RiuViewer::showEdgeTickMarksXZ(bool enable, bool showAxisLines)
|
||||
{
|
||||
m_mainRendering->removeOverlayItem(m_windowEdgeAxisOverlay.p());
|
||||
|
||||
@ -851,9 +851,9 @@ void RiuViewer::showEdgeTickMarksXZ(bool enable)
|
||||
{
|
||||
m_windowEdgeAxisOverlay->setDomainAxes(RivWindowEdgeAxesOverlayItem::XZ_AXES);
|
||||
m_windowEdgeAxisOverlay->setIsSwitchingYAxisSign(true);
|
||||
m_windowEdgeAxisOverlay->setShowAxisLines(showAxisLines);
|
||||
m_mainRendering->addOverlayItem(m_windowEdgeAxisOverlay.p());
|
||||
}
|
||||
|
||||
m_showWindowEdgeAxes = enable;
|
||||
}
|
||||
|
||||
|
@ -90,8 +90,8 @@ public:
|
||||
const cvf::Vec3d& displayModelOffset,
|
||||
const cvf::Color3f& backgroundColor,
|
||||
const cvf::BoundingBox& domainCoordBoundingBox);
|
||||
void showEdgeTickMarksXY(bool enable);
|
||||
void showEdgeTickMarksXZ(bool enable);
|
||||
void showEdgeTickMarksXY(bool enable, bool showAxisLines = false);
|
||||
void showEdgeTickMarksXZ(bool enable, bool showAxisLines = false);
|
||||
|
||||
void updateAnnotationItems();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user