// Created by: Sergey ZERCHANINOV
// Copyright (c) 2011-2013 OPEN CASCADE SAS
//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
-#include <OpenGl_GraphicDriver.hxx>
+#ifdef HAVE_CONFIG_H
+ #include <config.h>
+#endif
+#include <OpenGl_GraphicDriver.hxx>
#include <OpenGl_Context.hxx>
+#include <OpenGl_Flipper.hxx>
#include <OpenGl_GraduatedTrihedron.hxx>
#include <OpenGl_Group.hxx>
#include <OpenGl_CView.hxx>
#include <OpenGl_View.hxx>
+#include <OpenGl_StencilTest.hxx>
#include <OpenGl_Text.hxx>
#include <OpenGl_Trihedron.hxx>
#include <OpenGl_Workspace.hxx>
#endif
}
+// =======================================================================
+// function : OpenGl_GraphicDriver
+// purpose :
+// =======================================================================
+OpenGl_GraphicDriver::OpenGl_GraphicDriver (const Handle(Aspect_DisplayConnection)& theDisplayConnection)
+: Graphic3d_GraphicDriver ("TKOpenGl"),
+ myCaps (new OpenGl_Caps()),
+ myMapOfView (1, NCollection_BaseAllocator::CommonBaseAllocator()),
+ myMapOfWS (1, NCollection_BaseAllocator::CommonBaseAllocator()),
+ myMapOfStructure (1, NCollection_BaseAllocator::CommonBaseAllocator()),
+ myUserDrawCallback (NULL),
+ myTempText (new OpenGl_Text())
+{
+ Begin (theDisplayConnection);
+}
+
// =======================================================================
// function : OpenGl_GraphicDriver
// purpose :
}
// =======================================================================
-// function : BeginAddMode
-// purpose :
+// function : GetOpenClDeviceInfo
+// purpose : Returns information about device used for computations
// =======================================================================
-Standard_Boolean OpenGl_GraphicDriver::BeginAddMode (const Graphic3d_CView& theCView)
-{
- if (theCView.ViewId == -1)
- {
- return Standard_False;
- }
-
- const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView;
- if (aCView != NULL && aCView->WS->BeginAddMode())
- {
- myImmediateWS = aCView->WS;
- return Standard_True;
- }
+#ifndef HAVE_OPENCL
+Standard_Boolean OpenGl_GraphicDriver::GetOpenClDeviceInfo (const Graphic3d_CView&,
+ NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>&)
+{
return Standard_False;
}
-// =======================================================================
-// function : EndAddMode
-// purpose :
-// =======================================================================
-void OpenGl_GraphicDriver::EndAddMode()
-{
- if (!myImmediateWS.IsNull())
- {
- myImmediateWS->EndAddMode();
- myImmediateWS.Nullify();
- }
-}
+#else
-// =======================================================================
-// function : BeginImmediatMode
-// purpose :
-// =======================================================================
-Standard_Boolean OpenGl_GraphicDriver::BeginImmediatMode (const Graphic3d_CView& theCView,
- const Aspect_CLayer2d& /*theCUnderLayer*/,
- const Aspect_CLayer2d& /*theCOverLayer*/,
- const Standard_Boolean theDoubleBuffer,
- const Standard_Boolean theRetainMode)
+Standard_Boolean OpenGl_GraphicDriver::GetOpenClDeviceInfo (const Graphic3d_CView& theCView,
+ NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>& theInfo)
{
- if (theCView.ViewId == -1)
- {
- return Standard_False;
- }
- const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView;
- if (aCView != NULL && aCView->WS->BeginImmediatMode (theCView, theDoubleBuffer, theRetainMode))
+ if (theCView.ViewId == -1 || theCView.ptrView == NULL)
{
- myImmediateWS = aCView->WS;
- return Standard_True;
+ return Standard_False;
}
- return Standard_False;
+ return reinterpret_cast<const OpenGl_CView*> (theCView.ptrView)->WS->GetOpenClDeviceInfo (theInfo);
}
-// =======================================================================
-// function : ClearImmediatMode
-// purpose :
-// =======================================================================
-void OpenGl_GraphicDriver::ClearImmediatMode (const Graphic3d_CView& theCView,
- const Standard_Boolean theToFlush)
-{
- const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView;
- if (aCView != NULL)
- {
- aCView->WS->ClearImmediatMode (theCView, theToFlush);
- }
-}
+#endif
// =======================================================================
-// function : DrawStructure
+// function : DisplayImmediateStructure
// purpose :
// =======================================================================
-void OpenGl_GraphicDriver::DrawStructure (const Graphic3d_CStructure& theCStructure)
+void OpenGl_GraphicDriver::DisplayImmediateStructure (const Graphic3d_CView& theCView,
+ const Graphic3d_CStructure& theCStructure)
{
- OpenGl_Structure* aStructure = (OpenGl_Structure* )theCStructure.ptrStructure;
- if (aStructure == NULL)
+ OpenGl_CView* aCView = (OpenGl_CView* )theCView.ptrView;
+ OpenGl_Structure* aStructure = (OpenGl_Structure* )&theCStructure;
+ if (aCView == NULL)
{
return;
}
- if (!myImmediateWS.IsNull())
- {
- myImmediateWS->DrawStructure (aStructure);
- }
+ aCView->View->DisplayImmediateStructure (aStructure);
}
// =======================================================================
-// function : EndImmediatMode
+// function : EraseImmediateStructure
// purpose :
// =======================================================================
-void OpenGl_GraphicDriver::EndImmediatMode (const Standard_Integer )
+void OpenGl_GraphicDriver::EraseImmediateStructure (const Graphic3d_CView& theCView,
+ const Graphic3d_CStructure& theCStructure)
{
- if (!myImmediateWS.IsNull())
+ OpenGl_CView* aCView = (OpenGl_CView* )theCView.ptrView;
+ OpenGl_Structure* aStructure = (OpenGl_Structure* )&theCStructure;
+ if (aCView == NULL)
{
- myImmediateWS->EndImmediatMode();
- myImmediateWS.Nullify();
+ return;
}
+
+ aCView->View->EraseImmediateStructure (aStructure);
}
+
// =======================================================================
// function : Print
// purpose :
return isPrinted;
}
+void OpenGl_GraphicDriver::SetStencilTestOptions (const Graphic3d_CGroup& theCGroup,
+ const Standard_Boolean theIsEnabled)
+{
+ OpenGl_StencilTest* aStencilTest = new OpenGl_StencilTest();
+ aStencilTest->SetOptions (theIsEnabled);
+ ((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (aStencilTest);
+}
+
// =======================================================================
// function : Text
// purpose :
aParams.VAlign = theVta;
const OpenGl_Vec3 aPoint (thePoint.X(), thePoint.Y(), thePoint.Z());
OpenGl_Text* aText = new OpenGl_Text (theText, aPoint, aParams);
- ((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (TelText, aText);
+ ((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (aText);
}
// =======================================================================
{
OpenGl_GraduatedTrihedron::SetMinMax (theMinX, theMinY, theMinZ, theMaxX, theMaxY, theMaxZ);
}
+
+// =======================================================================
+// function : SetFlippingOptions
+// purpose : Enable or disable flipping option for the given group
+// =======================================================================
+void OpenGl_GraphicDriver::SetFlippingOptions (const Graphic3d_CGroup& theCGroup,
+ const Standard_Boolean theIsEnabled,
+ const gp_Ax2& theRefPlane)
+{
+ OpenGl_Flipper* aFlipper = new OpenGl_Flipper (theRefPlane);
+ aFlipper->SetOptions (theIsEnabled);
+ ((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (aFlipper);
+}