// and conditions governing the rights and limitations under the License.
#include <OpenGl_Flipper.hxx>
+
+#include <OpenGl_Context.hxx>
+#include <OpenGl_ShaderManager.hxx>
#include <OpenGl_Vec.hxx>
#include <OpenGl_Workspace.hxx>
// =======================================================================
void OpenGl_Flipper::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{
+ // Check if rendering is to be in immediate mode
+ const Standard_Boolean isImmediate = (theWorkspace->NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE)) != 0;
+ const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
+ GLint aCurrMode = GL_MODELVIEW;
+ glGetIntegerv (GL_MATRIX_MODE, &aCurrMode);
+
if (!myIsEnabled)
{
- glMatrixMode (GL_MODELVIEW);
- glLoadMatrixf ((GLfloat*) theWorkspace->ViewMatrix());
+ // Restore transformation
+ if (isImmediate)
+ {
+ if (aCurrMode != GL_MODELVIEW)
+ {
+ glMatrixMode (GL_MODELVIEW);
+ }
+
+ glPopMatrix();
+
+ if (aCurrMode != GL_MODELVIEW)
+ {
+ glMatrixMode (aCurrMode);
+ }
+
+ Tmatrix3 aModelWorldState = { { 1.f, 0.f, 0.f, 0.f },
+ { 0.f, 1.f, 0.f, 0.f },
+ { 0.f, 0.f, 1.f, 0.f },
+ { 0.f, 0.f, 0.f, 1.f } };
+
+ aContext->ShaderManager()->RevertModelWorldStateTo (aModelWorldState);
+ }
+ else
+ {
+ // Update current model-view matrix in the top of the stack
+ // replacing it with StructureMatrixT*ViewMatrix from the workspace.
+ theWorkspace->UpdateModelViewMatrix();
+ }
return;
}
+ if (isImmediate)
+ {
+
+ if (!aContext->ShaderManager()->IsEmpty())
+ {
+ Tmatrix3 aWorldView;
+ glGetFloatv (GL_MODELVIEW_MATRIX, *aWorldView);
+
+ Tmatrix3 aProjection;
+ glGetFloatv (GL_PROJECTION_MATRIX, *aProjection);
+
+ aContext->ShaderManager()->UpdateWorldViewStateTo (aWorldView);
+ aContext->ShaderManager()->UpdateProjectionStateTo (aProjection);
+ }
+
+ if (aCurrMode != GL_MODELVIEW)
+ {
+ glMatrixMode (GL_MODELVIEW);
+ }
+
+ glPushMatrix();
+
+ if (aCurrMode != GL_MODELVIEW)
+ {
+ glMatrixMode (aCurrMode);
+ }
+ }
+
OpenGl_Mat4 aMatrixMV;
glGetFloatv (GL_MODELVIEW_MATRIX, aMatrixMV.ChangeData());
aMatrixMV = aMatrixMV * aTransform;
// load transformed model-view matrix
- GLint aCurrMode = GL_MODELVIEW;
- glGetIntegerv (GL_MATRIX_MODE, &aCurrMode);
if (aCurrMode != GL_MODELVIEW)
{
glMatrixMode (GL_MODELVIEW);
TextParam_applied (NULL),
ViewMatrix_applied (&myDefaultMatrix),
StructureMatrix_applied (&myDefaultMatrix),
+ myModelViewMatrix (myDefaultMatrix),
PolygonOffset_applied (NULL)
{
theDisplay->InitAttributes();
const OpenGl_Matrix* SetViewMatrix (const OpenGl_Matrix* );
const OpenGl_Matrix* SetStructureMatrix (const OpenGl_Matrix*, bool aRevert = false);
+ //! Updates current model-view matrix
+ //! replacing it with StructureMatrixT*ViewMatrix from the workspace.
+ const void UpdateModelViewMatrix();
+
const OpenGl_AspectLine* SetAspectLine (const OpenGl_AspectLine* theAspect);
const OpenGl_AspectFace* SetAspectFace (const OpenGl_AspectFace* theAspect);
const OpenGl_AspectMarker* SetAspectMarker (const OpenGl_AspectMarker* theAspect);
const OpenGl_Matrix* ViewMatrix_applied;
const OpenGl_Matrix* StructureMatrix_applied;
+ //! Model matrix with applied structure transformations
+ OpenGl_Matrix myModelViewMatrix;
+
const TEL_POFFSET_PARAM* PolygonOffset_applied;
OpenGl_AspectFace myAspectFaceHl; // Hiddenline aspect
#include <OpenGl_AspectText.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_ShaderManager.hxx>
+#include <OpenGl_telem_util.hxx>
#ifdef HAVE_CONFIG_H
# include <config.h>
/*----------------------------------------------------------------------*/
-const OpenGl_Matrix * OpenGl_Workspace::SetViewMatrix(const OpenGl_Matrix *AMatrix)
+const OpenGl_Matrix * OpenGl_Workspace::SetViewMatrix (const OpenGl_Matrix *AMatrix)
{
const OpenGl_Matrix *ViewMatrix_old = ViewMatrix_applied;
ViewMatrix_applied = AMatrix;
- OpenGl_Matrix lmat;
- OpenGl_Transposemat3( &lmat, StructureMatrix_applied );
-
- glMatrixMode (GL_MODELVIEW);
- OpenGl_Matrix rmat;
- OpenGl_Multiplymat3 (&rmat, &lmat, ViewMatrix_applied);
- glLoadMatrixf ((const GLfloat* )rmat.mat);
+ // Update model-view matrix with new view matrix
+ UpdateModelViewMatrix();
return ViewMatrix_old;
}
OpenGl_Matrix lmat;
OpenGl_Transposemat3( &lmat, AMatrix );
- glMatrixMode (GL_MODELVIEW);
- OpenGl_Matrix rmat;
- OpenGl_Multiplymat3 (&rmat, &lmat, ViewMatrix_applied);
- glLoadMatrixf ((const GLfloat* )rmat.mat);
+ // Update model-view matrix with new structure matrix
+ UpdateModelViewMatrix();
if (!myGlContext->ShaderManager()->IsEmpty())
{
/*----------------------------------------------------------------------*/
+const void OpenGl_Workspace::UpdateModelViewMatrix()
+{
+ OpenGl_Matrix aStructureMatT;
+ OpenGl_Transposemat3( &aStructureMatT, StructureMatrix_applied);
+
+ glMatrixMode (GL_MODELVIEW);
+ OpenGl_Multiplymat3 (&myModelViewMatrix, &aStructureMatT, ViewMatrix_applied);
+ glLoadMatrixf ((const GLfloat* )&myModelViewMatrix.mat);
+}
+
+/*----------------------------------------------------------------------*/
+
const OpenGl_AspectLine * OpenGl_Workspace::AspectLine(const Standard_Boolean WithApply)
{
if ( WithApply && (AspectLine_set != AspectLine_applied) )
--- /dev/null
+puts "============"
+puts "CR24374"
+puts "============"
+puts ""
+#######################################################################
+# Flipping affects highlight presentation of dimension
+#######################################################################
+pload ALL
+pload QAcommands
+box b 100 100 100
+explode b e
+vdisplay b
+vdisplay b_9
+vdim -length -name=dim1 b_9 -text=3d -plane=zox
+vdisplay dim1
+vselmode b 2 1
+vfit
+vmoveto 110 352
+
+set x_coord 161
+set y_coord 372
+checkcolor $x_coord $y_coord 0 1 1
+
+if { $stat != 1 } {
+ puts "Error : Highlighting of dimension with flipping in local context failed."
+}
+
+set only_screen 1
\ No newline at end of file