mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0022877: Implementation of DRAW commands for non-regression testing:
- TKIVtkDraw toolkit provides IVtk packages functionality in DRAW. - it allows to create VTK interactive view in regular or virtual mode (virtual windows), display OCC objects and dump them. - TKIVtkDraw provides also test commands: ivtlinit, ivtkdisplay, ivtkerase, ivtksetdispmode, ivtksetselmode, ivtkmoveto, ivtkselect, ivtkfit, ivtkdump, ivtkbgcolor. Corrected offscreen rendering mode. Moved vinit command from /v3d/begin script to avoid unused occ view in ivtk tests.
This commit is contained in:
1
src/IVtkDraw/EXTERNLIB
Normal file
1
src/IVtkDraw/EXTERNLIB
Normal file
@@ -0,0 +1 @@
|
||||
CSF_VTK
|
7
src/IVtkDraw/FILES
Normal file
7
src/IVtkDraw/FILES
Normal file
@@ -0,0 +1,7 @@
|
||||
EXTERNLIB
|
||||
IVtkDraw.hxx
|
||||
IVtkDraw.cxx
|
||||
IVtkDraw_HighlightAndSelectionPipeline.hxx
|
||||
IVtkDraw_HighlightAndSelectionPipeline.cxx
|
||||
IVtkDraw_Interactor.hxx
|
||||
IVtkDraw_Interactor.cxx
|
1159
src/IVtkDraw/IVtkDraw.cxx
Normal file
1159
src/IVtkDraw/IVtkDraw.cxx
Normal file
File diff suppressed because it is too large
Load Diff
45
src/IVtkDraw/IVtkDraw.hxx
Normal file
45
src/IVtkDraw/IVtkDraw.hxx
Normal file
@@ -0,0 +1,45 @@
|
||||
// Created on: 2012-02-03
|
||||
//
|
||||
// Copyright (c) 2012-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _IVtkDraw_HeaderFile
|
||||
#define _IVtkDraw_HeaderFile
|
||||
|
||||
#include <MMgt_TShared.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
|
||||
class Draw_Interpretor;
|
||||
class MMgt_TShared;
|
||||
|
||||
class IVtkDraw
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
Standard_EXPORT static void ViewerInit (Standard_Integer thePxLeft,
|
||||
Standard_Integer thePxTop,
|
||||
Standard_Integer thePxWidth,
|
||||
Standard_Integer thePxHeight);
|
||||
|
||||
Standard_EXPORT static void Factory (Draw_Interpretor& theDI);
|
||||
Standard_EXPORT static void Commands (Draw_Interpretor& theCommands);
|
||||
|
||||
private:
|
||||
Standard_EXPORT static const Handle_MMgt_TShared& WClass();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
244
src/IVtkDraw/IVtkDraw_HighlightAndSelectionPipeline.cxx
Normal file
244
src/IVtkDraw/IVtkDraw_HighlightAndSelectionPipeline.cxx
Normal file
@@ -0,0 +1,244 @@
|
||||
// Created on: 2012-04-02
|
||||
|
||||
// Copyright (c) 2012-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <IVtkDraw_HighlightAndSelectionPipeline.hxx>
|
||||
|
||||
#include <vtkRenderer.h>
|
||||
#include <vtkActor.h>
|
||||
#include <vtkPolyDataMapper.h>
|
||||
#include <vtkPolyData.h>
|
||||
#include <vtkAppendPolyData.h>
|
||||
#include <vtkProperty.h>
|
||||
|
||||
#include <IVtkOCC_Shape.hxx>
|
||||
#include <IVtkTools_DisplayModeFilter.hxx>
|
||||
#include <IVtkTools_ShapeDataSource.hxx>
|
||||
#include <IVtkTools_ShapeObject.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_HANDLE(IVtkDraw_HighlightAndSelectionPipeline, Standard_Transient)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(IVtkDraw_HighlightAndSelectionPipeline, Standard_Transient)
|
||||
|
||||
//===========================================================
|
||||
// Function : Constructor
|
||||
// Purpose :
|
||||
//===========================================================
|
||||
|
||||
IVtkDraw_HighlightAndSelectionPipeline::IVtkDraw_HighlightAndSelectionPipeline (const TopoDS_Shape& theShape,
|
||||
const Standard_Integer theShapeID)
|
||||
: Standard_Transient()
|
||||
{
|
||||
/* ===========================
|
||||
* Allocate involved filters
|
||||
* =========================== */
|
||||
|
||||
myFilterMap.Bind (Filter_DM_Shape, vtkSmartPointer<IVtkTools_DisplayModeFilter>::New());
|
||||
myFilterMap.Bind (Filter_DM_Hili, vtkSmartPointer<IVtkTools_DisplayModeFilter>::New());
|
||||
myFilterMap.Bind (Filter_DM_Sel, vtkSmartPointer<IVtkTools_DisplayModeFilter>::New());
|
||||
myFilterMap.Bind (Filter_SUB_Hili, vtkSmartPointer<IVtkTools_SubPolyDataFilter>::New());
|
||||
myFilterMap.Bind (Filter_SUB_Sel, vtkSmartPointer<IVtkTools_SubPolyDataFilter>::New());
|
||||
|
||||
/* ========================
|
||||
* Build primary pipeline
|
||||
* ======================== */
|
||||
|
||||
myActor = vtkSmartPointer<vtkActor>::New();
|
||||
IVtkOCC_Shape::Handle anIVtkShape = new IVtkOCC_Shape (theShape);
|
||||
anIVtkShape->SetId (theShapeID);
|
||||
vtkSmartPointer<IVtkTools_ShapeDataSource> aDataSource = vtkSmartPointer<IVtkTools_ShapeDataSource>::New();
|
||||
aDataSource->SetShape (IVtkOCC_Shape::Handle::DownCast (anIVtkShape) );
|
||||
|
||||
IVtkTools_DisplayModeFilter*
|
||||
aDMFilter = IVtkTools_DisplayModeFilter::SafeDownCast (myFilterMap.Find(Filter_DM_Shape));
|
||||
|
||||
aDMFilter->AddInputConnection (aDataSource->GetOutputPort());
|
||||
aDMFilter->SetDisplayMode (DM_Wireframe);
|
||||
|
||||
myMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
myMapper->AddInputConnection (aDMFilter->GetOutputPort());
|
||||
myActor->SetMapper (myMapper);
|
||||
IVtkTools_ShapeObject::SetShapeSource (aDataSource, myActor);
|
||||
|
||||
myMapper->ScalarVisibilityOn();
|
||||
myMapper->SetScalarModeToUseCellFieldData();
|
||||
IVtkTools::InitShapeMapper (myMapper);
|
||||
myMapper->Update();
|
||||
|
||||
/* =================================
|
||||
* Build pipeline for highlighting
|
||||
* ================================= */
|
||||
|
||||
IVtkTools_DisplayModeFilter*
|
||||
aDMFilterH = IVtkTools_DisplayModeFilter::SafeDownCast (myFilterMap.Find(Filter_DM_Hili) );
|
||||
IVtkTools_SubPolyDataFilter*
|
||||
aSUBFilterH = IVtkTools_SubPolyDataFilter::SafeDownCast (myFilterMap.Find(Filter_SUB_Hili) );
|
||||
|
||||
// No highligthing exists initially
|
||||
aSUBFilterH->SetInputConnection (aDataSource->GetOutputPort() );
|
||||
aDMFilterH->SetInputConnection (aSUBFilterH->GetOutputPort() );
|
||||
|
||||
myHiliMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
myHiliMapper->SetInputConnection (aDMFilterH->GetOutputPort() );
|
||||
|
||||
// Create non-pickable actor
|
||||
myHiliActor = vtkSmartPointer<vtkActor>::New();
|
||||
myHiliActor->SetPickable(0);
|
||||
myHiliActor->SetVisibility(1);
|
||||
myHiliActor->GetProperty()->SetColor(0, 1, 1);
|
||||
myHiliActor->GetProperty()->SetOpacity(1);
|
||||
myHiliActor->GetProperty()->SetPointSize (myHiliActor->GetProperty()->GetPointSize() + 4 );
|
||||
myHiliActor->GetProperty()->SetLineWidth (myHiliActor->GetProperty()->GetLineWidth() + 2 );
|
||||
|
||||
// Set maper for actor
|
||||
myHiliActor->SetMapper (myHiliMapper);
|
||||
myHiliMapper->ScalarVisibilityOff();
|
||||
|
||||
/* ==============================
|
||||
* Build pipeline for selection
|
||||
* ============================== */
|
||||
|
||||
IVtkTools_DisplayModeFilter*
|
||||
aDMFilterS = IVtkTools_DisplayModeFilter::SafeDownCast (myFilterMap.Find(Filter_DM_Sel) );
|
||||
IVtkTools_SubPolyDataFilter*
|
||||
aSUBFilterS = IVtkTools_SubPolyDataFilter::SafeDownCast (myFilterMap.Find(Filter_SUB_Sel) );
|
||||
|
||||
// No highligthing exists initially
|
||||
aSUBFilterS->SetInputConnection (aDataSource->GetOutputPort() );
|
||||
aDMFilterS->SetInputConnection (aSUBFilterS->GetOutputPort() );
|
||||
|
||||
mySelMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
mySelMapper->SetInputConnection (aDMFilterS->GetOutputPort() );
|
||||
|
||||
// Create non-pickable actor
|
||||
mySelActor = vtkSmartPointer<vtkActor>::New();
|
||||
mySelActor->SetPickable (0);
|
||||
mySelActor->SetVisibility (1);
|
||||
mySelActor->GetProperty()->SetColor (1, 1, 1);
|
||||
mySelActor->GetProperty()->SetOpacity (1);
|
||||
mySelActor->GetProperty()->SetPointSize (myHiliActor->GetProperty()->GetPointSize() + 4 );
|
||||
mySelActor->GetProperty()->SetLineWidth (myHiliActor->GetProperty()->GetLineWidth() + 2 );
|
||||
|
||||
// Set maper for actor
|
||||
mySelActor->SetMapper (mySelMapper);
|
||||
mySelMapper->ScalarVisibilityOff();
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
// Function : AddToRenderer
|
||||
// Purpose :
|
||||
//===========================================================
|
||||
void IVtkDraw_HighlightAndSelectionPipeline::AddToRenderer (vtkRenderer* theRenderer)
|
||||
{
|
||||
theRenderer->AddActor (myActor);
|
||||
theRenderer->AddActor (myHiliActor);
|
||||
theRenderer->AddActor (mySelActor);
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
// Function : RemoveFromRenderer
|
||||
// Purpose :
|
||||
//===========================================================
|
||||
void IVtkDraw_HighlightAndSelectionPipeline::RemoveFromRenderer (vtkRenderer* theRenderer)
|
||||
{
|
||||
theRenderer->RemoveActor (myActor);
|
||||
theRenderer->RemoveActor (myHiliActor);
|
||||
theRenderer->RemoveActor (mySelActor);
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
// Function : ClearHighlightFilters
|
||||
// Purpose :
|
||||
//===========================================================
|
||||
void IVtkDraw_HighlightAndSelectionPipeline::ClearHighlightFilters()
|
||||
{
|
||||
this->GetHighlightFilter()->Clear();
|
||||
this->GetHighlightFilter()->SetDoFiltering (true);
|
||||
this->GetHighlightFilter()->Modified();
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
// Function : ClearSelectionFilters
|
||||
// Purpose :
|
||||
//===========================================================
|
||||
void IVtkDraw_HighlightAndSelectionPipeline::ClearSelectionFilters()
|
||||
{
|
||||
this->GetSelectionFilter()->Clear();
|
||||
this->GetSelectionFilter()->SetDoFiltering (true);
|
||||
this->GetSelectionFilter()->Modified();
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
// Function : GetDisplayModeFilter
|
||||
// Purpose :
|
||||
//===========================================================
|
||||
IVtkTools_DisplayModeFilter* IVtkDraw_HighlightAndSelectionPipeline::GetDisplayModeFilter()
|
||||
{
|
||||
return IVtkTools_DisplayModeFilter::SafeDownCast (myFilterMap.Find(Filter_DM_Shape) );
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
// Function : GetHighlightFilter
|
||||
// Purpose :
|
||||
//===========================================================
|
||||
IVtkTools_SubPolyDataFilter* IVtkDraw_HighlightAndSelectionPipeline::GetHighlightFilter()
|
||||
{
|
||||
return IVtkTools_SubPolyDataFilter::SafeDownCast (myFilterMap.Find (Filter_SUB_Hili) );
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
// Function : GetSelectionFilter
|
||||
// Purpose :
|
||||
//===========================================================
|
||||
IVtkTools_SubPolyDataFilter* IVtkDraw_HighlightAndSelectionPipeline::GetSelectionFilter()
|
||||
{
|
||||
return IVtkTools_SubPolyDataFilter::SafeDownCast (myFilterMap.Find (Filter_SUB_Sel) );
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
// Function : GetHighlightDMFilter
|
||||
// Purpose :
|
||||
//===========================================================
|
||||
IVtkTools_DisplayModeFilter* IVtkDraw_HighlightAndSelectionPipeline::GetHighlightDMFilter()
|
||||
{
|
||||
return IVtkTools_DisplayModeFilter::SafeDownCast (myFilterMap.Find (Filter_DM_Hili) );
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
// Function : GetSelectionDMFilter
|
||||
// Purpose :
|
||||
//===========================================================
|
||||
IVtkTools_DisplayModeFilter* IVtkDraw_HighlightAndSelectionPipeline::GetSelectionDMFilter()
|
||||
{
|
||||
return IVtkTools_DisplayModeFilter::SafeDownCast (myFilterMap.Find(Filter_DM_Sel));
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
// Function : SharedVerticesSelectionOn
|
||||
// Purpose :
|
||||
//===========================================================
|
||||
void IVtkDraw_HighlightAndSelectionPipeline::SharedVerticesSelectionOn()
|
||||
{
|
||||
this->GetHighlightDMFilter()->SetDisplaySharedVertices (Standard_True);
|
||||
this->GetSelectionDMFilter()->SetDisplaySharedVertices (Standard_True);
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
// Function : SharedVerticesSelectionOff
|
||||
// Purpose :
|
||||
//===========================================================
|
||||
void IVtkDraw_HighlightAndSelectionPipeline::SharedVerticesSelectionOff()
|
||||
{
|
||||
this->GetHighlightDMFilter()->SetDisplaySharedVertices (Standard_False);
|
||||
this->GetSelectionDMFilter()->SetDisplaySharedVertices (Standard_False);
|
||||
}
|
128
src/IVtkDraw/IVtkDraw_HighlightAndSelectionPipeline.hxx
Normal file
128
src/IVtkDraw/IVtkDraw_HighlightAndSelectionPipeline.hxx
Normal file
@@ -0,0 +1,128 @@
|
||||
// Created on: 2012-04-02
|
||||
|
||||
// Copyright (c) 2012-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _IVtkDraw_HighlightAndSelectionPipeline_HeaderFile
|
||||
#define _IVtkDraw_HighlightAndSelectionPipeline_HeaderFile
|
||||
|
||||
#ifndef _Standard_HeaderFile
|
||||
#include <Standard.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Macro_HeaderFile
|
||||
#include <Standard_Macro.hxx>
|
||||
#endif
|
||||
#ifndef _Handle_MMgt_TShared_HeaderFile
|
||||
#include <Handle_MMgt_TShared.hxx>
|
||||
#endif
|
||||
|
||||
#include <NCollection_DataMap.hxx>
|
||||
#include <NCollection_Handle.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
#include <vtkActor.h>
|
||||
#include <vtkPolyData.h>
|
||||
#include <vtkPolyDataMapper.h>
|
||||
#include <vtkRenderer.h>
|
||||
#include <vtkSmartPointer.h>
|
||||
|
||||
#include <IVtk_Types.hxx>
|
||||
#include <IVtkTools_DisplayModeFilter.hxx>
|
||||
#include <IVtkTools_SubPolyDataFilter.hxx>
|
||||
|
||||
typedef NCollection_DataMap <IVtk_IdType, vtkSmartPointer<IVtkTools_DisplayModeFilter> > DisplayModeFiltersMap;
|
||||
typedef NCollection_DataMap <IVtk_IdType, vtkSmartPointer<IVtkTools_SubPolyDataFilter> > SubShapesFiltersMap;
|
||||
|
||||
DEFINE_STANDARD_HANDLE(IVtkDraw_HighlightAndSelectionPipeline, Standard_Transient)
|
||||
|
||||
class IVtkDraw_HighlightAndSelectionPipeline : public Standard_Transient
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI(IVtkDraw_HighlightAndSelectionPipeline)
|
||||
|
||||
public:
|
||||
|
||||
//! Filters comprising the pipeline.
|
||||
enum FilterId
|
||||
{
|
||||
Filter_DM_Shape = 1, //!< Display Mode filter for shape.
|
||||
Filter_DM_Hili, //!< Display Mode filter for highlighting.
|
||||
Filter_DM_Sel, //!< Display Mode filter for selection.
|
||||
Filter_SUB_Hili, //!< Sub-shapes filter for highlighting.
|
||||
Filter_SUB_Sel //!< Sub-shapes filter for selection.
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
IVtkDraw_HighlightAndSelectionPipeline (const TopoDS_Shape& theShape,
|
||||
const Standard_Integer theShapeID);
|
||||
~IVtkDraw_HighlightAndSelectionPipeline() {}
|
||||
|
||||
public:
|
||||
|
||||
void AddToRenderer (vtkRenderer* theRenderer);
|
||||
void RemoveFromRenderer (vtkRenderer* theRenderer);
|
||||
|
||||
inline vtkActor* Actor() { return myActor; }
|
||||
inline vtkMapper* Mapper() { return myMapper; }
|
||||
|
||||
void ClearHighlightFilters();
|
||||
void ClearSelectionFilters();
|
||||
|
||||
IVtkTools_DisplayModeFilter* GetDisplayModeFilter();
|
||||
IVtkTools_SubPolyDataFilter* GetHighlightFilter();
|
||||
IVtkTools_SubPolyDataFilter* GetSelectionFilter();
|
||||
IVtkTools_DisplayModeFilter* GetHighlightDMFilter();
|
||||
IVtkTools_DisplayModeFilter* GetSelectionDMFilter();
|
||||
|
||||
void SharedVerticesSelectionOn();
|
||||
void SharedVerticesSelectionOff();
|
||||
|
||||
private:
|
||||
|
||||
//! Auxiliary map of internal filters by their correspondent IDs.
|
||||
typedef NCollection_DataMap <FilterId, vtkSmartPointer<vtkAlgorithm> > FilterMap;
|
||||
|
||||
private:
|
||||
|
||||
//! Actor.
|
||||
vtkSmartPointer<vtkActor> myActor;
|
||||
|
||||
//! Polygonal mapper.
|
||||
vtkSmartPointer<vtkPolyDataMapper> myMapper;
|
||||
|
||||
//! Actor for highlighting.
|
||||
vtkSmartPointer<vtkActor> myHiliActor;
|
||||
|
||||
//! Polygonal mapper for highlighting.
|
||||
vtkSmartPointer<vtkPolyDataMapper> myHiliMapper;
|
||||
|
||||
//! Actor for selection.
|
||||
vtkSmartPointer<vtkActor> mySelActor;
|
||||
|
||||
//! Polygonal mapper for selection.
|
||||
vtkSmartPointer<vtkPolyDataMapper> mySelMapper;
|
||||
|
||||
//! Map of involved VTK filters.
|
||||
FilterMap myFilterMap;
|
||||
|
||||
};
|
||||
|
||||
//! Mapping between OCCT topological shape IDs and their correspondent
|
||||
//! visualization pipelines.
|
||||
typedef NCollection_DataMap<IVtk_IdType, Handle(IVtkDraw_HighlightAndSelectionPipeline)> ShapePipelineMap;
|
||||
typedef NCollection_Handle<ShapePipelineMap> Handle(ShapePipelineMap);
|
||||
|
||||
#endif
|
1014
src/IVtkDraw/IVtkDraw_Interactor.cxx
Normal file
1014
src/IVtkDraw/IVtkDraw_Interactor.cxx
Normal file
File diff suppressed because it is too large
Load Diff
118
src/IVtkDraw/IVtkDraw_Interactor.hxx
Normal file
118
src/IVtkDraw/IVtkDraw_Interactor.hxx
Normal file
@@ -0,0 +1,118 @@
|
||||
// Created on: 2012-05-28
|
||||
//
|
||||
// Copyright (c) 2012-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _IVtkDraw_Interactor_HeaderFile
|
||||
#define _IVtkDraw_Interactor_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <MMgt_TShared.hxx>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Shell.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <tk.h>
|
||||
#endif
|
||||
|
||||
#include <vtkRenderWindowInteractor.h>
|
||||
#include <vtkSmartPointer.h>
|
||||
#include <IVtkTools_ShapePicker.hxx>
|
||||
#include <IVtkDraw_HighlightAndSelectionPipeline.hxx>
|
||||
#include <Aspect_Window.hxx>
|
||||
|
||||
class vtkWin32RenderWindowInteractor;
|
||||
typedef vtkSmartPointer<IVtkTools_ShapePicker> PSelector;
|
||||
|
||||
class IVtkDraw_Interactor : public vtkRenderWindowInteractor
|
||||
{
|
||||
public:
|
||||
static IVtkDraw_Interactor *New();
|
||||
vtkTypeMacro (IVtkDraw_Interactor, vtkRenderWindowInteractor);
|
||||
|
||||
virtual void Initialize();
|
||||
virtual void Enable();
|
||||
virtual void Start() { }
|
||||
|
||||
void SetShapePicker (const PSelector& theSelector);
|
||||
void SetPipelines (const Handle(ShapePipelineMap)& thePipelines);
|
||||
void SetOCCWindow (const Handle(Aspect_Window)& theWindow);
|
||||
const Handle(Aspect_Window)& GetOCCWindow() const;
|
||||
|
||||
//! Process highlighting
|
||||
void MoveTo (Standard_Integer theX, Standard_Integer theY);
|
||||
|
||||
//! Process selection
|
||||
void OnSelection();
|
||||
|
||||
Standard_Boolean IsEnabled() const;
|
||||
|
||||
#ifndef _WIN32
|
||||
Display* GetDisplayId() const;
|
||||
Standard_Integer ViewerMainLoop (Standard_Integer theArgNum, const char** theArgs);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
IVtkDraw_Interactor();
|
||||
IVtkDraw_Interactor (const IVtkDraw_Interactor& );
|
||||
~IVtkDraw_Interactor();
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
friend LRESULT CALLBACK WndProc (HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
friend LRESULT CALLBACK ViewerWindowProc (HWND hwnd,
|
||||
UINT Msg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam,
|
||||
IVtkDraw_Interactor *theInteractor);
|
||||
|
||||
void OnMouseMove (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y);
|
||||
void OnRButtonDown (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y, Standard_Integer repeat=0);
|
||||
void OnRButtonUp (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y);
|
||||
void OnMButtonDown (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y, Standard_Integer repeat=0);
|
||||
void OnMButtonUp (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y);
|
||||
void OnLButtonDown (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y, Standard_Integer repeat=0);
|
||||
void OnLButtonUp (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y);
|
||||
void OnSize (HWND wnd, UINT nType, Standard_Integer X, Standard_Integer Y);
|
||||
void OnTimer (HWND wnd, UINT nIDEvent);
|
||||
void OnMouseWheelForward (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y);
|
||||
void OnMouseWheelBackward (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y);
|
||||
#else
|
||||
static void ProcessEvents (ClientData theData, int);
|
||||
void GetMousePosition (Standard_Integer *theX, Standard_Integer *theY);
|
||||
#endif
|
||||
|
||||
|
||||
private:
|
||||
|
||||
#ifdef _WIN32
|
||||
HWND myWindowId;
|
||||
Standard_Integer myMouseInWindow;
|
||||
#else
|
||||
Window myWindowId;
|
||||
Display *myDisplayId;
|
||||
Standard_Boolean myIsLeftButtonPressed;
|
||||
#endif
|
||||
|
||||
PSelector mySelector;
|
||||
Handle(ShapePipelineMap) myPipelines;
|
||||
Handle(Aspect_Window) myWindow;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user