mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-03 14:10:33 +03:00
Compare commits
40 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6542788b04 | ||
|
b062dc431d | ||
|
29376f7703 | ||
|
448ecf7bd5 | ||
|
9cc449ed6a | ||
|
c6991f13e7 | ||
|
4db6748cc5 | ||
|
158f2931a7 | ||
|
4b59685af1 | ||
|
9e9b826aa1 | ||
|
64e8b010af | ||
|
1b6e8b9f09 | ||
|
b04decfaae | ||
|
79aa9b5cf6 | ||
|
72e6020d50 | ||
|
a87b1b3738 | ||
|
fa8a462827 | ||
|
0ebe5b0a7f | ||
|
39c8dc708f | ||
|
dcc4e908c2 | ||
|
b40cdc2b55 | ||
|
2615c2d705 | ||
|
23fe70ec52 | ||
|
331bcfc0d0 | ||
|
7ff18fb9cc | ||
|
ab9e277f15 | ||
|
0439d1cf44 | ||
|
e1c9a10311 | ||
|
9ad4ff93a0 | ||
|
89fcfe1551 | ||
|
a24a782174 | ||
|
5a2f31c887 | ||
|
67a843c0d4 | ||
|
b9f43ad13b | ||
|
b8a00b410a | ||
|
e00b8ed948 | ||
|
590b3f0416 | ||
|
62fbfa9856 | ||
|
1f9cb9f999 | ||
|
13dd311c9b |
@@ -3,6 +3,7 @@ StdResource
|
||||
SHMessage
|
||||
Textures
|
||||
Shaders
|
||||
XRResources
|
||||
XSMessage
|
||||
XSTEPResource
|
||||
XmlOcafResource
|
||||
|
@@ -222,6 +222,7 @@ n Xw
|
||||
n Cocoa
|
||||
r Textures
|
||||
r Shaders
|
||||
r XRResources
|
||||
t TKMeshVS
|
||||
t TKOpenGl
|
||||
t TKD3DHost
|
||||
|
@@ -187,6 +187,9 @@ proc wokdep:gui:UpdateList {} {
|
||||
if { "$::HAVE_FFMPEG" == "true" } {
|
||||
wokdep:SearchFFmpeg anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs
|
||||
}
|
||||
if { "$::HAVE_OPENVR" == "true" } {
|
||||
wokdep:SearchOpenVR anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs
|
||||
}
|
||||
if { "$::HAVE_TBB" == "true" } {
|
||||
wokdep:SearchTBB anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs
|
||||
}
|
||||
@@ -472,6 +475,8 @@ checkbutton .myFrame.myChecks.myFImageCheck -offvalue "false" -onvalue "true
|
||||
ttk::label .myFrame.myChecks.myFImageLbl -text "Use FreeImage"
|
||||
checkbutton .myFrame.myChecks.myTbbCheck -offvalue "false" -onvalue "true" -variable HAVE_TBB -command wokdep:gui:UpdateList
|
||||
ttk::label .myFrame.myChecks.myTbbLbl -text "Use Intel TBB"
|
||||
checkbutton .myFrame.myChecks.myOpenVrCheck -offvalue "false" -onvalue "true" -variable HAVE_OPENVR -command wokdep:gui:UpdateList
|
||||
ttk::label .myFrame.myChecks.myOpenVrLbl -text "Use OpenVR"
|
||||
if { "$::tcl_platform(os)" != "Darwin" } {
|
||||
checkbutton .myFrame.myChecks.myGlesCheck -offvalue "false" -onvalue "true" -variable HAVE_GLES2 -command wokdep:gui:UpdateList
|
||||
ttk::label .myFrame.myChecks.myGlesLbl -text "Use OpenGL ES"
|
||||
@@ -635,6 +640,8 @@ grid .myFrame.myChecks.myJDKLbl -row $aCheckRowIter -column 13 -sticky w
|
||||
incr aCheckRowIter
|
||||
grid .myFrame.myChecks.myRapidJsonCheck -row $aCheckRowIter -column 0 -sticky e
|
||||
grid .myFrame.myChecks.myRapidJsonLbl -row $aCheckRowIter -column 1 -sticky w
|
||||
grid .myFrame.myChecks.myOpenVrCheck -row $aCheckRowIter -column 4 -sticky e
|
||||
grid .myFrame.myChecks.myOpenVrLbl -row $aCheckRowIter -column 5 -sticky w
|
||||
grid .myFrame.myChecks.myE57Check -row $aCheckRowIter -column 6 -sticky e
|
||||
grid .myFrame.myChecks.myE57Lbl -row $aCheckRowIter -column 7 -sticky w
|
||||
|
||||
|
@@ -68,7 +68,7 @@ if { [info exists ::env(SHORTCUT_HEADERS)] } {
|
||||
}
|
||||
|
||||
# fetch environment variables (e.g. set by custom.sh or custom.bat) and set them as tcl variables with the same name
|
||||
set THE_ENV_VARIABLES {HAVE_FREEIMAGE HAVE_FFMPEG HAVE_TBB HAVE_GLES2 HAVE_D3D HAVE_VTK HAVE_ZLIB HAVE_LIBLZMA HAVE_E57 HAVE_RAPIDJSON HAVE_OPENCL CHECK_QT4 CHECK_JDK MACOSX_USE_GLX HAVE_RelWithDebInfo BUILD_Inspector}
|
||||
set THE_ENV_VARIABLES {HAVE_FREEIMAGE HAVE_FFMPEG HAVE_TBB HAVE_GLES2 HAVE_D3D HAVE_VTK HAVE_ZLIB HAVE_LIBLZMA HAVE_E57 HAVE_RAPIDJSON HAVE_OPENVR HAVE_OPENCL CHECK_QT4 CHECK_JDK MACOSX_USE_GLX HAVE_RelWithDebInfo BUILD_Inspector}
|
||||
foreach anEnvIter $THE_ENV_VARIABLES {
|
||||
set ${anEnvIter} "false"
|
||||
if { [info exists ::env(${anEnvIter})] } {
|
||||
@@ -625,6 +625,59 @@ proc wokdep:SearchFFmpeg {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBi
|
||||
return "$isFound"
|
||||
}
|
||||
|
||||
# Search OpenVR SDK placement
|
||||
proc wokdep:SearchOpenVR {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
|
||||
upvar $theErrInc anErrInc
|
||||
upvar $theErrLib32 anErrLib32
|
||||
upvar $theErrLib64 anErrLib64
|
||||
upvar $theErrBin32 anErrBin32
|
||||
upvar $theErrBin64 anErrBin64
|
||||
|
||||
set isFound "true"
|
||||
set anOpenVrHPath [wokdep:SearchHeader "openvr.h"]
|
||||
if { "$anOpenVrHPath" == "" } {
|
||||
set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{openvr}*] "$::VCVER" "$::ARCH" ]
|
||||
if { "$aPath" != "" && [file exists "$aPath/include/openvr.h"] } {
|
||||
lappend ::CSF_OPT_INC "$aPath/include"
|
||||
} elseif { "$aPath" != "" && [file exists "$aPath/headers/openvr.h"] } {
|
||||
lappend ::CSF_OPT_INC "$aPath/headers"
|
||||
} else {
|
||||
lappend anErrInc "Error: 'openvr.h' not found (OpenVR)"
|
||||
set isFound "false"
|
||||
}
|
||||
}
|
||||
|
||||
set aPlatform "unknown"
|
||||
if { "$::tcl_platform(platform)" == "windows" } {
|
||||
set aPlatform "win"
|
||||
} elseif { "$::tcl_platform(os)" == "Darwin" } {
|
||||
set aPlatform "osx"
|
||||
} elseif { "$::tcl_platform(os)" == "Linux" } {
|
||||
set aPlatform "linux"
|
||||
}
|
||||
|
||||
foreach anArchIter {64 32} {
|
||||
set anOpenVrLibPath [wokdep:SearchLib "openvr_api" "$anArchIter"]
|
||||
if { "$anOpenVrLibPath" == "" } {
|
||||
set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{openvr}*] "$::VCVER" "$anArchIter" ]
|
||||
set anOpenVrLibPath [wokdep:SearchLib "openvr_api" "$anArchIter" "$aPath/lib/${aPlatform}${anArchIter}"]
|
||||
set anOpenVrLibPath2 [wokdep:SearchLib "openvr_api" "$anArchIter" "$aPath/lib"]
|
||||
if { "$anOpenVrLibPath" != "" } {
|
||||
lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/${aPlatform}${anArchIter}"
|
||||
lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin/${aPlatform}${anArchIter}"
|
||||
} elseif { "$anOpenVrLibPath2" != "" } {
|
||||
lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
|
||||
lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
|
||||
} else {
|
||||
lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}openvr_api.${::SYS_LIB_SUFFIX}' not found (OpenVR)"
|
||||
if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "$isFound"
|
||||
}
|
||||
|
||||
# Search TBB library placement
|
||||
proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
|
||||
upvar $theErrInc anErrInc
|
||||
|
@@ -1440,6 +1440,9 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap theRelease} {
|
||||
if { "$::HAVE_LIBLZMA" == "true" } {
|
||||
set aLibsMap(CSF_LIBLZMA) "liblzma"
|
||||
}
|
||||
if { "$::HAVE_OPENVR" == "true" } {
|
||||
set aLibsMap(CSF_OpenVR) "openvr_api"
|
||||
}
|
||||
if { "$::HAVE_E57" == "true" && "$theOS" != "wnt" } {
|
||||
# exclude wnt, as there are different pragma lib depending on debug/release
|
||||
set aLibsMap(CSF_E57) "E57RefImpl"
|
||||
|
@@ -25,6 +25,7 @@ set "HAVE_D3D=false"
|
||||
set "HAVE_ZLIB=false"
|
||||
set "HAVE_LIBLZMA=false"
|
||||
set "HAVE_RAPIDJSON=false"
|
||||
set "HAVE_OPENVR=false"
|
||||
set "HAVE_E57=false"
|
||||
set "CSF_OPT_INC="
|
||||
set "CSF_OPT_LIB32="
|
||||
@@ -189,6 +190,7 @@ if ["%HAVE_D3D%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DH
|
||||
if ["%HAVE_ZLIB%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_ZLIB" & set "CSF_DEFINES=HAVE_ZLIB;%CSF_DEFINES%"
|
||||
if ["%HAVE_LIBLZMA%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_LIBLZMA" & set "CSF_DEFINES=HAVE_LIBLZMA;%CSF_DEFINES%"
|
||||
if ["%HAVE_RAPIDJSON%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_RAPIDJSON" & set "CSF_DEFINES=HAVE_RAPIDJSON;%CSF_DEFINES%"
|
||||
if ["%HAVE_OPENVR%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_OPENVR" & set "CSF_DEFINES=HAVE_OPENVR;%CSF_DEFINES%"
|
||||
if ["%HAVE_E57%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_E57" & set "CSF_DEFINES=HAVE_E57;%CSF_DEFINES%"
|
||||
|
||||
rem Eliminate VS warning
|
||||
|
@@ -16,6 +16,7 @@ export HAVE_GLES2="false";
|
||||
export HAVE_ZLIB="false";
|
||||
export HAVE_LIBLZMA="false";
|
||||
export HAVE_RAPIDJSON="false";
|
||||
export HAVE_OPENVR="false";
|
||||
export HAVE_E57="false";
|
||||
export MACOSX_USE_GLX="false";
|
||||
export CSF_OPT_INC=""
|
||||
@@ -106,6 +107,7 @@ if [ "$HAVE_VTK" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -D
|
||||
if [ "$HAVE_ZLIB" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_ZLIB"; fi
|
||||
if [ "$HAVE_LIBLZMA" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_LIBLZMA"; fi
|
||||
if [ "$HAVE_RAPIDJSON" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_RAPIDJSON"; fi
|
||||
if [ "$HAVE_OPENVR" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_OPENVR"; fi
|
||||
if [ "$HAVE_E57" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_E57"; fi
|
||||
# Option to compile OCCT with X11 libs on Mac OS X
|
||||
if [ "$MACOSX_USE_GLX" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DMACOSX_USE_GLX"; fi
|
||||
|
@@ -1934,3 +1934,48 @@ void BOPTools_AlgoTools::TreatCompound (const TopoDS_Shape& theS,
|
||||
Offset direction, which used in class Adaptor2d_OffsetCurve for evaluating values and derivatives of offset curve is unified for offset direction used in class Geom2d_OffsetCurve: now offset direction points to outer ("right") side of base curve instead of the previously used inner ("left") side. Old usage of class in any application should be changed something like that:
|
||||
|
||||
Adaptor2d_OffsetCurve aOC(BaseCurve, Offset) --> Adaptor2d_OffsetCurve aOC(BaseCurve, -Offset)
|
||||
|
||||
@subsection upgrade_750_message_messenger Message_Messenger interface change
|
||||
|
||||
Operators << with left argument *Handle(Message_Messenger)*, used to output messages with
|
||||
a stream-like interface, have been removed.
|
||||
This functionality is provided now by separate class *Message_Messenger::StreamBuffer*.
|
||||
That class contains a stringstream buffer which can be filled using standard stream
|
||||
operators. The string is sent to a messenger on destruction of the buffer object,
|
||||
call of its method Flush(), or using operator << with one of ostream manipulators
|
||||
(*std::endl, std::flush, std::ends*). Manipulator *Message_EndLine* has been removed,
|
||||
*std::endl* should be used instead.
|
||||
|
||||
New methods *SendFail(), SendAlarm(), SendWarning(), SendInfo()*, and *SendTrace()* are
|
||||
provided in both *Message_Messenger* class and as static functions in *Message* package
|
||||
(short-cuts to default messenger), returning buffer object for the output of
|
||||
corresponding type of the message.
|
||||
|
||||
The code that used operator << for messenger, should be ported as follows.
|
||||
|
||||
Before the change:
|
||||
~~~~~
|
||||
Handle(Message_Messenger) theMessenger = ...;
|
||||
theMessenger << "Value = " << anInteger << Message_EndLine;
|
||||
~~~~~
|
||||
|
||||
After the change, single-line variant:
|
||||
~~~~~
|
||||
Handle(Message_Messenger) theMessenger = ...;
|
||||
theMessenger->SendInfo() << "Value = " << anInteger << std::endl;
|
||||
~~~~~
|
||||
|
||||
After the change, extended variant:
|
||||
~~~~~
|
||||
Handle(Message_Messenger) theMessenger = ...;
|
||||
Message_Messenger::StreamBuffer aSender = theMessenger->SendInfo();
|
||||
aSender << "Array: [ ";
|
||||
for (int i = 0; i < aNb; ++i) { aSender << anArray[i] << " "; }
|
||||
aSender << "]" << std::endl; // aSender can be used further for other messages
|
||||
~~~~~
|
||||
|
||||
@subsection upgrade_750_message_printer Message_Printer interface change
|
||||
|
||||
Previously, sub-classes of *Message_Printer* have to provide a triplet of *Message_Printer::Send()* methods accepting different string representations: TCollection_AsciiString, TCollection_ExtendedString and Standard_CString.
|
||||
*Message_Printer* interface has been changed, so that sub-classes now have to implement only single method *Message_Printer::send()* accepting TCollection_AsciiString argument and having no Endl flag, which has been removed.
|
||||
Old three Message_Printer::Send() methods remain defined virtual with unused last argument and redirecting to new send() method by default.
|
||||
|
@@ -48,27 +48,11 @@ OcctJni_MsgPrinter::~OcctJni_MsgPrinter()
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Send
|
||||
// function : send
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OcctJni_MsgPrinter::Send (const TCollection_ExtendedString& theString,
|
||||
const Message_Gravity theGravity,
|
||||
const Standard_Boolean theToPutEndl) const
|
||||
{
|
||||
if (theGravity >= myTraceLevel)
|
||||
{
|
||||
const TCollection_AsciiString aStr (theString);
|
||||
OcctJni_MsgPrinter::Send (aStr, theGravity, theToPutEndl);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Send
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OcctJni_MsgPrinter::Send (const TCollection_AsciiString& theString,
|
||||
const Message_Gravity theGravity,
|
||||
const Standard_Boolean theToPutEndl) const
|
||||
void OcctJni_MsgPrinter::send (const TCollection_AsciiString& theString,
|
||||
const Message_Gravity theGravity) const
|
||||
{
|
||||
if (theGravity < myTraceLevel)
|
||||
{
|
||||
@@ -85,17 +69,3 @@ void OcctJni_MsgPrinter::Send (const TCollection_AsciiString& theString,
|
||||
myJEnv->CallObjectMethod (myJObj, myJMet, aJStr);
|
||||
myJEnv->DeleteLocalRef (aJStr);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Send
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OcctJni_MsgPrinter::Send (const Standard_CString& theString,
|
||||
const Message_Gravity theGravity,
|
||||
const Standard_Boolean theToPutEndl) const
|
||||
{
|
||||
if (theGravity >= myTraceLevel)
|
||||
{
|
||||
OcctJni_MsgPrinter::Send (TCollection_AsciiString (theString), theGravity, theToPutEndl);
|
||||
}
|
||||
}
|
||||
|
@@ -30,20 +30,11 @@ public:
|
||||
//! Destructor.
|
||||
~OcctJni_MsgPrinter();
|
||||
|
||||
//! Redirection to TCollection_AsciiString method
|
||||
virtual void Send (const TCollection_ExtendedString& theString,
|
||||
const Message_Gravity theGravity,
|
||||
const Standard_Boolean theToPutEndl) const;
|
||||
|
||||
//! Redirection to TCollection_AsciiString method
|
||||
virtual void Send (const Standard_CString& theString,
|
||||
const Message_Gravity theGravity,
|
||||
const Standard_Boolean theToPutEndl) const;
|
||||
protected:
|
||||
|
||||
//! Main printing method
|
||||
virtual void Send (const TCollection_AsciiString& theString,
|
||||
const Message_Gravity theGravity,
|
||||
const Standard_Boolean theToPutEndl) const;
|
||||
virtual void send (const TCollection_AsciiString& theString,
|
||||
const Message_Gravity theGravity) const;
|
||||
|
||||
private:
|
||||
|
||||
|
@@ -11,17 +11,9 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CNSGView
|
||||
|
||||
IMPLEMENT_DYNCREATE(CGeometryView2D, CView)
|
||||
IMPLEMENT_DYNCREATE(CGeometryView2D, OCC_2dView)
|
||||
BEGIN_MESSAGE_MAP(CGeometryView2D, OCC_2dView)
|
||||
//{{AFX_MSG_MAP(CGeometryView2D)
|
||||
ON_WM_LBUTTONDOWN()
|
||||
ON_WM_LBUTTONUP()
|
||||
ON_WM_MBUTTONDOWN()
|
||||
ON_WM_MBUTTONUP()
|
||||
ON_WM_RBUTTONDOWN()
|
||||
ON_WM_RBUTTONUP()
|
||||
ON_WM_MOUSEMOVE()
|
||||
ON_WM_SIZE()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
@@ -36,15 +28,9 @@ CGeometryView2D::~CGeometryView2D()
|
||||
{
|
||||
}
|
||||
|
||||
// CNSGView drawing
|
||||
|
||||
void CGeometryView2D::OnDraw(CDC* /*pDC*/)
|
||||
const Handle(AIS_InteractiveContext)& CGeometryView2D::GetAISContext() const
|
||||
{
|
||||
CGeometryDoc* pDoc = GetDocument();
|
||||
ASSERT_VALID(pDoc);
|
||||
|
||||
if (!myV2dView.IsNull())
|
||||
myV2dView->Update();
|
||||
return ((CGeometryDoc*)m_pDocument)->GetISessionContext();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -71,239 +57,9 @@ CGeometryDoc* CGeometryView2D::GetDocument() // non-debug version is inline
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CNSGView message handlers
|
||||
|
||||
|
||||
|
||||
//=================================================================
|
||||
|
||||
void CGeometryView2D::OnLButtonDown(UINT nFlags, CPoint point)
|
||||
{
|
||||
// save the current mouse coordinate in min
|
||||
myXmin=point.x; myYmin=point.y;
|
||||
myXmax=point.x; myYmax=point.y;
|
||||
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
// Button MB1 down Control :start zomming
|
||||
// SetCursor(AfxGetApp()->LoadStandardCursor());
|
||||
}
|
||||
else // if ( Ctrl )
|
||||
{
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case CurAction2d_Nothing : // start a drag
|
||||
GetDocument()->DragEvent2D(point.x,point.y,-1,myV2dView);
|
||||
break;
|
||||
case CurAction2d_DynamicZooming : // noting
|
||||
break;
|
||||
case CurAction2d_WindowZooming :
|
||||
break;
|
||||
case CurAction2d_DynamicPanning :// noting
|
||||
break;
|
||||
case CurAction2d_GlobalPanning :// noting
|
||||
break;
|
||||
default :
|
||||
throw Standard_Failure(" incompatible Current Mode ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGeometryView2D::OnLButtonUp(UINT nFlags, CPoint point)
|
||||
{
|
||||
// TODO: Add your message handler code here and/or call default
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
return;
|
||||
}
|
||||
else // if ( Ctrl )
|
||||
{
|
||||
const Handle(AIS_InteractiveContext)& aContext = GetDocument()->GetISessionContext();
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case CurAction2d_Nothing :
|
||||
if (point.x == myXmin && point.y == myYmin)
|
||||
{ // no offset between down and up --> selectEvent
|
||||
myXmax=point.x;
|
||||
myYmax=point.y;
|
||||
if (nFlags & MK_SHIFT )
|
||||
GetDocument()->ShiftInputEvent2D(point.x,point.y,myV2dView);
|
||||
else
|
||||
GetDocument()->InputEvent2D (point.x,point.y,myV2dView);
|
||||
} else
|
||||
{
|
||||
drawRectangle (myXmin,myYmin,myXmax,myYmax,aContext,Standard_False);
|
||||
myXmax=point.x;
|
||||
myYmax=point.y;
|
||||
if (nFlags & MK_SHIFT)
|
||||
GetDocument()->ShiftDragEvent2D(point.x,point.y,1,myV2dView);
|
||||
else
|
||||
GetDocument()->DragEvent2D(point.x,point.y,1,myV2dView);
|
||||
}
|
||||
break;
|
||||
case CurAction2d_DynamicZooming :
|
||||
// SetCursor(AfxGetApp()->LoadStandardCursor());
|
||||
myCurrentMode = CurAction2d_Nothing;
|
||||
break;
|
||||
case CurAction2d_WindowZooming :
|
||||
myXmax=point.x; myYmax=point.y;
|
||||
drawRectangle (myXmin,myYmin,myXmax,myYmax,aContext,Standard_False);
|
||||
if ((abs(myXmin-myXmax)>ValZWMin) || (abs(myYmin-myYmax)>ValZWMin))
|
||||
// Test if the zoom window is greater than a minimale window.
|
||||
{
|
||||
// Do the zoom window between Pmin and Pmax
|
||||
myV2dView->WindowFit(myXmin,myYmin,myXmax,myYmax);
|
||||
}
|
||||
myCurrentMode = CurAction2d_Nothing;
|
||||
break;
|
||||
case CurAction2d_DynamicPanning :
|
||||
myCurrentMode = CurAction2d_Nothing;
|
||||
break;
|
||||
case CurAction2d_GlobalPanning :
|
||||
myV2dView->Place(point.x,point.y,myCurZoom);
|
||||
myCurrentMode = CurAction2d_Nothing;
|
||||
break;
|
||||
default :
|
||||
throw Standard_Failure(" incompatible Current Mode ");
|
||||
break;
|
||||
} //switch (myCurrentMode)
|
||||
} // else // if ( Ctrl )
|
||||
|
||||
}
|
||||
|
||||
void CGeometryView2D::OnMButtonDown(UINT nFlags, CPoint /*point*/)
|
||||
{
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
// Button MB2 down Control : panning init
|
||||
// SetCursor(AfxGetApp()->LoadStandardCursor());
|
||||
}
|
||||
}
|
||||
|
||||
void CGeometryView2D::OnMButtonUp(UINT nFlags, CPoint /*point*/)
|
||||
{
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
// Button MB2 up Control : panning stop
|
||||
// SetCursor(AfxGetApp()->LoadStandardCursor());
|
||||
}
|
||||
}
|
||||
|
||||
void CGeometryView2D::OnRButtonDown(UINT nFlags, CPoint point)
|
||||
{
|
||||
// TODO: Add your message handler code here and/or call default
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
// SetCursor(AfxGetApp()->LoadStandardCursor());
|
||||
}
|
||||
else // if ( Ctrl )
|
||||
{
|
||||
GetDocument()->Popup2D(point.x,point.y,myV2dView);
|
||||
}
|
||||
}
|
||||
|
||||
void CGeometryView2D::OnRButtonUp(UINT /*nFlags*/, CPoint point)
|
||||
{
|
||||
OCC_2dView::Popup2D(point.x,point.y);
|
||||
}
|
||||
|
||||
void CGeometryView2D::OnMouseMove(UINT nFlags, CPoint point)
|
||||
{
|
||||
// ============================ LEFT BUTTON =======================
|
||||
if ( nFlags & MK_LBUTTON)
|
||||
{
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
// move with MB1 and Control : on the dynamic zooming
|
||||
// Do the zoom in function of mouse's coordinates
|
||||
myV2dView->Zoom(myXmax,myYmax,point.x,point.y);
|
||||
// save the current mouse coordinate in min
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
}
|
||||
else // if ( Ctrl )
|
||||
{
|
||||
const Handle(AIS_InteractiveContext)& aContext = GetDocument()->GetISessionContext();
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case CurAction2d_Nothing :
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
GetDocument()->DragEvent2D(myXmax,myYmax,0,myV2dView);
|
||||
drawRectangle (myXmin,myYmin,myXmax,myYmax, aContext);
|
||||
break;
|
||||
case CurAction2d_DynamicZooming :
|
||||
myV2dView->Zoom(myXmax,myYmax,point.x,point.y);
|
||||
// save the current mouse coordinate in min \n";
|
||||
myXmax=point.x; myYmax=point.y;
|
||||
break;
|
||||
case CurAction2d_WindowZooming :
|
||||
myXmax = point.x; myYmax = point.y;
|
||||
drawRectangle (myXmin,myYmin,myXmax,myYmax, aContext);
|
||||
break;
|
||||
case CurAction2d_DynamicPanning :
|
||||
myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
|
||||
myXmax = point.x; myYmax = point.y;
|
||||
break;
|
||||
case CurAction2d_GlobalPanning : // nothing
|
||||
break;
|
||||
default :
|
||||
throw Standard_Failure(" incompatible Current Mode ");
|
||||
break;
|
||||
}// switch (myCurrentMode)
|
||||
}// if ( nFlags & MK_CONTROL ) else
|
||||
} else // if ( nFlags & MK_LBUTTON)
|
||||
// ============================ MIDDLE BUTTON =======================
|
||||
if ( nFlags & MK_MBUTTON)
|
||||
{
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
|
||||
myXmax = point.x; myYmax = point.y;
|
||||
|
||||
}
|
||||
} else // if ( nFlags & MK_MBUTTON)
|
||||
// ============================ RIGHT BUTTON =======================
|
||||
if ( nFlags & MK_RBUTTON)
|
||||
{
|
||||
}else //if ( nFlags & MK_RBUTTON)
|
||||
// ============================ NO BUTTON =======================
|
||||
{ // No buttons
|
||||
myXmax = point.x; myYmax = point.y;
|
||||
if (nFlags & MK_SHIFT)
|
||||
GetDocument()->ShiftMoveEvent2D(point.x,point.y,myV2dView);
|
||||
else
|
||||
GetDocument()->MoveEvent2D(point.x,point.y,myV2dView);
|
||||
}
|
||||
}
|
||||
|
||||
void CGeometryView2D::OnSize(UINT nType, int cx, int cy)
|
||||
{
|
||||
OCC_2dView::OnSize (nType, cx, cy);
|
||||
if (!myV2dView.IsNull())
|
||||
{
|
||||
myV2dView->MustBeResized(); // added sro
|
||||
}
|
||||
}
|
||||
|
||||
void CGeometryView2D::OnInitialUpdate()
|
||||
{
|
||||
Handle(WNT_Window) aWNTWindow;
|
||||
aWNTWindow = new WNT_Window(GetSafeHwnd());
|
||||
|
||||
myV2dView = GetDocument()->GetViewer2D()->CreateView();
|
||||
myV2dView->SetWindow(aWNTWindow);
|
||||
myV2dView->SetBackgroundColor(Quantity_NOC_BLACK);
|
||||
|
||||
// initialyse the grids dialogs
|
||||
TheRectangularGridDialog.Create(CRectangularGrid::IDD, NULL);
|
||||
TheCircularGridDialog.Create(CCircularGrid::IDD, NULL);
|
||||
TheRectangularGridDialog.SetViewer (GetDocument()->GetViewer2D());
|
||||
TheCircularGridDialog.SetViewer (GetDocument()->GetViewer2D());
|
||||
|
||||
Standard_Integer w=100 , h=100 ; /* Debug Matrox */
|
||||
aWNTWindow->Size (w,h) ; /* Keeps me unsatisfied (rlb)..... */
|
||||
/* Resize is not supposed to be done on */
|
||||
/* Matrox */
|
||||
/* I suspect another problem elsewhere */
|
||||
::PostMessage ( GetSafeHwnd () , WM_SIZE , SIZE_RESTORED , w + h*65536 ) ;
|
||||
OCC_2dView::OnInitialUpdate();
|
||||
myView->SetBackgroundColor (Quantity_NOC_BLACK);
|
||||
}
|
||||
|
@@ -28,7 +28,6 @@ public:
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
public:
|
||||
virtual void OnDraw(CDC* pDC); // overridden to draw this view
|
||||
virtual void OnInitialUpdate(); // called first time after construct
|
||||
|
||||
// Implementation
|
||||
@@ -39,17 +38,12 @@ public:
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
//! Return interactive context for 2d presentations.
|
||||
virtual const Handle(AIS_InteractiveContext)& GetAISContext() const Standard_OVERRIDE;
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CGeometryView2D)
|
||||
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
|
||||
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
|
||||
afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
|
||||
afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
|
||||
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
|
||||
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
|
||||
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
@@ -128,7 +128,7 @@ void CHLRDoc::FitAll2DViews(Standard_Boolean UpdateViewer)
|
||||
if(pCurrentView->IsKindOf(RUNTIME_CLASS(OCC_2dView)) )
|
||||
{
|
||||
ASSERT_VALID(pCurrentView);
|
||||
((OCC_2dView*)pCurrentView)->GetV2dView()->FitAll();
|
||||
((OCC_2dView*)pCurrentView)->FitAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,23 +8,12 @@
|
||||
#include "resource2d\RectangularGrid.h"
|
||||
#include "resource2d\CircularGrid.h"
|
||||
|
||||
#define ValZWMin 1
|
||||
|
||||
#ifdef _DEBUG
|
||||
//#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
// the key for multi selection :
|
||||
#define MULTISELECTIONKEY MK_SHIFT
|
||||
|
||||
// the key for shortcut ( use to activate dynamic rotation, panning )
|
||||
#define CASCADESHORTCUTKEY MK_CONTROL
|
||||
|
||||
// define in witch case you want to display the popup
|
||||
#define POPUPONBUTTONDOWN
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CHLRView2D
|
||||
|
||||
@@ -32,7 +21,6 @@ IMPLEMENT_DYNCREATE(CHLRView2D, OCC_2dView)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CHLRView2D, OCC_2dView)
|
||||
//{{AFX_MSG_MAP(CHLRView2D)
|
||||
ON_WM_MOUSEMOVE()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
@@ -41,170 +29,26 @@ END_MESSAGE_MAP()
|
||||
|
||||
CHLRView2D::CHLRView2D()
|
||||
{
|
||||
/// TODO
|
||||
/// Override MouseMove event to exclude rectangle selection emulation as
|
||||
/// no selection is supported in DragEvent2D for this view.
|
||||
}
|
||||
|
||||
CHLRView2D::~CHLRView2D()
|
||||
{
|
||||
}
|
||||
|
||||
const Handle(AIS_InteractiveContext)& CHLRView2D::GetAISContext() const
|
||||
{
|
||||
return ((CHLRDoc*)m_pDocument)->GetInteractiveContext2D();
|
||||
}
|
||||
|
||||
CHLRDoc* CHLRView2D::GetDocument() // non-debug version is inline
|
||||
{
|
||||
//ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(OCC_2dDoc)));
|
||||
return (CHLRDoc*)m_pDocument;
|
||||
}
|
||||
|
||||
|
||||
void CHLRView2D::OnInitialUpdate()
|
||||
{
|
||||
Handle(WNT_Window) aWNTWindow;
|
||||
aWNTWindow = new WNT_Window(GetSafeHwnd(),Quantity_NOC_GRAY);
|
||||
myV2dView = GetDocument()->GetViewer2D()->CreateView();
|
||||
myV2dView->SetWindow(aWNTWindow);
|
||||
|
||||
// initialyse the grids dialogs
|
||||
TheRectangularGridDialog.Create(CRectangularGrid::IDD, NULL);
|
||||
TheCircularGridDialog.Create(CCircularGrid::IDD, NULL);
|
||||
TheRectangularGridDialog.SetViewer (GetDocument()->GetViewer2D());
|
||||
TheCircularGridDialog.SetViewer (GetDocument()->GetViewer2D());
|
||||
|
||||
Standard_Integer w=100 , h=100 ; /* Debug Matrox */
|
||||
aWNTWindow->Size (w,h) ; /* Keeps me unsatisfied (rlb)..... */
|
||||
/* Resize is not supposed to be done on */
|
||||
/* Matrox */
|
||||
/* I suspect another problem elsewhere */
|
||||
::PostMessage ( GetSafeHwnd () , WM_SIZE , SIZE_RESTORED , w + h*65536 ) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void CHLRView2D::DragEvent2D(const Standard_Integer /*x*/,
|
||||
const Standard_Integer /*y*/,
|
||||
const Standard_Integer /*TheState*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void CHLRView2D::InputEvent2D(const Standard_Integer /*x*/,
|
||||
const Standard_Integer /*y*/)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void CHLRView2D::MoveEvent2D(const Standard_Integer /*x*/,
|
||||
const Standard_Integer /*y*/)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void CHLRView2D::MultiMoveEvent2D(const Standard_Integer /*x*/,
|
||||
const Standard_Integer /*y*/)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void CHLRView2D::MultiDragEvent2D(const Standard_Integer /*x*/,
|
||||
const Standard_Integer /*y*/,
|
||||
const Standard_Integer /*TheState*/)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void CHLRView2D::MultiInputEvent2D(const Standard_Integer /*x*/,
|
||||
const Standard_Integer /*y*/)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void CHLRView2D::OnMouseMove(UINT nFlags, CPoint point)
|
||||
{
|
||||
if ( (nFlags & MK_LBUTTON) &! (nFlags & MK_RBUTTON) ) // Left + Right is specific
|
||||
{
|
||||
if ( nFlags & CASCADESHORTCUTKEY )
|
||||
{
|
||||
// move with MB1 and CASCADESHORTCUTKEY : on the dynamic zooming
|
||||
// Do the zoom in function of mouse's coordinates
|
||||
myV2dView->Zoom(myXmax,myYmax,point.x,point.y);
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
}
|
||||
else // if ( CASCADESHORTCUTKEY )
|
||||
{
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case CurAction2d_Nothing :
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
DragEvent2D(myXmax,myYmax,0);
|
||||
break;
|
||||
case CurAction2d_DynamicZooming :
|
||||
myV2dView->Zoom(myXmax,myYmax,point.x,point.y);
|
||||
myXmax=point.x;
|
||||
myYmax=point.y;
|
||||
break;
|
||||
case CurAction2d_WindowZooming :
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
break;
|
||||
case CurAction2d_DynamicPanning :
|
||||
myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
break;
|
||||
case CurAction2d_GlobalPanning :
|
||||
break;
|
||||
default :
|
||||
throw Standard_Failure(" incompatible Current Mode ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if ( nFlags & MK_MBUTTON)
|
||||
{
|
||||
if ( nFlags & CASCADESHORTCUTKEY )
|
||||
{
|
||||
myV2dView->Pan (point.x-myXmax,myYmax-point.y);
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
}
|
||||
} else if ( (nFlags & MK_RBUTTON) &! (nFlags & MK_LBUTTON) )
|
||||
{
|
||||
}
|
||||
else if ( (nFlags & MK_RBUTTON) && (nFlags & MK_LBUTTON) )
|
||||
{
|
||||
if ( nFlags & CASCADESHORTCUTKEY )
|
||||
{
|
||||
myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
|
||||
myXmax = point.x; myYmax = point.y;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // No buttons
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
if (nFlags & MULTISELECTIONKEY)
|
||||
{
|
||||
MultiMoveEvent2D(point.x,point.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveEvent2D(point.x,point.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CHLRView2D::AssertValid() const
|
||||
{
|
||||
|
@@ -20,37 +20,15 @@ class CHLRView2D : public OCC_2dView
|
||||
protected: // create from serialization only
|
||||
CHLRView2D();
|
||||
DECLARE_DYNCREATE(CHLRView2D)
|
||||
|
||||
// Override MouseMove event to exclude rectangle selection emulation as
|
||||
// no selection is supported in DragEvent2D for this view.
|
||||
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CHLRView2D)
|
||||
protected:
|
||||
virtual void OnInitialUpdate(); // called first time after construct
|
||||
//}}AFX_VIRTUAL
|
||||
//! Return interactive context for HLR presentations.
|
||||
virtual const Handle(AIS_InteractiveContext)& GetAISContext() const Standard_OVERRIDE;
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CHLRView2D();
|
||||
CHLRDoc* GetDocument();
|
||||
virtual void DragEvent2D (const Standard_Integer x,
|
||||
const Standard_Integer y,
|
||||
const Standard_Integer TheState);
|
||||
virtual void InputEvent2D (const Standard_Integer x,
|
||||
const Standard_Integer y);
|
||||
virtual void MoveEvent2D (const Standard_Integer x,
|
||||
const Standard_Integer y );
|
||||
virtual void MultiMoveEvent2D (const Standard_Integer x,
|
||||
const Standard_Integer y );
|
||||
virtual void MultiDragEvent2D (const Standard_Integer x,
|
||||
const Standard_Integer y ,
|
||||
const Standard_Integer TheState);
|
||||
virtual void MultiInputEvent2D (const Standard_Integer x,
|
||||
const Standard_Integer y );
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
|
@@ -18,8 +18,7 @@ IMPLEMENT_DYNCREATE(OCC_2dDoc, CDocument)
|
||||
OCC_2dDoc::OCC_2dDoc() : OCC_BaseDoc()
|
||||
{
|
||||
// Get the Graphic Driver from the application
|
||||
Handle(Graphic3d_GraphicDriver) aGraphicDriver =
|
||||
((OCC_App*)AfxGetApp())->GetGraphicDriver();
|
||||
Handle(Graphic3d_GraphicDriver) aGraphicDriver = ((OCC_App*)AfxGetApp())->GetGraphicDriver();
|
||||
|
||||
// create the Viewer
|
||||
myViewer = new V3d_Viewer (aGraphicDriver);
|
||||
@@ -52,20 +51,23 @@ void OCC_2dDoc::FitAll2DViews(Standard_Boolean theUpdateViewer)
|
||||
{
|
||||
OCC_2dView* aCurrentView = (OCC_2dView*)GetNextView (aPosition);
|
||||
ASSERT_VALID (aCurrentView);
|
||||
aCurrentView->GetV2dView()->FitAll();
|
||||
aCurrentView->GetView()->FitAll();
|
||||
}
|
||||
}
|
||||
|
||||
void OCC_2dDoc::MoveEvent(const Standard_Integer theMouseX,
|
||||
const Standard_Integer theMouseY,
|
||||
const Handle(V3d_View)& theView)
|
||||
void OCC_2dDoc::Popup (const Standard_Integer theMouseX,
|
||||
const Standard_Integer theMouseY,
|
||||
const Handle(V3d_View)& theView)
|
||||
{
|
||||
myAISContext->MoveTo (theMouseX, theMouseY, theView, Standard_True);
|
||||
}
|
||||
// load the 'normal' popup
|
||||
CMenu aMenu;
|
||||
VERIFY(aMenu.LoadMenu(IDR_Popup2D));
|
||||
// activate the sub menu '0'
|
||||
CMenu* aPopup = aMenu.GetSubMenu(0);
|
||||
ASSERT(aPopup != NULL);
|
||||
|
||||
void OCC_2dDoc::ShiftMoveEvent(const Standard_Integer theMouseX,
|
||||
const Standard_Integer theMouseY,
|
||||
const Handle(V3d_View)& theView)
|
||||
{
|
||||
myAISContext->MoveTo (theMouseX, theMouseY, theView, Standard_True);
|
||||
// display the popup
|
||||
POINT aWinCoord = { theMouseX, theMouseY };
|
||||
ClientToScreen ((HWND )theView->Window()->NativeHandle(), &aWinCoord);
|
||||
aPopup->TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON, aWinCoord.x, aWinCoord.y, AfxGetMainWnd());
|
||||
}
|
||||
|
@@ -28,23 +28,11 @@ public: // New operations
|
||||
|
||||
void FitAll2DViews(Standard_Boolean theUpdateViewer = Standard_False);
|
||||
|
||||
public: // getters
|
||||
|
||||
Handle(V3d_Viewer) GetViewer2D () { return myViewer; };
|
||||
|
||||
Handle(AIS_InteractiveContext)& GetInteractiveContext() { return myAISContext; };
|
||||
|
||||
public: // Operations to override
|
||||
|
||||
// Mouse move event tracking for 2D view : no rotation is supported in 2D view.
|
||||
virtual void MoveEvent(const Standard_Integer theMouseX,
|
||||
const Standard_Integer theMouseY,
|
||||
const Handle(V3d_View)& theView);
|
||||
|
||||
// Shift move event tracking for 2D view : no rotation is supported in 2D view.
|
||||
virtual void ShiftMoveEvent(const Standard_Integer theMouseX,
|
||||
const Standard_Integer theMouseY,
|
||||
const Handle(V3d_View)& theViewView);
|
||||
virtual void Popup (const Standard_Integer theMouseX,
|
||||
const Standard_Integer theMouseY,
|
||||
const Handle(V3d_View)& theView) Standard_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_OCC_2dDOC_H__2E048CC7_38F9_11D7_8611_0060B0EE281E__INCLUDED_)
|
||||
|
@@ -13,53 +13,35 @@
|
||||
#include "Quantity_Color.hxx"
|
||||
#include "Quantity_NameOfColor.hxx"
|
||||
|
||||
#define ValZWMin 1
|
||||
|
||||
// the key for multi selection :
|
||||
#define MULTISELECTIONKEY MK_SHIFT
|
||||
|
||||
// the key for shortcut ( use to activate dynamic rotation, panning )
|
||||
#define CASCADESHORTCUTKEY MK_CONTROL
|
||||
|
||||
// define in witch case you want to display the popup
|
||||
#define POPUPONBUTTONDOWN
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// OCC_2dView
|
||||
|
||||
IMPLEMENT_DYNCREATE(OCC_2dView, CView)
|
||||
IMPLEMENT_DYNCREATE(OCC_2dView, OCC_BaseView)
|
||||
|
||||
BEGIN_MESSAGE_MAP(OCC_2dView, CView)
|
||||
BEGIN_MESSAGE_MAP(OCC_2dView, OCC_BaseView)
|
||||
//{{AFX_MSG_MAP(OCC_2dView)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code!
|
||||
ON_COMMAND(ID_FILE_EXPORT_IMAGE, OnFileExportImage)
|
||||
ON_COMMAND(ID_BUTTON2DGridRectLines, OnBUTTONGridRectLines)
|
||||
ON_COMMAND(ID_BUTTON2DGridRectPoints, OnBUTTONGridRectPoints)
|
||||
ON_COMMAND(ID_BUTTON2DGridCircLines, OnBUTTONGridCircLines)
|
||||
ON_COMMAND(ID_BUTTON2DGridCircPoints, OnBUTTONGridCircPoints)
|
||||
ON_COMMAND(ID_BUTTON2DGridValues, OnBUTTONGridValues)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTON2DGridValues, OnUpdateBUTTONGridValues)
|
||||
ON_COMMAND(ID_BUTTON2DGridCancel, OnBUTTONGridCancel)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTON2DGridCancel, OnUpdateBUTTONGridCancel)
|
||||
ON_WM_LBUTTONDOWN()
|
||||
ON_WM_LBUTTONUP()
|
||||
ON_WM_MBUTTONDOWN()
|
||||
ON_WM_MBUTTONUP()
|
||||
ON_WM_RBUTTONDOWN()
|
||||
ON_WM_RBUTTONUP()
|
||||
ON_WM_MOUSEMOVE()
|
||||
ON_WM_SIZE()
|
||||
ON_COMMAND(ID_BUTTON2DFitAll, OnBUTTONFitAll)
|
||||
ON_COMMAND(ID_BUTTON2DGlobPanning, OnBUTTONGlobPanning)
|
||||
ON_COMMAND(ID_BUTTON2DPanning, OnBUTTONPanning)
|
||||
ON_COMMAND(ID_BUTTON2DZoomProg, OnBUTTONZoomProg)
|
||||
ON_COMMAND(ID_BUTTON2DZoomWin, OnBUTTONZoomWin)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTON2DGlobPanning, OnUpdateBUTTON2DGlobPanning)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTON2DPanning, OnUpdateBUTTON2DPanning)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTON2DZoomProg, OnUpdateBUTTON2DZoomProg)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTON2DZoomWin, OnUpdateBUTTON2DZoomWin)
|
||||
ON_COMMAND(ID_Modify_ChangeBackground ,OnChangeBackground)
|
||||
ON_COMMAND(ID_FILE_EXPORT_IMAGE, OnFileExportImage)
|
||||
ON_COMMAND(ID_BUTTON2DGridRectLines, OnBUTTONGridRectLines)
|
||||
ON_COMMAND(ID_BUTTON2DGridRectPoints, OnBUTTONGridRectPoints)
|
||||
ON_COMMAND(ID_BUTTON2DGridCircLines, OnBUTTONGridCircLines)
|
||||
ON_COMMAND(ID_BUTTON2DGridCircPoints, OnBUTTONGridCircPoints)
|
||||
ON_COMMAND(ID_BUTTON2DGridValues, OnBUTTONGridValues)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTON2DGridValues, OnUpdateBUTTONGridValues)
|
||||
ON_COMMAND(ID_BUTTON2DGridCancel, OnBUTTONGridCancel)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTON2DGridCancel, OnUpdateBUTTONGridCancel)
|
||||
ON_WM_SIZE()
|
||||
ON_COMMAND(ID_BUTTON2DFitAll, OnBUTTONFitAll)
|
||||
ON_COMMAND(ID_BUTTON2DGlobPanning, OnBUTTONGlobPanning)
|
||||
ON_COMMAND(ID_BUTTON2DPanning, OnBUTTONPanning)
|
||||
ON_COMMAND(ID_BUTTON2DZoomProg, OnBUTTONZoomProg)
|
||||
ON_COMMAND(ID_BUTTON2DZoomWin, OnBUTTONZoomWin)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTON2DGlobPanning, OnUpdateBUTTON2DGlobPanning)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTON2DPanning, OnUpdateBUTTON2DPanning)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTON2DZoomProg, OnUpdateBUTTON2DZoomProg)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTON2DZoomWin, OnUpdateBUTTON2DZoomWin)
|
||||
ON_COMMAND(ID_Modify_ChangeBackground ,OnChangeBackground)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
@@ -67,57 +49,34 @@ END_MESSAGE_MAP()
|
||||
// OCC_2dView construction/destruction
|
||||
|
||||
OCC_2dView::OCC_2dView()
|
||||
: myCurrentMode (CurAction2d_Nothing)
|
||||
{
|
||||
myToAllowRotation = false;
|
||||
myDefaultGestures.Bind (Aspect_VKeyMouse_LeftButton, AIS_MouseGesture_SelectRectangle);
|
||||
myMouseGestureMap = myDefaultGestures;
|
||||
}
|
||||
|
||||
OCC_2dView::~OCC_2dView()
|
||||
{
|
||||
myV2dView->Remove();
|
||||
}
|
||||
|
||||
BOOL OCC_2dView::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
// TODO: Modify the Window class or styles here by modifying
|
||||
// the CREATESTRUCT cs
|
||||
cs.lpszClass = ::AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC, ::LoadCursor(NULL, IDC_ARROW), NULL, NULL);
|
||||
return CView::PreCreateWindow(cs);
|
||||
//
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// OCC_2dView drawing
|
||||
|
||||
void OCC_2dView::OnDraw(CDC* /*pDC*/)
|
||||
{
|
||||
if (!myV2dView.IsNull())
|
||||
myV2dView->Update();
|
||||
}
|
||||
|
||||
void OCC_2dView::OnInitialUpdate()
|
||||
{
|
||||
CView::OnInitialUpdate();
|
||||
OCC_BaseView::OnInitialUpdate();
|
||||
|
||||
Handle(WNT_Window) aWNTWindow = new WNT_Window(GetSafeHwnd(),Quantity_NOC_MATRAGRAY);
|
||||
myV2dView =((OCC_2dDoc*)GetDocument())->GetViewer2D()->CreateView();
|
||||
myV2dView->SetWindow(aWNTWindow);
|
||||
// initialize the grids dialogs
|
||||
TheRectangularGridDialog.Create(CRectangularGrid::IDD, NULL);
|
||||
TheCircularGridDialog.Create(CCircularGrid::IDD, NULL);
|
||||
TheRectangularGridDialog.SetViewer (((OCC_2dDoc*)GetDocument())->GetViewer2D());
|
||||
TheCircularGridDialog.SetViewer (((OCC_2dDoc*)GetDocument())->GetViewer2D());
|
||||
|
||||
Standard_Integer w=100 , h=100 ; /* Debug Matrox */
|
||||
aWNTWindow->Size (w,h) ; /* Keeps me unsatisfied (rlb)..... */
|
||||
/* Resize is not supposed to be done on */
|
||||
/* Matrox */
|
||||
/* I suspect another problem elsewhere */
|
||||
::PostMessage ( GetSafeHwnd () , WM_SIZE , SIZE_RESTORED , w + h*65536 ) ;
|
||||
|
||||
TheRectangularGridDialog.SetViewer (myView->Viewer());
|
||||
TheCircularGridDialog.SetViewer (myView->Viewer());
|
||||
}
|
||||
|
||||
void OCC_2dView::OnFileExportImage()
|
||||
{
|
||||
GetDocument()->ExportView (myV2dView);
|
||||
GetDocument()->ExportView (myView);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -142,11 +101,11 @@ OCC_2dDoc* OCC_2dView::GetDocument() // non-debug version is inline
|
||||
#endif //_DEBUG
|
||||
void OCC_2dView::OnBUTTONGridRectLines()
|
||||
{
|
||||
Handle(V3d_Viewer) aViewer = myV2dView->Viewer();
|
||||
Handle(V3d_Viewer) aViewer = myView->Viewer();
|
||||
Handle(Graphic3d_AspectMarker3d) aGridAspect = new Graphic3d_AspectMarker3d(Aspect_TOM_RING1,Quantity_NOC_WHITE,2);
|
||||
aViewer->SetGridEcho(aGridAspect);
|
||||
Standard_Integer aWidth=0, aHeight=0, anOffset=0;
|
||||
myV2dView->Window()->Size(aWidth,aHeight);
|
||||
myView->Window()->Size(aWidth,aHeight);
|
||||
aViewer->SetRectangularGridGraphicValues(aWidth,aHeight,anOffset);
|
||||
aViewer->ActivateGrid(Aspect_GT_Rectangular, Aspect_GDM_Lines);
|
||||
FitAll();
|
||||
@@ -161,11 +120,11 @@ void OCC_2dView::OnBUTTONGridRectLines()
|
||||
|
||||
void OCC_2dView::OnBUTTONGridRectPoints()
|
||||
{
|
||||
Handle(V3d_Viewer) aViewer = myV2dView->Viewer();
|
||||
Handle(V3d_Viewer) aViewer = myView->Viewer();
|
||||
Handle(Graphic3d_AspectMarker3d) aGridAspect = new Graphic3d_AspectMarker3d(Aspect_TOM_RING1,Quantity_NOC_WHITE,2);
|
||||
aViewer->SetGridEcho(aGridAspect);
|
||||
Standard_Integer aWidth=0, aHeight=0, anOffset=0;
|
||||
myV2dView->Window()->Size(aWidth,aHeight);
|
||||
myView->Window()->Size(aWidth,aHeight);
|
||||
aViewer->SetRectangularGridGraphicValues(aWidth,aHeight,anOffset);
|
||||
aViewer->ActivateGrid(Aspect_GT_Rectangular, Aspect_GDM_Points);
|
||||
FitAll();
|
||||
@@ -180,11 +139,11 @@ void OCC_2dView::OnBUTTONGridRectPoints()
|
||||
|
||||
void OCC_2dView::OnBUTTONGridCircLines()
|
||||
{
|
||||
Handle(V3d_Viewer) aViewer = myV2dView->Viewer();
|
||||
Handle(V3d_Viewer) aViewer = myView->Viewer();
|
||||
Handle(Graphic3d_AspectMarker3d) aGridAspect = new Graphic3d_AspectMarker3d(Aspect_TOM_RING1,Quantity_NOC_WHITE,2);
|
||||
aViewer->SetGridEcho(aGridAspect);
|
||||
Standard_Integer aWidth=0, aHeight=0, anOffset=0;
|
||||
myV2dView->Window()->Size(aWidth,aHeight);
|
||||
myView->Window()->Size(aWidth,aHeight);
|
||||
aViewer->SetCircularGridGraphicValues(aWidth>aHeight?aWidth:aHeight,anOffset);
|
||||
aViewer->ActivateGrid(Aspect_GT_Circular, Aspect_GDM_Lines);
|
||||
FitAll();
|
||||
@@ -200,11 +159,11 @@ void OCC_2dView::OnBUTTONGridCircLines()
|
||||
|
||||
void OCC_2dView::OnBUTTONGridCircPoints()
|
||||
{
|
||||
Handle(V3d_Viewer) aViewer = myV2dView->Viewer();
|
||||
Handle(V3d_Viewer) aViewer = myView->Viewer();
|
||||
Handle(Graphic3d_AspectMarker3d) aGridAspect = new Graphic3d_AspectMarker3d(Aspect_TOM_RING1,Quantity_NOC_WHITE,2);
|
||||
aViewer->SetGridEcho(aGridAspect);
|
||||
Standard_Integer aWidth=0, aHeight=0, anOffset=0;
|
||||
myV2dView->Window()->Size(aWidth,aHeight);
|
||||
myView->Window()->Size(aWidth,aHeight);
|
||||
aViewer->SetCircularGridGraphicValues(aWidth>aHeight?aWidth:aHeight,anOffset);
|
||||
aViewer->ActivateGrid(Aspect_GT_Circular, Aspect_GDM_Points);
|
||||
FitAll();
|
||||
@@ -218,7 +177,7 @@ void OCC_2dView::OnBUTTONGridCircPoints()
|
||||
|
||||
void OCC_2dView::OnBUTTONGridValues()
|
||||
{
|
||||
Handle(V3d_Viewer) aViewer = myV2dView->Viewer();
|
||||
Handle(V3d_Viewer) aViewer = myView->Viewer();
|
||||
Aspect_GridType TheGridtype = aViewer->GridType();
|
||||
|
||||
switch( TheGridtype )
|
||||
@@ -237,13 +196,13 @@ void OCC_2dView::OnBUTTONGridValues()
|
||||
}
|
||||
void OCC_2dView::OnUpdateBUTTONGridValues(CCmdUI* pCmdUI)
|
||||
{
|
||||
Handle(V3d_Viewer) aViewer = myV2dView->Viewer();
|
||||
Handle(V3d_Viewer) aViewer = myView->Viewer();
|
||||
pCmdUI-> Enable( aViewer->IsActive() );
|
||||
}
|
||||
|
||||
void OCC_2dView::OnBUTTONGridCancel()
|
||||
{
|
||||
Handle(V3d_Viewer) aViewer = myV2dView->Viewer();
|
||||
Handle(V3d_Viewer) aViewer = myView->Viewer();
|
||||
aViewer->DeactivateGrid();
|
||||
TheRectangularGridDialog.ShowWindow(SW_HIDE);
|
||||
TheCircularGridDialog.ShowWindow(SW_HIDE);
|
||||
@@ -251,266 +210,50 @@ void OCC_2dView::OnBUTTONGridCancel()
|
||||
}
|
||||
void OCC_2dView::OnUpdateBUTTONGridCancel(CCmdUI* pCmdUI)
|
||||
{
|
||||
Handle(V3d_Viewer) aViewer = myV2dView->Viewer();
|
||||
Handle(V3d_Viewer) aViewer = myView->Viewer();
|
||||
pCmdUI-> Enable( aViewer->IsActive() );
|
||||
}
|
||||
|
||||
void OCC_2dView::OnLButtonDown(UINT nFlags, CPoint point)
|
||||
{
|
||||
// save the current mouse coordinate in min
|
||||
myXmin=point.x; myYmin=point.y;
|
||||
myXmax=point.x; myYmax=point.y;
|
||||
|
||||
if ( nFlags & CASCADESHORTCUTKEY )
|
||||
{
|
||||
// Button MB1 down Control :start zomming
|
||||
//
|
||||
}
|
||||
else // if ( MULTISELECTIONKEY )
|
||||
{
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case CurAction2d_Nothing : // start a drag
|
||||
DragEvent2D(point.x,point.y,-1);
|
||||
break;
|
||||
case CurAction2d_DynamicZooming : // nothing
|
||||
break;
|
||||
case CurAction2d_WindowZooming : // nothing
|
||||
break;
|
||||
case CurAction2d_DynamicPanning :// nothing
|
||||
break;
|
||||
case CurAction2d_GlobalPanning :// nothing
|
||||
break;
|
||||
default :
|
||||
throw Standard_Failure(" incompatible Current Mode ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OCC_2dView::OnLButtonUp(UINT nFlags, CPoint point)
|
||||
{
|
||||
// TODO: Add your message handler code here and/or call default
|
||||
if ( nFlags & CASCADESHORTCUTKEY )
|
||||
{
|
||||
return;
|
||||
}
|
||||
else // if ( Ctrl )
|
||||
{
|
||||
const Handle(AIS_InteractiveContext)& aContext = GetDocument()->GetAISContext();
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case CurAction2d_Nothing :
|
||||
if (point.x == myXmin && point.y == myYmin)
|
||||
{ // no offset between down and up --> selectEvent
|
||||
myXmax=point.x;
|
||||
myYmax=point.y;
|
||||
if (nFlags & MULTISELECTIONKEY )
|
||||
MultiInputEvent2D(point.x,point.y);
|
||||
else
|
||||
InputEvent2D (point.x,point.y);
|
||||
} else
|
||||
{
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext, Standard_False);
|
||||
myXmax=point.x;
|
||||
myYmax=point.y;
|
||||
if (nFlags & MULTISELECTIONKEY)
|
||||
MultiDragEvent2D(point.x,point.y,1);
|
||||
else
|
||||
DragEvent2D(point.x,point.y,1);
|
||||
}
|
||||
break;
|
||||
case CurAction2d_DynamicZooming :
|
||||
//
|
||||
myCurrentMode = CurAction2d_Nothing;
|
||||
break;
|
||||
case CurAction2d_WindowZooming :
|
||||
myXmax=point.x; myYmax=point.y;
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext, Standard_False);
|
||||
if ((abs(myXmin-myXmax)>ValZWMin) || (abs(myYmin-myYmax)>ValZWMin))
|
||||
// Test if the zoom window is greater than a minimale window.
|
||||
{
|
||||
// Do the zoom window between Pmin and Pmax
|
||||
myV2dView->WindowFit(myXmin,myYmin,myXmax,myYmax);
|
||||
}
|
||||
myCurrentMode = CurAction2d_Nothing;
|
||||
break;
|
||||
case CurAction2d_DynamicPanning :
|
||||
myCurrentMode = CurAction2d_Nothing;
|
||||
break;
|
||||
case CurAction2d_GlobalPanning :
|
||||
myV2dView->Place(point.x,point.y,myCurZoom);
|
||||
myCurrentMode = CurAction2d_Nothing;
|
||||
break;
|
||||
default :
|
||||
throw Standard_Failure(" incompatible Current Mode ");
|
||||
break;
|
||||
} //switch (myCurrentMode)
|
||||
} // else // if ( CASCADESHORTCUTKEY )
|
||||
}
|
||||
|
||||
void OCC_2dView::OnMButtonDown(UINT nFlags, CPoint /*point*/)
|
||||
{
|
||||
if ( nFlags & CASCADESHORTCUTKEY )
|
||||
{
|
||||
// Button MB2 down + CASCADESHORTCUTKEY : panning init
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
void OCC_2dView::OnMButtonUp(UINT nFlags, CPoint /*point*/)
|
||||
{
|
||||
if ( nFlags & CASCADESHORTCUTKEY )
|
||||
{
|
||||
// Button MB2 up + CASCADESHORTCUTKEY : panning stop
|
||||
}
|
||||
}
|
||||
|
||||
void OCC_2dView::OnRButtonDown(UINT nFlags, CPoint point)
|
||||
{
|
||||
#ifdef POPUPONBUTTONDOWN
|
||||
if ( !(nFlags & CASCADESHORTCUTKEY) )
|
||||
Popup2D(point.x,point.y);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OCC_2dView::OnRButtonUp(UINT
|
||||
#ifndef POPUPONBUTTONDOWN
|
||||
nFlags
|
||||
#endif
|
||||
, CPoint
|
||||
#ifndef POPUPONBUTTONDOWN
|
||||
point
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifndef POPUPONBUTTONDOWN
|
||||
if ( !(nFlags & CASCADESHORTCUTKEY) )
|
||||
Popup2D(point.x,point.y);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OCC_2dView::OnMouseMove(UINT nFlags, CPoint point)
|
||||
{
|
||||
// ============================ LEFT BUTTON =======================
|
||||
if ( (nFlags & MK_LBUTTON) &! (nFlags & MK_RBUTTON) ) // Left + Right is specific
|
||||
{
|
||||
if ( nFlags & CASCADESHORTCUTKEY )
|
||||
{
|
||||
// move with MB1 and CASCADESHORTCUTKEY : on the dynamic zooming
|
||||
// Do the zoom in function of mouse's coordinates
|
||||
myV2dView->Zoom(myXmax,myYmax,point.x,point.y);
|
||||
// save the current mouse coordinate in min
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
}
|
||||
else // if ( CASCADESHORTCUTKEY )
|
||||
{
|
||||
const Handle(AIS_InteractiveContext)& aContext = GetDocument()->GetAISContext();
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case CurAction2d_Nothing :
|
||||
myXmax = point.x; myYmax = point.y;
|
||||
DragEvent2D(myXmax,myYmax,0);
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext);
|
||||
break;
|
||||
case CurAction2d_DynamicZooming :
|
||||
myV2dView->Zoom(myXmax,myYmax,point.x,point.y);
|
||||
// save the current mouse coordinate in min \n";
|
||||
myXmax=point.x; myYmax=point.y;
|
||||
break;
|
||||
case CurAction2d_WindowZooming :
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext);
|
||||
break;
|
||||
case CurAction2d_DynamicPanning :
|
||||
myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
|
||||
myXmax = point.x; myYmax = point.y;
|
||||
break;
|
||||
case CurAction2d_GlobalPanning : // nothing
|
||||
break;
|
||||
default :
|
||||
throw Standard_Failure(" incompatible Current Mode ");
|
||||
break;
|
||||
}// switch (myCurrentMode)
|
||||
}// if ( nFlags & CASCADESHORTCUTKEY ) else
|
||||
} else // if ( nFlags & MK_LBUTTON)
|
||||
// ============================ MIDDLE BUTTON =======================
|
||||
if ( nFlags & MK_MBUTTON)
|
||||
{
|
||||
if ( nFlags & CASCADESHORTCUTKEY )
|
||||
{
|
||||
myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
|
||||
myXmax = point.x; myYmax = point.y;
|
||||
|
||||
}
|
||||
} else // if ( nFlags & MK_MBUTTON)
|
||||
// ============================ RIGHT BUTTON =======================
|
||||
if ( (nFlags & MK_RBUTTON) &! (nFlags & MK_LBUTTON) ) // Left + Right is specific
|
||||
{
|
||||
}else //if ( nFlags & MK_RBUTTON)
|
||||
if ( (nFlags & MK_RBUTTON) && (nFlags & MK_LBUTTON) )
|
||||
{
|
||||
// in case of Left + Right : same as Middle
|
||||
if ( nFlags & CASCADESHORTCUTKEY )
|
||||
{
|
||||
myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
|
||||
myXmax = point.x; myYmax = point.y;
|
||||
}
|
||||
}else //if ( nFlags & MK_RBUTTON)&& (nFlags & MK_LBUTTON)
|
||||
// ============================ NO BUTTON =======================
|
||||
{ // No buttons
|
||||
myXmax = point.x; myYmax = point.y;
|
||||
if (nFlags & MULTISELECTIONKEY)
|
||||
MultiMoveEvent2D(point.x,point.y);
|
||||
else
|
||||
MoveEvent2D(point.x,point.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OCC_2dView::OnSize(UINT nType, int cx, int cy)
|
||||
{
|
||||
OCC_BaseView::OnSize (nType, cx, cy);
|
||||
// Take care : This fonction is call before OnInitialUpdate
|
||||
if (!myV2dView.IsNull())
|
||||
myV2dView->MustBeResized();
|
||||
if (!myView.IsNull())
|
||||
myView->MustBeResized();
|
||||
}
|
||||
|
||||
void OCC_2dView::OnBUTTONFitAll()
|
||||
{
|
||||
myV2dView->FitAll();
|
||||
myView->FitAll();
|
||||
}
|
||||
|
||||
void OCC_2dView::OnBUTTONGlobPanning()
|
||||
{
|
||||
//save the current zoom value
|
||||
myCurZoom = myV2dView->Scale();
|
||||
myCurZoom = myView->Scale();
|
||||
|
||||
// Do a Global Zoom
|
||||
myV2dView->FitAll();
|
||||
myView->FitAll();
|
||||
|
||||
// Set the mode
|
||||
myCurrentMode = CurAction2d_GlobalPanning;
|
||||
setCurrentAction (CurAction3d_GlobalPanning);
|
||||
}
|
||||
void OCC_2dView::OnBUTTONPanning()
|
||||
{
|
||||
myCurrentMode = CurAction2d_DynamicPanning;
|
||||
setCurrentAction (CurAction3d_DynamicPanning);
|
||||
}
|
||||
void OCC_2dView::OnBUTTONZoomProg()
|
||||
{
|
||||
myCurrentMode = CurAction2d_DynamicZooming;
|
||||
setCurrentAction (CurAction3d_DynamicZooming);
|
||||
}
|
||||
void OCC_2dView::OnBUTTONZoomWin()
|
||||
{
|
||||
myCurrentMode = CurAction2d_WindowZooming;
|
||||
setCurrentAction (CurAction3d_WindowZooming);
|
||||
}
|
||||
void OCC_2dView::OnChangeBackground()
|
||||
{
|
||||
Standard_Real R1, G1, B1;
|
||||
Handle(Aspect_Window) aWindow = myV2dView->Window();
|
||||
Handle(Aspect_Window) aWindow = myView->Window();
|
||||
Aspect_Background ABack = aWindow->Background();
|
||||
Quantity_Color aColor = ABack.Color();
|
||||
aColor.Values(R1,G1,B1,Quantity_TOC_RGB);
|
||||
@@ -525,166 +268,32 @@ void OCC_2dView::OnChangeBackground()
|
||||
G1 = GetGValue(m_clr)/255.;
|
||||
B1 = GetBValue(m_clr)/255.;
|
||||
aColor.SetValues(R1,G1,B1,Quantity_TOC_RGB);
|
||||
myV2dView->SetBackgroundColor(aColor);
|
||||
myV2dView->Update();
|
||||
myView->SetBackgroundColor(aColor);
|
||||
myView->Update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OCC_2dView::OnUpdateBUTTON2DGlobPanning(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myCurrentMode == CurAction2d_GlobalPanning);
|
||||
pCmdUI->Enable (myCurrentMode != CurAction2d_GlobalPanning);
|
||||
pCmdUI->SetCheck (getCurrentAction() == CurAction3d_GlobalPanning);
|
||||
pCmdUI->Enable (getCurrentAction() != CurAction3d_GlobalPanning);
|
||||
}
|
||||
|
||||
void OCC_2dView::OnUpdateBUTTON2DPanning(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myCurrentMode == CurAction2d_DynamicPanning);
|
||||
pCmdUI->Enable (myCurrentMode != CurAction2d_DynamicPanning);
|
||||
pCmdUI->SetCheck (getCurrentAction() == CurAction3d_DynamicPanning);
|
||||
pCmdUI->Enable (getCurrentAction() != CurAction3d_DynamicPanning);
|
||||
}
|
||||
|
||||
void OCC_2dView::OnUpdateBUTTON2DZoomProg(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myCurrentMode == CurAction2d_DynamicZooming);
|
||||
pCmdUI->Enable (myCurrentMode != CurAction2d_DynamicZooming);
|
||||
pCmdUI->SetCheck (getCurrentAction() == CurAction3d_DynamicZooming);
|
||||
pCmdUI->Enable (getCurrentAction() != CurAction3d_DynamicZooming);
|
||||
}
|
||||
|
||||
void OCC_2dView::OnUpdateBUTTON2DZoomWin(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myCurrentMode == CurAction2d_WindowZooming);
|
||||
pCmdUI->Enable (myCurrentMode != CurAction2d_WindowZooming);
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void OCC_2dView::DragEvent2D(const Standard_Integer x,
|
||||
const Standard_Integer y,
|
||||
const Standard_Integer TheState)
|
||||
{
|
||||
// TheState == -1 button down
|
||||
// TheState == 0 move
|
||||
// TheState == 1 button up
|
||||
|
||||
static Standard_Integer theButtonDownX=0;
|
||||
static Standard_Integer theButtonDownY=0;
|
||||
|
||||
if (TheState == -1)
|
||||
{
|
||||
theButtonDownX=x;
|
||||
theButtonDownY=y;
|
||||
}
|
||||
|
||||
if (TheState == 0)
|
||||
{
|
||||
((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->MoveTo (x, y, myV2dView, Standard_False);
|
||||
((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->Select (theButtonDownX, theButtonDownY, x, y, myV2dView, Standard_True);
|
||||
}
|
||||
|
||||
if (TheState == 1)
|
||||
{
|
||||
((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->Select(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void OCC_2dView::InputEvent2D(const Standard_Integer /*x*/,
|
||||
const Standard_Integer /*y*/)
|
||||
{
|
||||
((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->Select(true);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void OCC_2dView::MoveEvent2D(const Standard_Integer x,
|
||||
const Standard_Integer y)
|
||||
{
|
||||
if(myV2dView->Viewer()->Grid()->IsActive())
|
||||
{
|
||||
Standard_Real aGridX=0,aGridY=0,aGridZ=0;
|
||||
myV2dView->ConvertToGrid(x,y,aGridX,aGridY,aGridZ);
|
||||
//View is not updated automatically in ConvertToGrid
|
||||
myV2dView->Update();
|
||||
}
|
||||
((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->MoveTo (x, y, myV2dView, Standard_True);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void OCC_2dView::MultiMoveEvent2D(const Standard_Integer x,
|
||||
const Standard_Integer y)
|
||||
{
|
||||
// MultiMoveEvent2D means we move the mouse in a multi selection mode
|
||||
((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->MoveTo (x, y, myV2dView, Standard_True);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void OCC_2dView::MultiDragEvent2D(const Standard_Integer x ,
|
||||
const Standard_Integer y ,
|
||||
const Standard_Integer TheState)
|
||||
{
|
||||
static Standard_Integer theButtonDownX=0;
|
||||
static Standard_Integer theButtonDownY=0;
|
||||
|
||||
if (TheState == -1)
|
||||
{
|
||||
theButtonDownX=x;
|
||||
theButtonDownY=y;
|
||||
}
|
||||
|
||||
if (TheState == 0)
|
||||
{
|
||||
((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->MoveTo (x, y, myV2dView, Standard_False);
|
||||
((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->ShiftSelect (theButtonDownX, theButtonDownY, x, y, myV2dView, Standard_True);
|
||||
}
|
||||
|
||||
if (TheState == 1)
|
||||
{
|
||||
((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->ShiftSelect(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void OCC_2dView::MultiInputEvent2D(const Standard_Integer /*x*/,
|
||||
const Standard_Integer /*y*/)
|
||||
{
|
||||
((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->ShiftSelect(true);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void OCC_2dView::Popup2D(const Standard_Integer x,
|
||||
const Standard_Integer y )
|
||||
{
|
||||
CMenu menu;
|
||||
CMenu* pPopup ;
|
||||
|
||||
// load the 'normal' popup
|
||||
VERIFY(menu.LoadMenu(IDR_Popup2D));
|
||||
// activate the sub menu '0'
|
||||
pPopup= menu.GetSubMenu(0);
|
||||
ASSERT(pPopup != NULL);
|
||||
|
||||
// display the popup
|
||||
POINT winCoord = { x , y };
|
||||
ClientToScreen ( &winCoord);
|
||||
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON , winCoord.x, winCoord.y , AfxGetMainWnd());
|
||||
}
|
||||
|
||||
void OCC_2dView::FitAll()
|
||||
{
|
||||
myV2dView->FitAll();
|
||||
pCmdUI->SetCheck (getCurrentAction() == CurAction3d_WindowZooming);
|
||||
pCmdUI->Enable (getCurrentAction() != CurAction3d_WindowZooming);
|
||||
}
|
||||
|
@@ -14,15 +14,6 @@
|
||||
#include "Resource2d/RectangularGrid.h"
|
||||
#include "Resource2d/CircularGrid.h"
|
||||
|
||||
enum CurrentAction2d
|
||||
{
|
||||
CurAction2d_Nothing,
|
||||
CurAction2d_DynamicZooming,
|
||||
CurAction2d_WindowZooming,
|
||||
CurAction2d_DynamicPanning,
|
||||
CurAction2d_GlobalPanning,
|
||||
};
|
||||
|
||||
class Standard_EXPORT OCC_2dView : public OCC_BaseView
|
||||
{
|
||||
DECLARE_DYNCREATE(OCC_2dView)
|
||||
@@ -35,17 +26,10 @@ public:
|
||||
|
||||
OCC_2dDoc* GetDocument();
|
||||
|
||||
Handle(V3d_View)& GetV2dView() { return myV2dView; }
|
||||
|
||||
void FitAll();
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(OCC_2dView)
|
||||
public:
|
||||
virtual void OnDraw(CDC* pDC); // overridden to draw this view
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
protected:
|
||||
protected:
|
||||
virtual void OnInitialUpdate(); // called first time after construct
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
@@ -70,13 +54,6 @@ protected:
|
||||
afx_msg void OnUpdateBUTTONGridValues(CCmdUI* pCmdUI);
|
||||
afx_msg void OnBUTTONGridCancel();
|
||||
afx_msg void OnUpdateBUTTONGridCancel(CCmdUI* pCmdUI);
|
||||
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
|
||||
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
|
||||
afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
|
||||
afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
|
||||
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
|
||||
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
|
||||
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
afx_msg void OnBUTTONFitAll();
|
||||
afx_msg void OnBUTTONGlobPanning();
|
||||
@@ -92,34 +69,6 @@ protected:
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
protected:
|
||||
|
||||
virtual void DragEvent2D (const Standard_Integer x,
|
||||
const Standard_Integer y,
|
||||
const Standard_Integer TheState);
|
||||
|
||||
virtual void InputEvent2D (const Standard_Integer x,
|
||||
const Standard_Integer y);
|
||||
|
||||
virtual void MoveEvent2D (const Standard_Integer x,
|
||||
const Standard_Integer y);
|
||||
|
||||
virtual void MultiMoveEvent2D (const Standard_Integer x,
|
||||
const Standard_Integer y);
|
||||
|
||||
virtual void MultiDragEvent2D (const Standard_Integer x,
|
||||
const Standard_Integer y,
|
||||
const Standard_Integer TheState);
|
||||
|
||||
virtual void MultiInputEvent2D (const Standard_Integer x,
|
||||
const Standard_Integer y);
|
||||
|
||||
virtual void Popup2D (const Standard_Integer x,
|
||||
const Standard_Integer y);
|
||||
|
||||
protected:
|
||||
|
||||
Handle(V3d_View) myV2dView;
|
||||
CurrentAction2d myCurrentMode;
|
||||
CRectangularGrid TheRectangularGridDialog;
|
||||
CCircularGrid TheCircularGridDialog;
|
||||
};
|
||||
|
@@ -221,9 +221,7 @@ void OCC_3dBaseDoc::Popup (const Standard_Integer theMouseX,
|
||||
}
|
||||
|
||||
POINT winCoord = { theMouseX , theMouseY };
|
||||
Handle(WNT_Window) aWNTWindow=
|
||||
Handle(WNT_Window)::DownCast(theView->Window());
|
||||
ClientToScreen ( (HWND)(aWNTWindow->HWindow()),&winCoord);
|
||||
ClientToScreen ((HWND )theView->Window()->NativeHandle(), &winCoord);
|
||||
pPopup->TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON,
|
||||
winCoord.x,
|
||||
winCoord.y,
|
||||
|
@@ -51,7 +51,7 @@ public:
|
||||
|
||||
virtual void Popup (const Standard_Integer theMouseX,
|
||||
const Standard_Integer theMouseY,
|
||||
const Handle(V3d_View)& theView);
|
||||
const Handle(V3d_View)& theView) Standard_OVERRIDE;
|
||||
|
||||
static void Fit();
|
||||
|
||||
|
@@ -12,11 +12,9 @@
|
||||
|
||||
#include <OpenGl_GraphicDriver.hxx>
|
||||
|
||||
#define ValZWMin 1
|
||||
IMPLEMENT_DYNCREATE(OCC_3dView, OCC_BaseView)
|
||||
|
||||
IMPLEMENT_DYNCREATE(OCC_3dView, CView)
|
||||
|
||||
BEGIN_MESSAGE_MAP(OCC_3dView, CView)
|
||||
BEGIN_MESSAGE_MAP(OCC_3dView, OCC_BaseView)
|
||||
//{{AFX_MSG_MAP(OCC_3dView)
|
||||
ON_COMMAND(ID_BUTTONAxo, OnBUTTONAxo)
|
||||
ON_COMMAND(ID_BUTTONBack, OnBUTTONBack)
|
||||
@@ -37,13 +35,6 @@ BEGIN_MESSAGE_MAP(OCC_3dView, CView)
|
||||
ON_COMMAND(ID_FILE_EXPORT_IMAGE, OnFileExportImage)
|
||||
ON_COMMAND(ID_BUTTONZoomProg, OnBUTTONZoomProg)
|
||||
ON_COMMAND(ID_BUTTONZoomWin, OnBUTTONZoomWin)
|
||||
ON_WM_LBUTTONDOWN()
|
||||
ON_WM_LBUTTONUP()
|
||||
ON_WM_MBUTTONDOWN()
|
||||
ON_WM_MBUTTONUP()
|
||||
ON_WM_MOUSEMOVE()
|
||||
ON_WM_RBUTTONDOWN()
|
||||
ON_WM_RBUTTONUP()
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTONHlrOff, OnUpdateBUTTONHlrOff)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTONHlrOn, OnUpdateBUTTONHlrOn)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTONPanGlo, OnUpdateBUTTONPanGlo)
|
||||
@@ -60,79 +51,25 @@ END_MESSAGE_MAP()
|
||||
// OCC_3dView construction/destruction
|
||||
|
||||
OCC_3dView::OCC_3dView()
|
||||
: myCurrentMode (CurAction3d_Nothing),
|
||||
myWidth (0),
|
||||
myHeight (0),
|
||||
myHlrModeIsOn (Standard_False)
|
||||
{
|
||||
// TODO: add construction code here
|
||||
}
|
||||
|
||||
OCC_3dView::~OCC_3dView()
|
||||
{
|
||||
if (myView.IsNull())
|
||||
{
|
||||
myView->Remove();
|
||||
}
|
||||
|
||||
delete m_pStereoDlg;
|
||||
}
|
||||
|
||||
BOOL OCC_3dView::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
// TODO: Modify the Window class or styles here by modifying
|
||||
// the CREATESTRUCT cs
|
||||
cs.lpszClass = ::AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC, ::LoadCursor(NULL, IDC_ARROW), NULL, NULL);
|
||||
return CView::PreCreateWindow(cs);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// OCC_3dView drawing
|
||||
void OCC_3dView::OnInitialUpdate()
|
||||
{
|
||||
CView::OnInitialUpdate();
|
||||
|
||||
myView = GetDocument()->GetViewer()->CreateView();
|
||||
|
||||
// store for restore state after rotation (which is in Degenerated mode)
|
||||
myHlrModeIsOn = Standard_False;
|
||||
myView->SetComputedMode (myHlrModeIsOn);
|
||||
|
||||
Handle(OpenGl_GraphicDriver) aDriver =
|
||||
Handle(OpenGl_GraphicDriver)::DownCast (((OCC_App*)AfxGetApp())->GetGraphicDriver());
|
||||
|
||||
Handle(WNT_Window) aWNTWindow = new WNT_Window(GetSafeHwnd());
|
||||
|
||||
myView->SetWindow(aWNTWindow);
|
||||
myView->Camera()->SetProjectionType (aDriver->Options().contextStereo
|
||||
? Graphic3d_Camera::Projection_Stereo
|
||||
: Graphic3d_Camera::Projection_Orthographic);
|
||||
|
||||
if (!aWNTWindow->IsMapped())
|
||||
{
|
||||
aWNTWindow->Map();
|
||||
}
|
||||
|
||||
// store the mode ( nothing , dynamic zooming, dynamic ... )
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
|
||||
OCC_BaseView::OnInitialUpdate();
|
||||
m_pStereoDlg = new OCC_StereoConfigDlg (this);
|
||||
m_pStereoDlg->SetView (myView);
|
||||
m_pStereoDlg->Create (IDD_DIALOG_STEREO, this);
|
||||
}
|
||||
|
||||
void OCC_3dView::OnDraw(CDC* /*pDC*/)
|
||||
{
|
||||
CRect aRect;
|
||||
GetWindowRect(aRect);
|
||||
if(myWidth != aRect.Width() || myHeight != aRect.Height()) {
|
||||
myWidth = aRect.Width();
|
||||
myHeight = aRect.Height();
|
||||
::PostMessage ( GetSafeHwnd() , WM_SIZE , SW_SHOW , myWidth + myHeight*65536 );
|
||||
}
|
||||
myView->Redraw();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// OCC_3dView diagnostics
|
||||
|
||||
@@ -162,74 +99,72 @@ void OCC_3dView::OnFileExportImage()
|
||||
GetDocument()->ExportView (myView);
|
||||
}
|
||||
|
||||
void OCC_3dView::OnSize(UINT nType, int cx, int cy)
|
||||
{
|
||||
OCC_BaseView::OnSize (nType, cx, cy);
|
||||
if (!myView.IsNull())
|
||||
myView->MustBeResized();
|
||||
}
|
||||
|
||||
// See the back View
|
||||
void OCC_3dView::OnBUTTONBack()
|
||||
{
|
||||
myView->SetProj(V3d_Ypos);
|
||||
myView->Redraw();
|
||||
}
|
||||
|
||||
// See the front View
|
||||
void OCC_3dView::OnBUTTONFront()
|
||||
{
|
||||
myView->SetProj(V3d_Yneg);
|
||||
myView->Redraw();
|
||||
}
|
||||
|
||||
// See the bottom View
|
||||
void OCC_3dView::OnBUTTONBottom()
|
||||
{
|
||||
myView->SetProj(V3d_Zneg);
|
||||
myView->Redraw();
|
||||
}
|
||||
|
||||
// See the top View
|
||||
void OCC_3dView::OnBUTTONTop()
|
||||
{
|
||||
myView->SetProj(V3d_Zpos);
|
||||
myView->Redraw();
|
||||
}
|
||||
|
||||
// See the left View
|
||||
void OCC_3dView::OnBUTTONLeft()
|
||||
{
|
||||
myView->SetProj(V3d_Xneg);
|
||||
myView->Redraw();
|
||||
}
|
||||
|
||||
// See the right View
|
||||
void OCC_3dView::OnBUTTONRight()
|
||||
{
|
||||
myView->SetProj(V3d_Xpos);
|
||||
myView->Redraw();
|
||||
}
|
||||
|
||||
// See the axonometric View
|
||||
void OCC_3dView::OnBUTTONAxo()
|
||||
{
|
||||
myView->SetProj(V3d_XposYnegZpos);
|
||||
myView->Redraw();
|
||||
}
|
||||
|
||||
void OCC_3dView::OnBUTTONHlrOff()
|
||||
{
|
||||
myHlrModeIsOn = Standard_False;
|
||||
myView->SetComputedMode (myHlrModeIsOn);
|
||||
myView->SetComputedMode (Standard_False);
|
||||
myView->Redraw();
|
||||
}
|
||||
|
||||
void OCC_3dView::OnBUTTONHlrOn()
|
||||
{
|
||||
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
|
||||
myHlrModeIsOn = Standard_True;
|
||||
myView->SetComputedMode (myHlrModeIsOn);
|
||||
myView->SetComputedMode (Standard_True);
|
||||
myView->Redraw();
|
||||
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
|
||||
}
|
||||
|
||||
void OCC_3dView::OnBUTTONPan()
|
||||
{
|
||||
myCurrentMode = CurAction3d_DynamicPanning;
|
||||
setCurrentAction (CurAction3d_DynamicPanning);
|
||||
}
|
||||
|
||||
void OCC_3dView::OnBUTTONPanGlo()
|
||||
@@ -237,9 +172,9 @@ void OCC_3dView::OnBUTTONPanGlo()
|
||||
// save the current zoom value
|
||||
myCurZoom = myView->Scale();
|
||||
// Do a Global Zoom
|
||||
//myView->FitAll();
|
||||
myView->FitAll();
|
||||
// Set the mode
|
||||
myCurrentMode = CurAction3d_GlobalPanning;
|
||||
setCurrentAction (CurAction3d_GlobalPanning);
|
||||
}
|
||||
|
||||
void OCC_3dView::OnBUTTONReset()
|
||||
@@ -249,7 +184,7 @@ void OCC_3dView::OnBUTTONReset()
|
||||
|
||||
void OCC_3dView::OnBUTTONRot()
|
||||
{
|
||||
myCurrentMode = CurAction3d_DynamicRotation;
|
||||
setCurrentAction (CurAction3d_DynamicRotation);
|
||||
}
|
||||
|
||||
void OCC_3dView::OnBUTTONZoomAll()
|
||||
@@ -259,298 +194,55 @@ void OCC_3dView::OnBUTTONZoomAll()
|
||||
}
|
||||
|
||||
void OCC_3dView::OnBUTTONZoomProg()
|
||||
{ myCurrentMode = CurAction3d_DynamicZooming; }
|
||||
{
|
||||
setCurrentAction (CurAction3d_DynamicZooming);
|
||||
}
|
||||
|
||||
void OCC_3dView::OnBUTTONZoomWin()
|
||||
{ myCurrentMode = CurAction3d_WindowZooming; }
|
||||
|
||||
void OCC_3dView::OnLButtonDown(UINT nFlags, CPoint point)
|
||||
{
|
||||
// save the current mouse coordinate in min
|
||||
myXmin=point.x; myYmin=point.y;
|
||||
myXmax=point.x; myYmax=point.y;
|
||||
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
// Button MB1 down Control :start zomming
|
||||
// SetCursor(AfxGetApp()->LoadStandardCursor());
|
||||
}
|
||||
else // if ( Ctrl )
|
||||
{
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case CurAction3d_Nothing : // start a drag
|
||||
if (nFlags & MK_SHIFT)
|
||||
GetDocument()->ShiftDragEvent(myXmax,myYmax,-1,myView);
|
||||
else
|
||||
GetDocument()->DragEvent(myXmax,myYmax,-1,myView);
|
||||
break;
|
||||
break;
|
||||
case CurAction3d_DynamicZooming : // noting
|
||||
break;
|
||||
case CurAction3d_WindowZooming : // noting
|
||||
break;
|
||||
case CurAction3d_DynamicPanning :// noting
|
||||
break;
|
||||
case CurAction3d_GlobalPanning :// noting
|
||||
break;
|
||||
case CurAction3d_DynamicRotation :
|
||||
if (myHlrModeIsOn)
|
||||
{
|
||||
myView->SetComputedMode (Standard_False);
|
||||
}
|
||||
|
||||
myView->StartRotation(point.x,point.y);
|
||||
break;
|
||||
default :
|
||||
throw Standard_Failure(" incompatible Current Mode ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OCC_3dView::OnLButtonUp(UINT nFlags, CPoint point)
|
||||
{
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
return;
|
||||
}
|
||||
else // if ( Ctrl )
|
||||
{
|
||||
const Handle(AIS_InteractiveContext)& aContext = GetDocument()->GetAISContext();
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case CurAction3d_Nothing :
|
||||
if (point.x == myXmin && point.y == myYmin)
|
||||
{ // no offset between down and up --> selectEvent
|
||||
myXmax=point.x;
|
||||
myYmax=point.y;
|
||||
if (nFlags & MK_SHIFT )
|
||||
GetDocument()->ShiftInputEvent(point.x,point.y,myView);
|
||||
else
|
||||
GetDocument()->InputEvent (point.x,point.y,myView);
|
||||
} else
|
||||
{
|
||||
myXmax=point.x; myYmax=point.y;
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext, Standard_False);
|
||||
if (nFlags & MK_SHIFT)
|
||||
GetDocument()->ShiftDragEvent(point.x,point.y,1,myView);
|
||||
else
|
||||
GetDocument()->DragEvent(point.x,point.y,1,myView);
|
||||
}
|
||||
break;
|
||||
case CurAction3d_DynamicZooming :
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
break;
|
||||
case CurAction3d_WindowZooming :
|
||||
myXmax=point.x; myYmax=point.y;
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext, Standard_False);
|
||||
if ((abs(myXmin-myXmax)>ValZWMin) || (abs(myYmin-myYmax)>ValZWMin))
|
||||
// Test if the zoom window is greater than a minimale window.
|
||||
{
|
||||
// Do the zoom window between Pmin and Pmax
|
||||
myView->WindowFitAll(myXmin,myYmin,myXmax,myYmax);
|
||||
}
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
break;
|
||||
case CurAction3d_DynamicPanning :
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
break;
|
||||
case CurAction3d_GlobalPanning :
|
||||
myView->Place(point.x,point.y,myCurZoom);
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
break;
|
||||
case CurAction3d_DynamicRotation :
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
if (myHlrModeIsOn)
|
||||
{
|
||||
CWaitCursor aWaitCursor;
|
||||
myView->SetComputedMode (myHlrModeIsOn);
|
||||
myView->Redraw();
|
||||
}
|
||||
else
|
||||
{
|
||||
myView->SetComputedMode (myHlrModeIsOn);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
throw Standard_Failure(" incompatible Current Mode ");
|
||||
break;
|
||||
} //switch (myCurrentMode)
|
||||
} // else // if ( Ctrl )
|
||||
}
|
||||
|
||||
void OCC_3dView::OnMButtonDown(UINT nFlags, CPoint /*point*/)
|
||||
{
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
// Button MB2 down Control : panning init
|
||||
// SetCursor(AfxGetApp()->LoadStandardCursor());
|
||||
}
|
||||
}
|
||||
|
||||
void OCC_3dView::OnMButtonUp(UINT nFlags, CPoint /*point*/)
|
||||
{
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
// Button MB2 down Control : panning init
|
||||
// SetCursor(AfxGetApp()->LoadStandardCursor());
|
||||
}
|
||||
}
|
||||
|
||||
void OCC_3dView::OnRButtonDown(UINT nFlags, CPoint point)
|
||||
{
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
if (myHlrModeIsOn)
|
||||
{
|
||||
myView->SetComputedMode (Standard_False);
|
||||
}
|
||||
myView->StartRotation(point.x,point.y);
|
||||
}
|
||||
else // if ( Ctrl )
|
||||
{
|
||||
GetDocument()->Popup(point.x,point.y,myView);
|
||||
}
|
||||
}
|
||||
|
||||
void OCC_3dView::OnRButtonUp(UINT /*nFlags*/, CPoint /*point*/)
|
||||
{
|
||||
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
|
||||
if (myHlrModeIsOn)
|
||||
{
|
||||
myView->SetComputedMode (myHlrModeIsOn);
|
||||
myView->Redraw();
|
||||
}
|
||||
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
|
||||
}
|
||||
|
||||
void OCC_3dView::OnMouseMove(UINT nFlags, CPoint point)
|
||||
{
|
||||
// ============================ LEFT BUTTON =======================
|
||||
if ( nFlags & MK_LBUTTON)
|
||||
{
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
// move with MB1 and Control : on the dynamic zooming
|
||||
// Do the zoom in function of mouse's coordinates
|
||||
myView->Zoom (myXmax,myYmax,point.x,point.y);
|
||||
// save the current mouse coordinate in min
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
}
|
||||
else // if ( Ctrl )
|
||||
{
|
||||
const Handle(AIS_InteractiveContext)& aContext = GetDocument()->GetAISContext();
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case CurAction3d_Nothing :
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
|
||||
if (nFlags & MK_SHIFT)
|
||||
GetDocument()->ShiftDragEvent(myXmax,myYmax,0,myView);
|
||||
else
|
||||
GetDocument()->DragEvent(myXmax,myYmax,0,myView);
|
||||
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext);
|
||||
|
||||
break;
|
||||
case CurAction3d_DynamicZooming :
|
||||
myView->Zoom(myXmax,myYmax,point.x,point.y);
|
||||
// save the current mouse coordinate in min \n";
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
break;
|
||||
case CurAction3d_WindowZooming :
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext);
|
||||
break;
|
||||
case CurAction3d_DynamicPanning :
|
||||
myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
|
||||
myXmax = point.x; myYmax = point.y;
|
||||
break;
|
||||
case CurAction3d_GlobalPanning : // nothing
|
||||
break;
|
||||
case CurAction3d_DynamicRotation :
|
||||
myView->Rotation(point.x,point.y);
|
||||
myView->Redraw();
|
||||
break;
|
||||
default :
|
||||
throw Standard_Failure(" incompatible Current Mode ");
|
||||
break;
|
||||
}// switch (myCurrentMode)
|
||||
}// if ( nFlags & MK_CONTROL ) else
|
||||
}
|
||||
else if ( nFlags & MK_MBUTTON)
|
||||
{
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
}
|
||||
}
|
||||
else if ( nFlags & MK_RBUTTON)
|
||||
{
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
myView->Rotation(point.x,point.y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // No buttons
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
if (nFlags & MK_SHIFT)
|
||||
GetDocument()->ShiftMoveEvent(point.x,point.y,myView);
|
||||
else
|
||||
GetDocument()->MoveEvent(point.x,point.y,myView);
|
||||
}
|
||||
setCurrentAction (CurAction3d_WindowZooming);
|
||||
}
|
||||
|
||||
void OCC_3dView::OnUpdateBUTTONHlrOff(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (!myHlrModeIsOn);
|
||||
pCmdUI->Enable (myHlrModeIsOn);
|
||||
pCmdUI->SetCheck (!myView->ComputedMode());
|
||||
pCmdUI->Enable (myView->ComputedMode());
|
||||
}
|
||||
|
||||
void OCC_3dView::OnUpdateBUTTONHlrOn(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myHlrModeIsOn);
|
||||
pCmdUI->Enable (!myHlrModeIsOn);
|
||||
pCmdUI->SetCheck (myView->ComputedMode());
|
||||
pCmdUI->Enable (!myView->ComputedMode());
|
||||
}
|
||||
|
||||
void OCC_3dView::OnUpdateBUTTONPanGlo(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myCurrentMode == CurAction3d_GlobalPanning);
|
||||
pCmdUI->Enable (myCurrentMode != CurAction3d_GlobalPanning);
|
||||
|
||||
pCmdUI->SetCheck (getCurrentAction() == CurAction3d_GlobalPanning);
|
||||
pCmdUI->Enable (getCurrentAction() != CurAction3d_GlobalPanning);
|
||||
}
|
||||
|
||||
void OCC_3dView::OnUpdateBUTTONPan(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myCurrentMode == CurAction3d_DynamicPanning);
|
||||
pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicPanning );
|
||||
pCmdUI->SetCheck (getCurrentAction() == CurAction3d_DynamicPanning);
|
||||
pCmdUI->Enable (getCurrentAction() != CurAction3d_DynamicPanning );
|
||||
}
|
||||
|
||||
void OCC_3dView::OnUpdateBUTTONZoomProg(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myCurrentMode == CurAction3d_DynamicZooming );
|
||||
pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicZooming);
|
||||
pCmdUI->SetCheck (getCurrentAction() == CurAction3d_DynamicZooming );
|
||||
pCmdUI->Enable (getCurrentAction() != CurAction3d_DynamicZooming);
|
||||
}
|
||||
|
||||
void OCC_3dView::OnUpdateBUTTONZoomWin(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myCurrentMode == CurAction3d_WindowZooming);
|
||||
pCmdUI->Enable (myCurrentMode != CurAction3d_WindowZooming);
|
||||
pCmdUI->SetCheck (getCurrentAction() == CurAction3d_WindowZooming);
|
||||
pCmdUI->Enable (getCurrentAction() != CurAction3d_WindowZooming);
|
||||
}
|
||||
|
||||
void OCC_3dView::OnUpdateBUTTONRot(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myCurrentMode == CurAction3d_DynamicRotation);
|
||||
pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicRotation);
|
||||
pCmdUI->SetCheck (getCurrentAction() == CurAction3d_DynamicRotation);
|
||||
pCmdUI->Enable (getCurrentAction() != CurAction3d_DynamicRotation);
|
||||
}
|
||||
|
||||
void OCC_3dView::OnModifyChangeBackground()
|
||||
|
@@ -14,15 +14,6 @@
|
||||
#include "OCC_StereoConfigDlg.h"
|
||||
#include <Standard_Macro.hxx>
|
||||
|
||||
enum CurAction3d {
|
||||
CurAction3d_Nothing,
|
||||
CurAction3d_DynamicZooming,
|
||||
CurAction3d_WindowZooming,
|
||||
CurAction3d_DynamicPanning,
|
||||
CurAction3d_GlobalPanning,
|
||||
CurAction3d_DynamicRotation
|
||||
};
|
||||
|
||||
class Standard_EXPORT OCC_3dView : public OCC_BaseView
|
||||
{
|
||||
DECLARE_DYNCREATE(OCC_3dView)
|
||||
@@ -31,57 +22,42 @@ public:
|
||||
virtual ~OCC_3dView();
|
||||
|
||||
OCC_3dDoc* GetDocument();
|
||||
void FitAll() { if ( !myView.IsNull() ) myView->FitAll(); myView->ZFitAll(); };
|
||||
void Redraw() { if ( !myView.IsNull() ) myView->Redraw(); };
|
||||
|
||||
void SetZoom ( const Standard_Real& Coef ) { myView->SetZoom ( Coef ); };
|
||||
|
||||
Handle(V3d_View)& GetView() { return myView; }
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(OCC_3dView)
|
||||
public:
|
||||
virtual void OnDraw(CDC* pDC); // overridden to draw this view
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
virtual void OnInitialUpdate();
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(OCC_3dView)
|
||||
afx_msg void OnBUTTONAxo();
|
||||
afx_msg void OnBUTTONBack();
|
||||
afx_msg void OnBUTTONBottom();
|
||||
afx_msg void OnBUTTONFront();
|
||||
afx_msg void OnBUTTONHlrOff();
|
||||
afx_msg void OnBUTTONHlrOn();
|
||||
afx_msg void OnBUTTONLeft();
|
||||
afx_msg void OnBUTTONPan();
|
||||
afx_msg void OnBUTTONPanGlo();
|
||||
afx_msg void OnBUTTONReset();
|
||||
afx_msg void OnBUTTONRight();
|
||||
afx_msg void OnBUTTONRot();
|
||||
afx_msg void OnBUTTONTop();
|
||||
afx_msg void OnBUTTONZoomAll();
|
||||
afx_msg void OnFileExportImage();
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
afx_msg void OnBUTTONZoomProg();
|
||||
afx_msg void OnBUTTONZoomWin();
|
||||
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
|
||||
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
|
||||
afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
|
||||
afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
|
||||
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
|
||||
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
|
||||
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
|
||||
afx_msg void OnUpdateBUTTONHlrOff(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONHlrOn(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONPanGlo(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONPan(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONZoomProg(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONZoomWin(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONRot(CCmdUI* pCmdUI);
|
||||
afx_msg void OnModifyChangeBackground();
|
||||
afx_msg void OnBUTTONAxo();
|
||||
afx_msg void OnBUTTONBack();
|
||||
afx_msg void OnBUTTONBottom();
|
||||
afx_msg void OnBUTTONFront();
|
||||
afx_msg void OnBUTTONHlrOff();
|
||||
afx_msg void OnBUTTONHlrOn();
|
||||
afx_msg void OnBUTTONLeft();
|
||||
afx_msg void OnBUTTONPan();
|
||||
afx_msg void OnBUTTONPanGlo();
|
||||
afx_msg void OnBUTTONReset();
|
||||
afx_msg void OnBUTTONRight();
|
||||
afx_msg void OnBUTTONRot();
|
||||
afx_msg void OnBUTTONTop();
|
||||
afx_msg void OnBUTTONZoomAll();
|
||||
afx_msg void OnFileExportImage();
|
||||
afx_msg void OnBUTTONZoomProg();
|
||||
afx_msg void OnBUTTONZoomWin();
|
||||
afx_msg void OnUpdateBUTTONHlrOff(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONHlrOn(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONPanGlo(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONPan(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONZoomProg(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONZoomWin(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONRot(CCmdUI* pCmdUI);
|
||||
afx_msg void OnModifyChangeBackground();
|
||||
afx_msg void OnStereoConfigButton();
|
||||
afx_msg void OnUpdateStereoConfigButton (CCmdUI* theCmdUI);
|
||||
//}}AFX_MSG
|
||||
@@ -92,14 +68,6 @@ protected:
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
Handle(V3d_View) myView;
|
||||
CurAction3d myCurrentMode;
|
||||
Standard_Integer myWidth;
|
||||
Standard_Integer myHeight;
|
||||
Standard_Boolean myHlrModeIsOn;
|
||||
|
||||
private:
|
||||
|
||||
//! Persistent non blocking stereo configuration dialog
|
||||
|
@@ -78,7 +78,4 @@ void OCC_BaseDoc::ResetDocumentViews (CDocTemplate* theTemplate)
|
||||
|
||||
// init frame
|
||||
theTemplate->InitialUpdateFrame(aNewFrame, this);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -28,9 +28,10 @@ public:
|
||||
|
||||
virtual ~OCC_BaseDoc();
|
||||
|
||||
Handle(AIS_InteractiveContext)& GetAISContext() { return myAISContext; }
|
||||
const Handle(AIS_InteractiveContext)& GetAISContext() const { return myAISContext; }
|
||||
const Handle(AIS_InteractiveContext)& GetInteractiveContext() const { return myAISContext; };
|
||||
|
||||
Handle(V3d_Viewer) GetViewer() { return myViewer; }
|
||||
const Handle(V3d_Viewer)& GetViewer() const { return myViewer; }
|
||||
|
||||
// Returns string with supported export pixel and vector images formats.
|
||||
const CString SupportedImageFormats() const;
|
||||
@@ -69,6 +70,10 @@ public:
|
||||
const Standard_Integer /*theMouseY*/,
|
||||
const Handle(V3d_View)& /*theView*/) {}
|
||||
|
||||
//! Callback called by handleMoveTo() on Selection in 3D Viewer.
|
||||
virtual void OnSelectionChanged (const Handle(AIS_InteractiveContext)& ,
|
||||
const Handle(V3d_View)& ) {}
|
||||
|
||||
void ResetDocumentViews (CDocTemplate* theTemplate);
|
||||
|
||||
protected:
|
||||
|
@@ -5,24 +5,30 @@
|
||||
#include <stdafx.h>
|
||||
#include "OCC_BaseView.h"
|
||||
|
||||
BEGIN_MESSAGE_MAP(OCC_BaseView, CView)
|
||||
ON_WM_SIZE()
|
||||
ON_WM_MOUSEMOVE()
|
||||
ON_WM_MOUSEWHEEL()
|
||||
ON_WM_MOUSELEAVE()
|
||||
ON_WM_NCMOUSEMOVE()
|
||||
ON_WM_LBUTTONDOWN()
|
||||
ON_WM_LBUTTONUP()
|
||||
ON_WM_MBUTTONDOWN()
|
||||
ON_WM_MBUTTONUP()
|
||||
ON_WM_RBUTTONDOWN()
|
||||
ON_WM_RBUTTONUP()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
OCC_BaseView::OCC_BaseView()
|
||||
: myXmin (0),
|
||||
myYmin (0),
|
||||
myXmax (0),
|
||||
myYmax (0),
|
||||
myCurZoom (0.0),
|
||||
myRect (new AIS_RubberBand (Quantity_Color(Quantity_NOC_WHITE), Aspect_TOL_SOLID, 1.0) )
|
||||
: myUpdateRequests (0),
|
||||
myCurZoom (0.0),
|
||||
myCurrentMode (CurAction3d_Nothing)
|
||||
{
|
||||
myRect->SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
|
||||
if (myRect->ZLayer() != Graphic3d_ZLayerId_TopOSD)
|
||||
{
|
||||
myRect->SetZLayer (Graphic3d_ZLayerId_TopOSD);
|
||||
}
|
||||
|
||||
myDefaultGestures = myMouseGestureMap;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -31,7 +37,7 @@ OCC_BaseView::OCC_BaseView()
|
||||
//=======================================================================
|
||||
OCC_BaseView::~OCC_BaseView()
|
||||
{
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -43,37 +49,330 @@ OCC_BaseDoc* OCC_BaseView::GetDocument() // non-debug version is inline
|
||||
return (OCC_BaseDoc*)m_pDocument;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : drawRectangle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void OCC_BaseView::drawRectangle (const Standard_Integer theMinX,
|
||||
const Standard_Integer theMinY,
|
||||
const Standard_Integer theMaxX,
|
||||
const Standard_Integer theMaxY,
|
||||
const Handle(AIS_InteractiveContext)& theContext,
|
||||
const Standard_Boolean toDraw)
|
||||
// =======================================================================
|
||||
// function : PostNcDestroy
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OCC_BaseView::PostNcDestroy()
|
||||
{
|
||||
if (toDraw)
|
||||
if (!myView.IsNull())
|
||||
{
|
||||
CRect aRect;
|
||||
GetWindowRect(aRect);
|
||||
myRect->SetRectangle (theMinX, aRect.Height() - theMinY, theMaxX, aRect.Height() - theMaxY);
|
||||
|
||||
if (!theContext->IsDisplayed (myRect))
|
||||
{
|
||||
theContext->Display (myRect, Standard_False);
|
||||
}
|
||||
else
|
||||
{
|
||||
theContext->Redisplay (myRect, Standard_False);
|
||||
}
|
||||
myView->Remove();
|
||||
myView.Nullify();
|
||||
}
|
||||
else
|
||||
{
|
||||
theContext->Remove (myRect, Standard_False);
|
||||
}
|
||||
|
||||
theContext->CurrentViewer()->RedrawImmediate();
|
||||
CView::PostNcDestroy();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : PreCreateWindow
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
BOOL OCC_BaseView::PreCreateWindow (CREATESTRUCT& cs)
|
||||
{
|
||||
cs.lpszClass = ::AfxRegisterWndClass (CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC, ::LoadCursor(NULL, IDC_ARROW), NULL, NULL);
|
||||
return CView::PreCreateWindow (cs);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OnInitialUpdate
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OCC_BaseView::OnInitialUpdate()
|
||||
{
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
CView::OnInitialUpdate();
|
||||
if (!myView.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myView = GetAISContext()->CurrentViewer()->CreateView();
|
||||
myView->SetImmediateUpdate (false);
|
||||
myView->SetComputedMode (Standard_False);
|
||||
|
||||
Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (myView->Viewer()->Driver());
|
||||
myView->Camera()->SetProjectionType (aDriver->Options().contextStereo
|
||||
? Graphic3d_Camera::Projection_Stereo
|
||||
: Graphic3d_Camera::Projection_Orthographic);
|
||||
|
||||
Handle(WNT_Window) aWNTWindow = new WNT_Window (GetSafeHwnd());
|
||||
myView->SetWindow (aWNTWindow);
|
||||
if (!aWNTWindow->IsMapped()) aWNTWindow->Map();
|
||||
|
||||
myView->Redraw();
|
||||
myView->Invalidate();
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : GetAISContext
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
const Handle(AIS_InteractiveContext)& OCC_BaseView::GetAISContext() const
|
||||
{
|
||||
return ((OCC_BaseDoc*)m_pDocument)->GetInteractiveContext();
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : update3dView
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void OCC_BaseView::update3dView()
|
||||
{
|
||||
if (!myView.IsNull())
|
||||
{
|
||||
if (++myUpdateRequests == 1)
|
||||
{
|
||||
Invalidate (FALSE);
|
||||
UpdateWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : redraw3dView
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void OCC_BaseView::redraw3dView()
|
||||
{
|
||||
if (!myView.IsNull())
|
||||
{
|
||||
FlushViewEvents (GetAISContext(), myView, true);
|
||||
}
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : handleViewRedraw
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void OCC_BaseView::handleViewRedraw (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView)
|
||||
{
|
||||
myUpdateRequests = 0;
|
||||
AIS_ViewController::handleViewRedraw (theCtx, theView);
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : OnSelectionChanged
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void OCC_BaseView::OnSelectionChanged (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView)
|
||||
{
|
||||
AIS_ViewController::OnSelectionChanged (theCtx, theView);
|
||||
GetDocument()->OnSelectionChanged (theCtx, theView);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OnDraw
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OCC_BaseView::OnDraw (CDC* )
|
||||
{
|
||||
// always redraw immediate layer (dynamic highlighting) on Paint event,
|
||||
// and redraw entire view content only when it is explicitly invalidated (V3d_View::Invalidate())
|
||||
myView->InvalidateImmediate();
|
||||
FlushViewEvents (GetAISContext(), myView, true);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : defineMouseGestures
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OCC_BaseView::defineMouseGestures()
|
||||
{
|
||||
myMouseGestureMap.Clear();
|
||||
AIS_MouseGesture aRot = AIS_MouseGesture_RotateOrbit;
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case CurAction3d_Nothing:
|
||||
{
|
||||
myMouseGestureMap = myDefaultGestures;
|
||||
break;
|
||||
}
|
||||
case CurAction3d_DynamicZooming:
|
||||
{
|
||||
myMouseGestureMap.Bind (Aspect_VKeyMouse_LeftButton, AIS_MouseGesture_Zoom);
|
||||
break;
|
||||
}
|
||||
case CurAction3d_GlobalPanning:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case CurAction3d_WindowZooming:
|
||||
{
|
||||
myMouseGestureMap.Bind (Aspect_VKeyMouse_LeftButton, AIS_MouseGesture_ZoomWindow);
|
||||
break;
|
||||
}
|
||||
case CurAction3d_DynamicPanning:
|
||||
{
|
||||
myMouseGestureMap.Bind (Aspect_VKeyMouse_LeftButton, AIS_MouseGesture_Pan);
|
||||
break;
|
||||
}
|
||||
case CurAction3d_DynamicRotation:
|
||||
{
|
||||
myMouseGestureMap.Bind (Aspect_VKeyMouse_LeftButton, aRot);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OnMouseMove
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OCC_BaseView::OnMouseMove (UINT theFlags, CPoint thePoint)
|
||||
{
|
||||
TRACKMOUSEEVENT aMouseEvent; // for WM_MOUSELEAVE
|
||||
aMouseEvent.cbSize = sizeof(aMouseEvent);
|
||||
aMouseEvent.dwFlags = TME_LEAVE;
|
||||
aMouseEvent.hwndTrack = m_hWnd;
|
||||
aMouseEvent.dwHoverTime = HOVER_DEFAULT;
|
||||
if (!::_TrackMouseEvent (&aMouseEvent)) { TRACE("Track ERROR!\n"); }
|
||||
|
||||
const Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent (theFlags);
|
||||
if (UpdateMousePosition (Graphic3d_Vec2i (thePoint.x, thePoint.y), PressedMouseButtons(), aFlags, false))
|
||||
{
|
||||
update3dView();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OnLButtonDown
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OCC_BaseView::OnLButtonDown (UINT theFlags, CPoint thePoint)
|
||||
{
|
||||
const Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent (theFlags);
|
||||
PressMouseButton (Graphic3d_Vec2i (thePoint.x, thePoint.y), Aspect_VKeyMouse_LeftButton, aFlags, false);
|
||||
update3dView();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OnLButtonUp
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OCC_BaseView::OnLButtonUp (UINT theFlags, CPoint thePoint)
|
||||
{
|
||||
const Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent (theFlags);
|
||||
ReleaseMouseButton (Graphic3d_Vec2i (thePoint.x, thePoint.y), Aspect_VKeyMouse_LeftButton, aFlags, false);
|
||||
if (myCurrentMode == CurAction3d_GlobalPanning)
|
||||
{
|
||||
myView->Place (thePoint.x, thePoint.y, myCurZoom);
|
||||
myView->Invalidate();
|
||||
}
|
||||
if (myCurrentMode != CurAction3d_Nothing)
|
||||
{
|
||||
setCurrentAction (CurAction3d_Nothing);
|
||||
}
|
||||
update3dView();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OnMButtonDown
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OCC_BaseView::OnMButtonDown (UINT theFlags, CPoint thePoint)
|
||||
{
|
||||
const Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent (theFlags);
|
||||
PressMouseButton (Graphic3d_Vec2i (thePoint.x, thePoint.y), Aspect_VKeyMouse_MiddleButton, aFlags, false);
|
||||
update3dView();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OnMButtonUp
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OCC_BaseView::OnMButtonUp (UINT theFlags, CPoint thePoint)
|
||||
{
|
||||
const Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent (theFlags);
|
||||
ReleaseMouseButton (Graphic3d_Vec2i (thePoint.x, thePoint.y), Aspect_VKeyMouse_MiddleButton, aFlags, false);
|
||||
update3dView();
|
||||
if (myCurrentMode != CurAction3d_Nothing)
|
||||
{
|
||||
setCurrentAction (CurAction3d_Nothing);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OnRButtonDown
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OCC_BaseView::OnRButtonDown (UINT theFlags, CPoint thePoint)
|
||||
{
|
||||
const Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent (theFlags);
|
||||
PressMouseButton (Graphic3d_Vec2i (thePoint.x, thePoint.y), Aspect_VKeyMouse_RightButton, aFlags, false);
|
||||
update3dView();
|
||||
myClickPos.SetValues (thePoint.x, thePoint.y);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OnRButtonUp
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OCC_BaseView::OnRButtonUp (UINT theFlags, CPoint thePoint)
|
||||
{
|
||||
const Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent (theFlags);
|
||||
ReleaseMouseButton (Graphic3d_Vec2i (thePoint.x, thePoint.y), Aspect_VKeyMouse_RightButton, aFlags, false);
|
||||
update3dView();
|
||||
if (myCurrentMode != CurAction3d_Nothing)
|
||||
{
|
||||
setCurrentAction (CurAction3d_Nothing);
|
||||
}
|
||||
if (aFlags == Aspect_VKeyFlags_NONE
|
||||
&& (myClickPos - Graphic3d_Vec2i (thePoint.x, thePoint.y)).cwiseAbs().maxComp() <= 4)
|
||||
{
|
||||
GetDocument()->Popup (thePoint.x, thePoint.y, myView);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OnMouseWheel
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
BOOL OCC_BaseView::OnMouseWheel (UINT theFlags, short theDelta, CPoint thePoint)
|
||||
{
|
||||
const Standard_Real aDeltaF = Standard_Real(theDelta) / Standard_Real(WHEEL_DELTA);
|
||||
CPoint aCursorPnt = thePoint;
|
||||
ScreenToClient (&aCursorPnt);
|
||||
const Graphic3d_Vec2i aPos (aCursorPnt.x, aCursorPnt.y);
|
||||
const Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent (theFlags);
|
||||
if (UpdateMouseScroll (Aspect_ScrollDelta (aPos, aDeltaF, aFlags)))
|
||||
{
|
||||
update3dView();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OnSize
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OCC_BaseView::OnSize (UINT nType, int cx, int cy)
|
||||
{
|
||||
CView::OnSize (nType, cx, cy);
|
||||
if (cx != 0
|
||||
&& cy != 0
|
||||
&& !myView.IsNull())
|
||||
{
|
||||
myView->Window()->DoResize();
|
||||
myView->MustBeResized();
|
||||
myView->Invalidate();
|
||||
update3dView();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OnMouseLeave
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OCC_BaseView::OnMouseLeave()
|
||||
{
|
||||
CPoint aCursorPos;
|
||||
if (GetCursorPos (&aCursorPos))
|
||||
{
|
||||
ReleaseMouseButton (Graphic3d_Vec2i (aCursorPos.x, aCursorPos.y),
|
||||
PressedMouseButtons(),
|
||||
Aspect_VKeyMouse_NONE,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
@@ -12,37 +12,104 @@
|
||||
#include <stdafx.h>
|
||||
|
||||
#include "OCC_BaseDoc.h"
|
||||
#include "AIS_RubberBand.hxx"
|
||||
#include "AIS_ViewController.hxx"
|
||||
|
||||
class Standard_EXPORT OCC_BaseView : public CView
|
||||
enum CurAction3d
|
||||
{
|
||||
CurAction3d_Nothing,
|
||||
CurAction3d_DynamicZooming,
|
||||
CurAction3d_WindowZooming,
|
||||
CurAction3d_DynamicPanning,
|
||||
CurAction3d_GlobalPanning,
|
||||
CurAction3d_DynamicRotation
|
||||
};
|
||||
|
||||
class Standard_EXPORT OCC_BaseView : public CView, public AIS_ViewController
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
OCC_BaseView();
|
||||
virtual ~OCC_BaseView();
|
||||
|
||||
|
||||
//! Return the view.
|
||||
const Handle(V3d_View)& GetView() const { return myView; }
|
||||
|
||||
void FitAll() { if ( !myView.IsNull() ) myView->FitAll(); myView->ZFitAll(); };
|
||||
void Redraw() { if ( !myView.IsNull() ) myView->Redraw(); };
|
||||
|
||||
void SetZoom ( const Standard_Real& Coef ) { myView->SetZoom ( Coef ); };
|
||||
|
||||
//! Return the document.
|
||||
OCC_BaseDoc* GetDocument();
|
||||
|
||||
protected:
|
||||
|
||||
virtual void drawRectangle (const Standard_Integer theMinX,
|
||||
const Standard_Integer theMinY,
|
||||
const Standard_Integer theMaxX,
|
||||
const Standard_Integer theMaxY,
|
||||
const Handle(AIS_InteractiveContext)& theContext,
|
||||
const Standard_Boolean toDraw = Standard_True);
|
||||
//! Request view redrawing.
|
||||
void update3dView();
|
||||
|
||||
//! Flush events and redraw view.
|
||||
void redraw3dView();
|
||||
|
||||
protected:
|
||||
|
||||
Standard_Real myCurZoom;
|
||||
Standard_Integer myXmin;
|
||||
Standard_Integer myYmin;
|
||||
Standard_Integer myXmax;
|
||||
Standard_Integer myYmax;
|
||||
//! Handle view redraw.
|
||||
virtual void handleViewRedraw (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView) Standard_OVERRIDE;
|
||||
|
||||
Handle(AIS_RubberBand) myRect; //!< Rubber rectangle for selection
|
||||
//! Callback called by handleMoveTo() on Selection in 3D Viewer.
|
||||
virtual void OnSelectionChanged (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView) Standard_OVERRIDE;
|
||||
|
||||
//! Return interactive context.
|
||||
virtual const Handle(AIS_InteractiveContext)& GetAISContext() const;
|
||||
|
||||
protected:
|
||||
|
||||
//! Setup mouse gestures.
|
||||
void defineMouseGestures();
|
||||
|
||||
//! Get current action.
|
||||
CurAction3d getCurrentAction() const { return myCurrentMode; }
|
||||
|
||||
//! Set current action.
|
||||
void setCurrentAction (CurAction3d theAction)
|
||||
{
|
||||
myCurrentMode = theAction;
|
||||
defineMouseGestures();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual BOOL PreCreateWindow (CREATESTRUCT& cs) Standard_OVERRIDE;
|
||||
virtual void PostNcDestroy() Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
Handle(V3d_View) myView;
|
||||
AIS_MouseGestureMap myDefaultGestures;
|
||||
Graphic3d_Vec2i myClickPos;
|
||||
Standard_Real myCurZoom;
|
||||
unsigned int myUpdateRequests; //!< counter for unhandled update requests
|
||||
|
||||
private:
|
||||
|
||||
CurAction3d myCurrentMode;
|
||||
|
||||
// message map functions
|
||||
protected:
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
virtual void OnInitialUpdate() Standard_OVERRIDE;
|
||||
virtual void OnDraw (CDC* /*pDC*/) Standard_OVERRIDE;
|
||||
afx_msg void OnSize (UINT nType, int cx, int cy);
|
||||
afx_msg BOOL OnMouseWheel (UINT theFlags, short theDelta, CPoint thePoint);
|
||||
afx_msg void OnMouseMove (UINT theFlags, CPoint thePoint);
|
||||
afx_msg void OnMouseLeave();
|
||||
afx_msg void OnLButtonDown (UINT theFlags, CPoint thePoint);
|
||||
afx_msg void OnLButtonUp (UINT theFlags, CPoint thePoint);
|
||||
afx_msg void OnMButtonDown (UINT theFlags, CPoint thePoint);
|
||||
afx_msg void OnMButtonUp (UINT theFlags, CPoint thePoint);
|
||||
afx_msg void OnRButtonDown (UINT theFlags, CPoint thePoint);
|
||||
afx_msg void OnRButtonUp (UINT theFlags, CPoint thePoint);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_OCC_BASEVIEW_H__2E048CCA_38F9_11D7_8611_0060B0EE281E__INCLUDED_)
|
||||
|
@@ -29,14 +29,46 @@
|
||||
#include <OcctWindow.h>
|
||||
#include <Aspect_DisplayConnection.hxx>
|
||||
|
||||
// the key for multi selection :
|
||||
#define MULTISELECTIONKEY Qt::ShiftModifier
|
||||
namespace
|
||||
{
|
||||
//! Map Qt buttons bitmask to virtual keys.
|
||||
Aspect_VKeyMouse qtMouseButtons2VKeys (Qt::MouseButtons theButtons)
|
||||
{
|
||||
Aspect_VKeyMouse aButtons = Aspect_VKeyMouse_NONE;
|
||||
if ((theButtons & Qt::LeftButton) != 0)
|
||||
{
|
||||
aButtons |= Aspect_VKeyMouse_LeftButton;
|
||||
}
|
||||
if ((theButtons & Qt::MiddleButton) != 0)
|
||||
{
|
||||
aButtons |= Aspect_VKeyMouse_MiddleButton;
|
||||
}
|
||||
if ((theButtons & Qt::RightButton) != 0)
|
||||
{
|
||||
aButtons |= Aspect_VKeyMouse_RightButton;
|
||||
}
|
||||
return aButtons;
|
||||
}
|
||||
|
||||
// the key for shortcut ( use to activate dynamic rotation, panning )
|
||||
#define CASCADESHORTCUTKEY Qt::ControlModifier
|
||||
|
||||
// for elastic bean selection
|
||||
#define ValZWMin 1
|
||||
//! Map Qt mouse modifiers bitmask to virtual keys.
|
||||
Aspect_VKeyFlags qtMouseModifiers2VKeys (Qt::KeyboardModifiers theModifiers)
|
||||
{
|
||||
Aspect_VKeyFlags aFlags = Aspect_VKeyFlags_NONE;
|
||||
if ((theModifiers & Qt::ShiftModifier) != 0)
|
||||
{
|
||||
aFlags |= Aspect_VKeyFlags_SHIFT;
|
||||
}
|
||||
if ((theModifiers & Qt::ControlModifier) != 0)
|
||||
{
|
||||
aFlags |= Aspect_VKeyFlags_CTRL;
|
||||
}
|
||||
if ((theModifiers & Qt::AltModifier) != 0)
|
||||
{
|
||||
aFlags |= Aspect_VKeyFlags_ALT;
|
||||
}
|
||||
return aFlags;
|
||||
}
|
||||
}
|
||||
|
||||
static QCursor* defCursor = NULL;
|
||||
static QCursor* handCursor = NULL;
|
||||
@@ -60,18 +92,12 @@ View::View( Handle(AIS_InteractiveContext) theContext, QWidget* parent )
|
||||
#endif
|
||||
myContext = theContext;
|
||||
|
||||
myXmin = 0;
|
||||
myYmin = 0;
|
||||
myXmax = 0;
|
||||
myYmax = 0;
|
||||
myCurZoom = 0;
|
||||
myRectBand = 0;
|
||||
|
||||
setAttribute(Qt::WA_PaintOnScreen);
|
||||
setAttribute(Qt::WA_NoSystemBackground);
|
||||
|
||||
myDefaultGestures = myMouseGestureMap;
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
myHlrModeIsOn = Standard_False;
|
||||
setMouseTracking( true );
|
||||
|
||||
initViewActions();
|
||||
@@ -111,7 +137,8 @@ void View::init()
|
||||
void View::paintEvent( QPaintEvent * )
|
||||
{
|
||||
// QApplication::syncX();
|
||||
myView->Redraw();
|
||||
myView->InvalidateImmediate();
|
||||
FlushViewEvents (myContext, myView, true);
|
||||
}
|
||||
|
||||
void View::resizeEvent( QResizeEvent * )
|
||||
@@ -123,6 +150,12 @@ void View::resizeEvent( QResizeEvent * )
|
||||
}
|
||||
}
|
||||
|
||||
void View::OnSelectionChanged (const Handle(AIS_InteractiveContext)& ,
|
||||
const Handle(V3d_View)& )
|
||||
{
|
||||
ApplicationCommonWindow::getApplication()->onSelectionChanged();
|
||||
}
|
||||
|
||||
void View::fitAll()
|
||||
{
|
||||
myView->FitAll();
|
||||
@@ -132,22 +165,22 @@ void View::fitAll()
|
||||
|
||||
void View::fitArea()
|
||||
{
|
||||
myCurrentMode = CurAction3d_WindowZooming;
|
||||
setCurrentAction (CurAction3d_WindowZooming);
|
||||
}
|
||||
|
||||
void View::zoom()
|
||||
{
|
||||
myCurrentMode = CurAction3d_DynamicZooming;
|
||||
setCurrentAction (CurAction3d_DynamicZooming);
|
||||
}
|
||||
|
||||
void View::pan()
|
||||
{
|
||||
myCurrentMode = CurAction3d_DynamicPanning;
|
||||
setCurrentAction (CurAction3d_DynamicPanning);
|
||||
}
|
||||
|
||||
void View::rotation()
|
||||
{
|
||||
myCurrentMode = CurAction3d_DynamicRotation;
|
||||
setCurrentAction (CurAction3d_DynamicRotation);
|
||||
}
|
||||
|
||||
void View::globalPan()
|
||||
@@ -157,7 +190,7 @@ void View::globalPan()
|
||||
// Do a Global Zoom
|
||||
myView->FitAll();
|
||||
// Set the mode
|
||||
myCurrentMode = CurAction3d_GlobalPanning;
|
||||
setCurrentAction (CurAction3d_GlobalPanning);
|
||||
}
|
||||
|
||||
void View::front()
|
||||
@@ -203,8 +236,7 @@ void View::reset()
|
||||
void View::hlrOff()
|
||||
{
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
myHlrModeIsOn = Standard_False;
|
||||
myView->SetComputedMode (myHlrModeIsOn);
|
||||
myView->SetComputedMode (false);
|
||||
myView->Redraw();
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
@@ -212,8 +244,7 @@ void View::hlrOff()
|
||||
void View::hlrOn()
|
||||
{
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
myHlrModeIsOn = Standard_True;
|
||||
myView->SetComputedMode (myHlrModeIsOn);
|
||||
myView->SetComputedMode (true);
|
||||
myView->Redraw();
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
@@ -548,31 +579,6 @@ void View::initRaytraceActions()
|
||||
myRaytraceActions->insert( ToolAntialiasingId, a );
|
||||
}
|
||||
|
||||
void View::mousePressEvent( QMouseEvent* e )
|
||||
{
|
||||
if ( e->button() == Qt::LeftButton )
|
||||
onLButtonDown( ( e->buttons() | e->modifiers() ), e->pos() );
|
||||
else if ( e->button() == Qt::MidButton )
|
||||
onMButtonDown( e->buttons() | e->modifiers(), e->pos() );
|
||||
else if ( e->button() == Qt::RightButton )
|
||||
onRButtonDown( e->buttons() | e->modifiers(), e->pos() );
|
||||
}
|
||||
|
||||
void View::mouseReleaseEvent(QMouseEvent* e)
|
||||
{
|
||||
if ( e->button() == Qt::LeftButton )
|
||||
onLButtonUp( e->buttons(), e->pos() );
|
||||
else if ( e->button() == Qt::MidButton )
|
||||
onMButtonUp( e->buttons(), e->pos() );
|
||||
else if( e->button() == Qt::RightButton )
|
||||
onRButtonUp( e->buttons(), e->pos() );
|
||||
}
|
||||
|
||||
void View::mouseMoveEvent(QMouseEvent* e)
|
||||
{
|
||||
onMouseMove( e->buttons(), e->pos() );
|
||||
}
|
||||
|
||||
void View::activateCursor( const CurrentAction3d mode )
|
||||
{
|
||||
switch( mode )
|
||||
@@ -599,276 +605,124 @@ void View::activateCursor( const CurrentAction3d mode )
|
||||
}
|
||||
}
|
||||
|
||||
void View::onLButtonDown( const int/*Qt::MouseButtons*/ nFlags, const QPoint point )
|
||||
void View::mousePressEvent (QMouseEvent* theEvent)
|
||||
{
|
||||
// save the current mouse coordinate in min
|
||||
myXmin = point.x();
|
||||
myYmin = point.y();
|
||||
myXmax = point.x();
|
||||
myYmax = point.y();
|
||||
|
||||
if ( nFlags & CASCADESHORTCUTKEY )
|
||||
const Graphic3d_Vec2i aPnt (theEvent->pos().x(), theEvent->pos().y());
|
||||
const Aspect_VKeyFlags aFlags = qtMouseModifiers2VKeys (theEvent->modifiers());
|
||||
if (!myView.IsNull()
|
||||
&& UpdateMouseButtons (aPnt,
|
||||
qtMouseButtons2VKeys (theEvent->buttons()),
|
||||
aFlags,
|
||||
false))
|
||||
{
|
||||
myCurrentMode = CurAction3d_DynamicZooming;
|
||||
updateView();
|
||||
}
|
||||
else
|
||||
myClickPos = aPnt;
|
||||
}
|
||||
|
||||
void View::mouseReleaseEvent (QMouseEvent* theEvent)
|
||||
{
|
||||
const Graphic3d_Vec2i aPnt (theEvent->pos().x(), theEvent->pos().y());
|
||||
const Aspect_VKeyFlags aFlags = qtMouseModifiers2VKeys (theEvent->modifiers());
|
||||
if (!myView.IsNull()
|
||||
&& UpdateMouseButtons (aPnt,
|
||||
qtMouseButtons2VKeys (theEvent->buttons()),
|
||||
aFlags,
|
||||
false))
|
||||
{
|
||||
switch ( myCurrentMode )
|
||||
updateView();
|
||||
}
|
||||
|
||||
if (myCurrentMode == CurAction3d_GlobalPanning)
|
||||
{
|
||||
myView->Place (aPnt.x(), aPnt.y(), myCurZoom);
|
||||
}
|
||||
if (myCurrentMode != CurAction3d_Nothing)
|
||||
{
|
||||
setCurrentAction (CurAction3d_Nothing);
|
||||
}
|
||||
if (theEvent->button() == Qt::RightButton
|
||||
&& (aFlags & Aspect_VKeyFlags_CTRL) == 0
|
||||
&& (myClickPos - aPnt).cwiseAbs().maxComp() <= 4)
|
||||
{
|
||||
Popup (aPnt.x(), aPnt.y());
|
||||
}
|
||||
}
|
||||
|
||||
void View::mouseMoveEvent (QMouseEvent* theEvent)
|
||||
{
|
||||
const Graphic3d_Vec2i aNewPos (theEvent->pos().x(), theEvent->pos().y());
|
||||
if (!myView.IsNull()
|
||||
&& UpdateMousePosition (aNewPos,
|
||||
qtMouseButtons2VKeys (theEvent->buttons()),
|
||||
qtMouseModifiers2VKeys (theEvent->modifiers()),
|
||||
false))
|
||||
{
|
||||
updateView();
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//function : wheelEvent
|
||||
//purpose :
|
||||
//==============================================================================
|
||||
void View::wheelEvent (QWheelEvent* theEvent)
|
||||
{
|
||||
const Graphic3d_Vec2i aPos (theEvent->pos().x(), theEvent->pos().y());
|
||||
if (!myView.IsNull()
|
||||
&& UpdateZoom (Aspect_ScrollDelta (aPos, theEvent->delta() / 8)))
|
||||
{
|
||||
updateView();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : updateView
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View::updateView()
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
void View::defineMouseGestures()
|
||||
{
|
||||
myMouseGestureMap.Clear();
|
||||
AIS_MouseGesture aRot = AIS_MouseGesture_RotateOrbit;
|
||||
activateCursor (myCurrentMode);
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case CurAction3d_Nothing:
|
||||
{
|
||||
case CurAction3d_Nothing:
|
||||
if ( nFlags & MULTISELECTIONKEY )
|
||||
MultiDragEvent( myXmax, myYmax, -1 );
|
||||
else
|
||||
DragEvent( myXmax, myYmax, -1 );
|
||||
break;
|
||||
case CurAction3d_DynamicZooming:
|
||||
break;
|
||||
case CurAction3d_WindowZooming:
|
||||
break;
|
||||
case CurAction3d_DynamicPanning:
|
||||
break;
|
||||
case CurAction3d_GlobalPanning:
|
||||
break;
|
||||
case CurAction3d_DynamicRotation:
|
||||
if (myHlrModeIsOn)
|
||||
{
|
||||
myView->SetComputedMode (Standard_False);
|
||||
}
|
||||
myView->StartRotation( point.x(), point.y() );
|
||||
break;
|
||||
default:
|
||||
throw Standard_Failure( "incompatible Current Mode" );
|
||||
break;
|
||||
noActiveActions();
|
||||
myMouseGestureMap = myDefaultGestures;
|
||||
break;
|
||||
}
|
||||
case CurAction3d_DynamicZooming:
|
||||
{
|
||||
myMouseGestureMap.Bind (Aspect_VKeyMouse_LeftButton, AIS_MouseGesture_Zoom);
|
||||
break;
|
||||
}
|
||||
case CurAction3d_GlobalPanning:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case CurAction3d_WindowZooming:
|
||||
{
|
||||
myMouseGestureMap.Bind (Aspect_VKeyMouse_LeftButton, AIS_MouseGesture_ZoomWindow);
|
||||
break;
|
||||
}
|
||||
case CurAction3d_DynamicPanning:
|
||||
{
|
||||
myMouseGestureMap.Bind (Aspect_VKeyMouse_LeftButton, AIS_MouseGesture_Pan);
|
||||
break;
|
||||
}
|
||||
case CurAction3d_DynamicRotation:
|
||||
{
|
||||
myMouseGestureMap.Bind (Aspect_VKeyMouse_LeftButton, aRot);
|
||||
break;
|
||||
}
|
||||
}
|
||||
activateCursor( myCurrentMode );
|
||||
}
|
||||
|
||||
void View::onMButtonDown( const int/*Qt::MouseButtons*/ nFlags, const QPoint /*point*/ )
|
||||
{
|
||||
if ( nFlags & CASCADESHORTCUTKEY )
|
||||
myCurrentMode = CurAction3d_DynamicPanning;
|
||||
activateCursor( myCurrentMode );
|
||||
}
|
||||
|
||||
void View::onRButtonDown( const int/*Qt::MouseButtons*/ nFlags, const QPoint point )
|
||||
{
|
||||
if ( nFlags & CASCADESHORTCUTKEY )
|
||||
{
|
||||
if (myHlrModeIsOn)
|
||||
{
|
||||
myView->SetComputedMode (Standard_False);
|
||||
}
|
||||
myCurrentMode = CurAction3d_DynamicRotation;
|
||||
myView->StartRotation( point.x(), point.y() );
|
||||
}
|
||||
else
|
||||
{
|
||||
Popup( point.x(), point.y() );
|
||||
}
|
||||
activateCursor( myCurrentMode );
|
||||
}
|
||||
|
||||
void View::onLButtonUp( Qt::MouseButtons nFlags, const QPoint point )
|
||||
{
|
||||
switch( myCurrentMode )
|
||||
{
|
||||
case CurAction3d_Nothing:
|
||||
if ( point.x() == myXmin && point.y() == myYmin )
|
||||
{
|
||||
// no offset between down and up --> selectEvent
|
||||
myXmax = point.x();
|
||||
myYmax = point.y();
|
||||
if ( nFlags & MULTISELECTIONKEY )
|
||||
MultiInputEvent( point.x(), point.y() );
|
||||
else
|
||||
InputEvent( point.x(), point.y() );
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawRectangle( myXmin, myYmin, myXmax, myYmax, Standard_False );
|
||||
myXmax = point.x();
|
||||
myYmax = point.y();
|
||||
if ( nFlags & MULTISELECTIONKEY )
|
||||
MultiDragEvent( point.x(), point.y(), 1 );
|
||||
else
|
||||
DragEvent( point.x(), point.y(), 1 );
|
||||
}
|
||||
break;
|
||||
case CurAction3d_DynamicZooming:
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
noActiveActions();
|
||||
break;
|
||||
case CurAction3d_WindowZooming:
|
||||
DrawRectangle( myXmin, myYmin, myXmax, myYmax, Standard_False );//,LongDash);
|
||||
myXmax = point.x();
|
||||
myYmax = point.y();
|
||||
if ( (abs( myXmin - myXmax ) > ValZWMin ) ||
|
||||
(abs( myYmin - myYmax ) > ValZWMin ) )
|
||||
myView->WindowFitAll( myXmin, myYmin, myXmax, myYmax );
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
noActiveActions();
|
||||
break;
|
||||
case CurAction3d_DynamicPanning:
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
noActiveActions();
|
||||
break;
|
||||
case CurAction3d_GlobalPanning :
|
||||
myView->Place( point.x(), point.y(), myCurZoom );
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
noActiveActions();
|
||||
break;
|
||||
case CurAction3d_DynamicRotation:
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
noActiveActions();
|
||||
break;
|
||||
default:
|
||||
throw Standard_Failure(" incompatible Current Mode ");
|
||||
break;
|
||||
}
|
||||
activateCursor( myCurrentMode );
|
||||
ApplicationCommonWindow::getApplication()->onSelectionChanged();
|
||||
}
|
||||
|
||||
void View::onMButtonUp( Qt::MouseButtons /*nFlags*/, const QPoint /*point*/ )
|
||||
{
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
activateCursor( myCurrentMode );
|
||||
}
|
||||
|
||||
void View::onRButtonUp( Qt::MouseButtons /*nFlags*/, const QPoint point )
|
||||
{
|
||||
if ( myCurrentMode == CurAction3d_Nothing )
|
||||
Popup( point.x(), point.y() );
|
||||
else
|
||||
{
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
// reset tyhe good Degenerated mode according to the strored one
|
||||
// --> dynamic rotation may have change it
|
||||
if (myHlrModeIsOn)
|
||||
{
|
||||
myView->SetComputedMode (myHlrModeIsOn);
|
||||
myView->Redraw();
|
||||
}
|
||||
QApplication::restoreOverrideCursor();
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
}
|
||||
activateCursor( myCurrentMode );
|
||||
}
|
||||
|
||||
void View::onMouseMove( Qt::MouseButtons nFlags, const QPoint point )
|
||||
{
|
||||
if ( nFlags & Qt::LeftButton || nFlags & Qt::RightButton || nFlags & Qt::MidButton )
|
||||
{
|
||||
switch ( myCurrentMode )
|
||||
{
|
||||
case CurAction3d_Nothing:
|
||||
myXmax = point.x();
|
||||
myYmax = point.y();
|
||||
DrawRectangle( myXmin, myYmin, myXmax, myYmax, Standard_False );
|
||||
if ( nFlags & MULTISELECTIONKEY )
|
||||
MultiDragEvent( myXmax, myYmax, 0 );
|
||||
else
|
||||
DragEvent( myXmax, myYmax, 0 );
|
||||
DrawRectangle( myXmin, myYmin, myXmax, myYmax, Standard_True );
|
||||
break;
|
||||
case CurAction3d_DynamicZooming:
|
||||
myView->Zoom( myXmax, myYmax, point.x(), point.y() );
|
||||
myXmax = point.x();
|
||||
myYmax = point.y();
|
||||
break;
|
||||
case CurAction3d_WindowZooming:
|
||||
myXmax = point.x();
|
||||
myYmax = point.y();
|
||||
DrawRectangle( myXmin, myYmin, myXmax, myYmax, Standard_False );
|
||||
DrawRectangle( myXmin, myYmin, myXmax, myYmax, Standard_True );
|
||||
break;
|
||||
case CurAction3d_DynamicPanning:
|
||||
myView->Pan( point.x() - myXmax, myYmax - point.y() );
|
||||
myXmax = point.x();
|
||||
myYmax = point.y();
|
||||
break;
|
||||
case CurAction3d_GlobalPanning:
|
||||
break;
|
||||
case CurAction3d_DynamicRotation:
|
||||
myView->Rotation( point.x(), point.y() );
|
||||
myView->Redraw();
|
||||
break;
|
||||
default:
|
||||
throw Standard_Failure( "incompatible Current Mode" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
myXmax = point.x();
|
||||
myYmax = point.y();
|
||||
if ( nFlags & MULTISELECTIONKEY )
|
||||
MultiMoveEvent( point.x(), point.y() );
|
||||
else
|
||||
MoveEvent( point.x(), point.y() );
|
||||
}
|
||||
}
|
||||
|
||||
void View::DragEvent( const int x, const int y, const int TheState )
|
||||
{
|
||||
// TheState == -1 button down
|
||||
// TheState == 0 move
|
||||
// TheState == 1 button up
|
||||
|
||||
static Standard_Integer theButtonDownX = 0;
|
||||
static Standard_Integer theButtonDownY = 0;
|
||||
|
||||
if ( TheState == -1 )
|
||||
{
|
||||
theButtonDownX = x;
|
||||
theButtonDownY = y;
|
||||
}
|
||||
|
||||
if ( TheState == 1 )
|
||||
{
|
||||
myContext->Select( theButtonDownX, theButtonDownY, x, y, myView, Standard_True );
|
||||
emit selectionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void View::InputEvent( const int /*x*/, const int /*y*/ )
|
||||
{
|
||||
myContext->Select (Standard_True);
|
||||
emit selectionChanged();
|
||||
}
|
||||
|
||||
void View::MoveEvent( const int x, const int y )
|
||||
{
|
||||
myContext->MoveTo( x, y, myView, Standard_True );
|
||||
}
|
||||
|
||||
void View::MultiMoveEvent( const int x, const int y )
|
||||
{
|
||||
myContext->MoveTo( x, y, myView, Standard_True );
|
||||
}
|
||||
|
||||
void View::MultiDragEvent( const int x, const int y, const int TheState )
|
||||
{
|
||||
static Standard_Integer theButtonDownX = 0;
|
||||
static Standard_Integer theButtonDownY = 0;
|
||||
|
||||
if ( TheState == -1 )
|
||||
{
|
||||
theButtonDownX = x;
|
||||
theButtonDownY = y;
|
||||
}
|
||||
if ( TheState == 0 )
|
||||
{
|
||||
myContext->ShiftSelect( theButtonDownX, theButtonDownY, x, y, myView, Standard_True );
|
||||
emit selectionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void View::MultiInputEvent( const int /*x*/, const int /*y*/ )
|
||||
{
|
||||
myContext->ShiftSelect (Standard_True);
|
||||
emit selectionChanged();
|
||||
}
|
||||
|
||||
void View::Popup( const int /*x*/, const int /*y*/ )
|
||||
@@ -930,49 +784,6 @@ void View::addItemInPopup( QMenu* /*theMenu*/)
|
||||
{
|
||||
}
|
||||
|
||||
void View::DrawRectangle(const int MinX, const int MinY,
|
||||
const int MaxX, const int MaxY, const bool Draw)
|
||||
{
|
||||
static Standard_Integer StoredMinX, StoredMaxX, StoredMinY, StoredMaxY;
|
||||
static Standard_Boolean m_IsVisible;
|
||||
|
||||
StoredMinX = (MinX < MaxX) ? MinX: MaxX ;
|
||||
StoredMinY = (MinY < MaxY) ? MinY: MaxY ;
|
||||
StoredMaxX = (MinX > MaxX) ? MinX: MaxX ;
|
||||
StoredMaxY = (MinY > MaxY) ? MinY: MaxY ;
|
||||
|
||||
QRect aRect;
|
||||
aRect.setRect( StoredMinX, StoredMinY, abs(StoredMaxX-StoredMinX), abs(StoredMaxY-StoredMinY));
|
||||
|
||||
if ( !myRectBand )
|
||||
{
|
||||
myRectBand = new QRubberBand( QRubberBand::Rectangle, this );
|
||||
myRectBand->setStyle( QStyleFactory::create("windows") );
|
||||
myRectBand->setGeometry( aRect );
|
||||
myRectBand->show();
|
||||
|
||||
/*QPalette palette;
|
||||
palette.setColor(myRectBand->foregroundRole(), Qt::white);
|
||||
myRectBand->setPalette(palette);*/
|
||||
}
|
||||
|
||||
if ( m_IsVisible && !Draw ) // move or up : erase at the old position
|
||||
{
|
||||
myRectBand->hide();
|
||||
delete myRectBand;
|
||||
myRectBand = 0;
|
||||
m_IsVisible = false;
|
||||
}
|
||||
|
||||
if (Draw) // move : draw
|
||||
{
|
||||
//aRect.setRect( StoredMinX, StoredMinY, abs(StoredMaxX-StoredMinX), abs(StoredMaxY-StoredMinY));
|
||||
m_IsVisible = true;
|
||||
myRectBand->setGeometry( aRect );
|
||||
//myRectBand->show();
|
||||
}
|
||||
}
|
||||
|
||||
void View::noActiveActions()
|
||||
{
|
||||
for ( int i = ViewFitAllId; i < ViewHlrOffId ; i++ )
|
||||
@@ -1052,6 +863,3 @@ View::CurrentAction3d View::getCurrentMode()
|
||||
{
|
||||
return myCurrentMode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@@ -8,13 +8,14 @@
|
||||
#include <Standard_WarningsRestore.hxx>
|
||||
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_ViewController.hxx>
|
||||
#include <V3d_View.hxx>
|
||||
|
||||
class TopoDS_Shape;
|
||||
class QRubberBand;
|
||||
|
||||
//class COMMONSAMPLE_EXPORT View: public QWidget
|
||||
class View: public QWidget
|
||||
class View: public QWidget, protected AIS_ViewController
|
||||
{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
@@ -95,6 +96,7 @@ protected:
|
||||
virtual void mousePressEvent( QMouseEvent* );
|
||||
virtual void mouseReleaseEvent(QMouseEvent* );
|
||||
virtual void mouseMoveEvent( QMouseEvent* );
|
||||
virtual void wheelEvent (QWheelEvent* );
|
||||
|
||||
virtual void addItemInPopup( QMenu* );
|
||||
|
||||
@@ -103,48 +105,41 @@ protected:
|
||||
void activateCursor( const CurrentAction3d );
|
||||
void Popup( const int x, const int y );
|
||||
CurrentAction3d getCurrentMode();
|
||||
void updateView();
|
||||
|
||||
virtual void onLButtonDown( const int nFlags, const QPoint point );
|
||||
virtual void onMButtonDown( const int nFlags, const QPoint point );
|
||||
virtual void onRButtonDown( const int nFlags, const QPoint point );
|
||||
virtual void onLButtonUp( Qt::MouseButtons nFlags, const QPoint point );
|
||||
virtual void onMButtonUp( Qt::MouseButtons nFlags, const QPoint point );
|
||||
virtual void onRButtonUp( Qt::MouseButtons nFlags, const QPoint point );
|
||||
virtual void onMouseMove( Qt::MouseButtons nFlags, const QPoint point );
|
||||
//! Setup mouse gestures.
|
||||
void defineMouseGestures();
|
||||
|
||||
//! Set current action.
|
||||
void setCurrentAction (CurrentAction3d theAction)
|
||||
{
|
||||
myCurrentMode = theAction;
|
||||
defineMouseGestures();
|
||||
}
|
||||
|
||||
//! Handle selection changed event.
|
||||
void OnSelectionChanged (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
void initCursors();
|
||||
void initViewActions();
|
||||
void initRaytraceActions();
|
||||
void DragEvent( const int x, const int y, const int TheState );
|
||||
void InputEvent( const int x, const int y );
|
||||
void MoveEvent( const int x, const int y );
|
||||
void MultiMoveEvent( const int x, const int y );
|
||||
void MultiDragEvent( const int x, const int y, const int TheState );
|
||||
void MultiInputEvent( const int x, const int y );
|
||||
void DrawRectangle( const int MinX, const int MinY,
|
||||
const int MaxX, const int MaxY, const bool Draw );
|
||||
|
||||
private:
|
||||
bool myIsRaytracing;
|
||||
bool myIsShadowsEnabled;
|
||||
bool myIsReflectionsEnabled;
|
||||
bool myIsAntialiasingEnabled;
|
||||
|
||||
bool myDrawRect; // set when a rect is used for selection or magnify
|
||||
Handle(V3d_View) myView;
|
||||
Handle(AIS_InteractiveContext) myContext;
|
||||
AIS_MouseGestureMap myDefaultGestures;
|
||||
Graphic3d_Vec2i myClickPos;
|
||||
CurrentAction3d myCurrentMode;
|
||||
Standard_Integer myXmin;
|
||||
Standard_Integer myYmin;
|
||||
Standard_Integer myXmax;
|
||||
Standard_Integer myYmax;
|
||||
Standard_Real myCurZoom;
|
||||
Standard_Boolean myHlrModeIsOn;
|
||||
QList<QAction*>* myViewActions;
|
||||
QList<QAction*>* myRaytraceActions;
|
||||
QMenu* myBackMenu;
|
||||
QRubberBand* myRectBand; //!< selection rectangle rubber band
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -21,10 +21,15 @@ enum AIS_MouseGesture
|
||||
{
|
||||
AIS_MouseGesture_NONE, //!< no active gesture
|
||||
//
|
||||
AIS_MouseGesture_SelectRectangle, //!< rectangular selection
|
||||
AIS_MouseGesture_SelectLasso, //!< polygonal selection
|
||||
AIS_MouseGesture_SelectRectangle, //!< rectangular selection;
|
||||
//! press button to start, move mouse to define rectangle, release to finish
|
||||
AIS_MouseGesture_SelectLasso, //!< polygonal selection;
|
||||
//! press button to start, move mouse to define polygonal path, release to finish
|
||||
//
|
||||
AIS_MouseGesture_Zoom, //!< view zoom gesture
|
||||
AIS_MouseGesture_Zoom, //!< view zoom gesture;
|
||||
//! move mouse left to zoom-out, and to the right to zoom-in
|
||||
AIS_MouseGesture_ZoomWindow, //!< view zoom by window gesture;
|
||||
//! press button to start, move mouse to define rectangle, release to finish
|
||||
AIS_MouseGesture_Pan, //!< view panning gesture
|
||||
AIS_MouseGesture_RotateOrbit, //!< orbit rotation gesture
|
||||
AIS_MouseGesture_RotateView, //!< view rotation gesture
|
||||
|
@@ -153,9 +153,8 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
|
||||
}
|
||||
catch (Standard_Failure const& anException)
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString()
|
||||
+ "Error: AIS_Shape::Compute() wireframe presentation builder has failed ("
|
||||
+ anException.GetMessageString() + ")", Message_Fail);
|
||||
Message::SendFail (TCollection_AsciiString("Error: AIS_Shape::Compute() wireframe presentation builder has failed (")
|
||||
+ anException.GetMessageString() + ")");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -184,9 +183,8 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
|
||||
}
|
||||
catch (Standard_Failure const& anException)
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString()
|
||||
+ "Error: AIS_Shape::Compute() shaded presentation builder has failed ("
|
||||
+ anException.GetMessageString() + ")", Message_Fail);
|
||||
Message::SendFail (TCollection_AsciiString("Error: AIS_Shape::Compute() shaded presentation builder has failed (")
|
||||
+ anException.GetMessageString() + ")");
|
||||
StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
|
||||
}
|
||||
}
|
||||
@@ -295,9 +293,8 @@ void AIS_Shape::computeHlrPresentation (const Handle(Graphic3d_Camera)& theProje
|
||||
}
|
||||
catch (Standard_Failure const& anException)
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString()
|
||||
+ "Error: AIS_Shape::Compute() HLR Algorithm has failed ("
|
||||
+ anException.GetMessageString() + ")", Message_Fail);
|
||||
Message::SendFail (TCollection_AsciiString("Error: AIS_Shape::Compute() HLR Algorithm has failed (")
|
||||
+ anException.GetMessageString() + ")");
|
||||
StdPrs_WFShape::Add (thePrs, theShape, theDrawer);
|
||||
}
|
||||
}
|
||||
@@ -339,9 +336,8 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
|
||||
}
|
||||
catch (Standard_Failure const& anException)
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString()
|
||||
+ "Error: AIS_Shape::ComputeSelection(" + aMode + ") has failed ("
|
||||
+ anException.GetMessageString() + ")", Message_Fail);
|
||||
Message::SendFail (TCollection_AsciiString("Error: AIS_Shape::ComputeSelection(") + aMode + ") has failed ("
|
||||
+ anException.GetMessageString() + ")");
|
||||
if (aMode == 0)
|
||||
{
|
||||
aSelection->Clear();
|
||||
|
@@ -37,9 +37,10 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_TextLabel,AIS_InteractiveObject)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_TextLabel::AIS_TextLabel()
|
||||
: myText ("?"),
|
||||
myHasOrientation3D (Standard_False),
|
||||
myHasFlipping (Standard_False)
|
||||
: myText ("?"),
|
||||
myHasOrientation3D (Standard_False),
|
||||
myHasOwnAnchorPoint (Standard_True),
|
||||
myHasFlipping (Standard_False)
|
||||
{
|
||||
myDrawer->SetTextAspect (new Prs3d_TextAspect());
|
||||
myDrawer->SetDisplayMode (0);
|
||||
@@ -322,7 +323,12 @@ void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePr
|
||||
|
||||
gp_Ax2 anOrientation = myOrientation3D;
|
||||
anOrientation.SetLocation (aPosition);
|
||||
Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (thePrs), anAsp, myText, myOrientation3D, !myHasFlipping);
|
||||
Standard_Boolean aHasOwnAnchor = HasOwnAnchorPoint();
|
||||
if (myHasFlipping)
|
||||
{
|
||||
aHasOwnAnchor = Standard_False; // always not using own anchor if flipping
|
||||
}
|
||||
Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (thePrs), anAsp, myText, myOrientation3D, aHasOwnAnchor);
|
||||
if (myHasFlipping && isInit)
|
||||
{
|
||||
Prs3d_Root::CurrentGroup (thePrs)->SetFlippingOptions (Standard_False, gp_Ax2());
|
||||
|
@@ -102,6 +102,12 @@ public:
|
||||
|
||||
Standard_EXPORT Standard_Boolean HasFlipping() const;
|
||||
|
||||
//! Returns flag if text uses position as point of attach
|
||||
Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchorPoint; }
|
||||
|
||||
//! Set flag if text uses position as point of attach
|
||||
void SetOwnAnchorPoint (const Standard_Boolean theOwnAnchorPoint) { myHasOwnAnchorPoint = theOwnAnchorPoint; }
|
||||
|
||||
//! Define the display type of the text.
|
||||
//!
|
||||
//! TODT_NORMAL Default display. Text only.
|
||||
@@ -131,6 +137,7 @@ protected:
|
||||
TCollection_ExtendedString myText;
|
||||
gp_Ax2 myOrientation3D;
|
||||
Standard_Boolean myHasOrientation3D;
|
||||
Standard_Boolean myHasOwnAnchorPoint;
|
||||
Standard_Boolean myHasFlipping;
|
||||
|
||||
public:
|
||||
|
@@ -76,8 +76,8 @@ void AIS_TexturedShape::SetTextureFileName (const TCollection_AsciiString& theTe
|
||||
}
|
||||
else
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: texture with ID ") + theTextureFileName
|
||||
+ " is undefined! Texture 0 will be used instead.", Message_Fail);
|
||||
Message::SendFail (TCollection_AsciiString ("Error: texture with ID ") + theTextureFileName
|
||||
+ " is undefined. Texture 0 will be used instead.");
|
||||
myPredefTexture = Graphic3d_NameOfTexture2D (0);
|
||||
}
|
||||
myTextureFile = "";
|
||||
@@ -311,7 +311,7 @@ void AIS_TexturedShape::updateAttributes (const Handle(Prs3d_Presentation)& theP
|
||||
}
|
||||
else
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: texture can not be loaded ") + aTextureDesc, Message_Fail);
|
||||
Message::SendFail (TCollection_AsciiString ("Error: texture can not be loaded ") + aTextureDesc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,8 +18,12 @@
|
||||
#include <AIS_Manipulator.hxx>
|
||||
#include <AIS_Point.hxx>
|
||||
#include <AIS_RubberBand.hxx>
|
||||
#include <AIS_XRTrackedDevice.hxx>
|
||||
#include <Aspect_XRSession.hxx>
|
||||
#include <Aspect_Grid.hxx>
|
||||
#include <Geom_CartesianPoint.hxx>
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Graphic3d_Texture2Dmanual.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <gp_Quaternion.hxx>
|
||||
@@ -60,6 +64,17 @@ AIS_ViewController::AIS_ViewController()
|
||||
myPrevMoveTo (-1, -1),
|
||||
myHasHlrOnBeforeRotation (false),
|
||||
//
|
||||
myXRPrsDevices (0, 0),
|
||||
myXRLaserTeleColor (Quantity_NOC_GREEN),
|
||||
myXRLaserPickColor (Quantity_NOC_BLUE),
|
||||
myXRLastTeleportHand(Aspect_XRTrackedDeviceRole_Other),
|
||||
myXRLastPickingHand (Aspect_XRTrackedDeviceRole_Other),
|
||||
myXRLastPickDepthLeft (Precision::Infinite()),
|
||||
myXRLastPickDepthRight(Precision::Infinite()),
|
||||
myXRTurnAngle (M_PI_4),
|
||||
myToDisplayXRAuxDevices (false),
|
||||
myToDisplayXRHands (true),
|
||||
//
|
||||
myMouseClickThreshold (3.0),
|
||||
myMouseDoubleClickInt (0.4),
|
||||
myScrollZoomRatio (15.0f),
|
||||
@@ -111,6 +126,18 @@ AIS_ViewController::AIS_ViewController()
|
||||
|
||||
myMouseGestureMap.Bind (Aspect_VKeyMouse_MiddleButton, AIS_MouseGesture_Pan);
|
||||
myMouseGestureMap.Bind (Aspect_VKeyMouse_MiddleButton | Aspect_VKeyFlags_CTRL, AIS_MouseGesture_Pan);
|
||||
|
||||
myXRTeleportHaptic.Duration = 3600.0f;
|
||||
myXRTeleportHaptic.Frequency = 0.1f;
|
||||
myXRTeleportHaptic.Amplitude = 0.2f;
|
||||
|
||||
myXRPickingHaptic.Duration = 0.1f;
|
||||
myXRPickingHaptic.Frequency = 4.0f;
|
||||
myXRPickingHaptic.Amplitude = 0.1f;
|
||||
|
||||
myXRSelectHaptic.Duration = 0.2f;
|
||||
myXRSelectHaptic.Frequency = 4.0f;
|
||||
myXRSelectHaptic.Amplitude = 0.5f;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -721,6 +748,7 @@ bool AIS_ViewController::UpdateMouseButtons (const Graphic3d_Vec2i& thePoint,
|
||||
break;
|
||||
}
|
||||
case AIS_MouseGesture_Zoom:
|
||||
case AIS_MouseGesture_ZoomWindow:
|
||||
{
|
||||
if (!myToAllowZooming)
|
||||
{
|
||||
@@ -756,7 +784,8 @@ bool AIS_ViewController::UpdateMouseButtons (const Graphic3d_Vec2i& thePoint,
|
||||
if (aPrevGesture != myMouseActiveGesture)
|
||||
{
|
||||
if (aPrevGesture == AIS_MouseGesture_SelectRectangle
|
||||
|| aPrevGesture == AIS_MouseGesture_SelectLasso)
|
||||
|| aPrevGesture == AIS_MouseGesture_SelectLasso
|
||||
|| aPrevGesture == AIS_MouseGesture_ZoomWindow)
|
||||
{
|
||||
myUI.Selection.ToApplyTool = true;
|
||||
}
|
||||
@@ -828,8 +857,13 @@ bool AIS_ViewController::UpdateMousePosition (const Graphic3d_Vec2i& thePoint,
|
||||
switch (myMouseActiveGesture)
|
||||
{
|
||||
case AIS_MouseGesture_SelectRectangle:
|
||||
case AIS_MouseGesture_ZoomWindow:
|
||||
{
|
||||
UpdateRubberBand (myMousePressPoint, thePoint);
|
||||
if (myMouseActiveGesture == AIS_MouseGesture_ZoomWindow)
|
||||
{
|
||||
myUI.Selection.Tool = AIS_ViewSelectionTool_ZoomWindow;
|
||||
}
|
||||
toUpdateView = true;
|
||||
break;
|
||||
}
|
||||
@@ -1280,6 +1314,7 @@ void AIS_ViewController::handlePanning (const Handle(V3d_View)& theView)
|
||||
{
|
||||
theView->Pan (myGL.Panning.Delta.x(), myGL.Panning.Delta.y());
|
||||
theView->Invalidate();
|
||||
theView->View()->SynchronizeXRPosedToBaseCamera();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1300,6 +1335,7 @@ void AIS_ViewController::handlePanning (const Handle(V3d_View)& theView)
|
||||
aPanTrsf.SetTranslation (aCameraPan);
|
||||
aCam->Transform (aPanTrsf);
|
||||
theView->Invalidate();
|
||||
theView->View()->SynchronizeXRPosedToBaseCamera();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -1324,6 +1360,7 @@ void AIS_ViewController::handleZRotate (const Handle(V3d_View)& theView)
|
||||
aRotPnt.y() += myGL.ZRotate.Angle * aViewPort.y();
|
||||
theView->Rotation (int(aRotPnt.x()), int(aRotPnt.y()));
|
||||
theView->Invalidate();
|
||||
theView->View()->SynchronizeXRPosedToBaseCamera();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -1354,6 +1391,7 @@ void AIS_ViewController::handleZoom (const Handle(V3d_View)& theView,
|
||||
aCoeff = theParams.Delta > 0.0 ? aCoeff : 1.0 / aCoeff;
|
||||
theView->SetZoom (aCoeff, true);
|
||||
theView->Invalidate();
|
||||
theView->View()->SynchronizeXRPosedToBaseCamera();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1425,6 +1463,7 @@ void AIS_ViewController::handleZoom (const Handle(V3d_View)& theView,
|
||||
aPanTrsf.SetTranslation (aCameraPan);
|
||||
aCam->Transform (aPanTrsf);
|
||||
theView->Invalidate();
|
||||
theView->View()->SynchronizeXRPosedToBaseCamera();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -1445,7 +1484,7 @@ void AIS_ViewController::handleZFocusScroll (const Handle(V3d_View)& theView,
|
||||
&& aFocus < 2.0)
|
||||
{
|
||||
theView->Camera()->SetZFocus (theView->Camera()->ZFocusType(), aFocus);
|
||||
theView->Redraw();
|
||||
theView->Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1462,7 +1501,9 @@ void AIS_ViewController::handleOrbitRotation (const Handle(V3d_View)& theView,
|
||||
return;
|
||||
}
|
||||
|
||||
const Handle(Graphic3d_Camera)& aCam = theView->Camera();
|
||||
const Handle(Graphic3d_Camera)& aCam = theView->View()->IsActiveXR()
|
||||
? theView->View()->BaseXRCamera()
|
||||
: theView->Camera();
|
||||
if (myGL.OrbitRotation.ToStart)
|
||||
{
|
||||
// default alternatives
|
||||
@@ -1501,9 +1542,13 @@ void AIS_ViewController::handleOrbitRotation (const Handle(V3d_View)& theView,
|
||||
theView->Window()->Size (aWinXY.x(), aWinXY.y());
|
||||
double aYawAngleDelta = ((myGL.OrbitRotation.PointStart.x() - myGL.OrbitRotation.PointTo.x()) / double (aWinXY.x())) * (M_PI * 0.5);
|
||||
double aPitchAngleDelta = -((myGL.OrbitRotation.PointStart.y() - myGL.OrbitRotation.PointTo.y()) / double (aWinXY.y())) * (M_PI * 0.5);
|
||||
const double aPitchAngleNew = Max (Min (myRotateStartYawPitchRoll[1] + aPitchAngleDelta, M_PI * 0.5 - M_PI / 180.0), -M_PI * 0.5 + M_PI / 180.0);
|
||||
const double aYawAngleNew = myRotateStartYawPitchRoll[0] + aYawAngleDelta;
|
||||
const double aRoll = 0.0;
|
||||
double aPitchAngleNew = 0.0, aRoll = 0.0;
|
||||
const double aYawAngleNew = myRotateStartYawPitchRoll[0] + aYawAngleDelta;
|
||||
if (!theView->View()->IsActiveXR())
|
||||
{
|
||||
aPitchAngleNew = Max (Min (myRotateStartYawPitchRoll[1] + aPitchAngleDelta, M_PI * 0.5 - M_PI / 180.0), -M_PI * 0.5 + M_PI / 180.0);
|
||||
aRoll = 0.0;
|
||||
}
|
||||
|
||||
gp_Quaternion aRot;
|
||||
aRot.SetEulerAngles (gp_YawPitchRoll, aYawAngleNew, aPitchAngleNew, aRoll);
|
||||
@@ -1557,6 +1602,7 @@ void AIS_ViewController::handleOrbitRotation (const Handle(V3d_View)& theView,
|
||||
}
|
||||
|
||||
theView->Invalidate();
|
||||
theView->View()->SynchronizeXRBaseToPosedCamera();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -1926,6 +1972,251 @@ void AIS_ViewController::handleCameraActions (const Handle(AIS_InteractiveContex
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : handleXRInput
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void AIS_ViewController::handleXRInput (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView,
|
||||
const AIS_WalkDelta& )
|
||||
{
|
||||
theView->View()->ProcessXRInput();
|
||||
if (!theView->View()->IsActiveXR())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (myXRCameraTmp.IsNull())
|
||||
{
|
||||
myXRCameraTmp = new Graphic3d_Camera();
|
||||
}
|
||||
handleXRTurnPad (theCtx, theView);
|
||||
handleXRTeleport(theCtx, theView);
|
||||
handleXRPicking (theCtx, theView);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : handleXRTurnPad
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void AIS_ViewController::handleXRTurnPad (const Handle(AIS_InteractiveContext)& ,
|
||||
const Handle(V3d_View)& theView)
|
||||
{
|
||||
if (myXRTurnAngle <= 0.0
|
||||
|| !theView->View()->IsActiveXR())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// turn left/right at 45 degrees on left/right trackpad clicks
|
||||
for (int aHand = 0; aHand < 2; ++aHand)
|
||||
{
|
||||
const Aspect_XRTrackedDeviceRole aRole = aHand == 0 ? Aspect_XRTrackedDeviceRole_RightHand : Aspect_XRTrackedDeviceRole_LeftHand;
|
||||
const Handle(Aspect_XRAction)& aPadClickAct = theView->View()->XRSession()->GenericAction (aRole, Aspect_XRGenericAction_InputTrackPadClick);
|
||||
const Handle(Aspect_XRAction)& aPadPosAct = theView->View()->XRSession()->GenericAction (aRole, Aspect_XRGenericAction_InputTrackPadPosition);
|
||||
if (aPadClickAct.IsNull()
|
||||
|| aPadPosAct.IsNull())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const Aspect_XRDigitalActionData aPadClick = theView->View()->XRSession()->GetDigitalActionData (aPadClickAct);
|
||||
const Aspect_XRAnalogActionData aPadPos = theView->View()->XRSession()->GetAnalogActionData (aPadPosAct);
|
||||
if (aPadClick.IsActive
|
||||
&& aPadClick.IsPressed
|
||||
&& aPadClick.IsChanged
|
||||
&& aPadPos.IsActive
|
||||
&& Abs (aPadPos.VecXYZ.y()) < 0.5f
|
||||
&& Abs (aPadPos.VecXYZ.x()) > 0.7f)
|
||||
{
|
||||
gp_Trsf aTrsfTurn;
|
||||
aTrsfTurn.SetRotation (gp_Ax1 (gp::Origin(), theView->View()->BaseXRCamera()->Up()), aPadPos.VecXYZ.x() < 0.0f ? myXRTurnAngle : -myXRTurnAngle);
|
||||
theView->View()->TurnViewXRCamera (aTrsfTurn);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : handleXRTeleport
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void AIS_ViewController::handleXRTeleport (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView)
|
||||
{
|
||||
if (!theView->View()->IsActiveXR())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// teleport on forward trackpad unclicks
|
||||
const Aspect_XRTrackedDeviceRole aTeleOld = myXRLastTeleportHand;
|
||||
myXRLastTeleportHand = Aspect_XRTrackedDeviceRole_Other;
|
||||
for (int aHand = 0; aHand < 2; ++aHand)
|
||||
{
|
||||
const Aspect_XRTrackedDeviceRole aRole = aHand == 0 ? Aspect_XRTrackedDeviceRole_RightHand : Aspect_XRTrackedDeviceRole_LeftHand;
|
||||
const Standard_Integer aDeviceId = theView->View()->XRSession()->NamedTrackedDevice (aRole);
|
||||
if (aDeviceId == -1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const Handle(Aspect_XRAction)& aPadClickAct = theView->View()->XRSession()->GenericAction (aRole, Aspect_XRGenericAction_InputTrackPadClick);
|
||||
const Handle(Aspect_XRAction)& aPadPosAct = theView->View()->XRSession()->GenericAction (aRole, Aspect_XRGenericAction_InputTrackPadPosition);
|
||||
if (aPadClickAct.IsNull()
|
||||
|| aPadPosAct.IsNull())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const Aspect_XRDigitalActionData aPadClick = theView->View()->XRSession()->GetDigitalActionData (aPadClickAct);
|
||||
const Aspect_XRAnalogActionData aPadPos = theView->View()->XRSession()->GetAnalogActionData (aPadPosAct);
|
||||
const bool isPressed = aPadClick.IsPressed;
|
||||
const bool isClicked = !aPadClick.IsPressed
|
||||
&& aPadClick.IsChanged;
|
||||
if (aPadClick.IsActive
|
||||
&& (isPressed || isClicked)
|
||||
&& aPadPos.IsActive
|
||||
&& aPadPos.VecXYZ.y() > 0.6f
|
||||
&& Abs (aPadPos.VecXYZ.x()) < 0.5f)
|
||||
{
|
||||
const Aspect_TrackedDevicePose& aPose = theView->View()->XRSession()->TrackedPoses()[aDeviceId];
|
||||
if (!aPose.IsValidPose)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
myXRLastTeleportHand = aRole;
|
||||
Standard_Real& aPickDepth = aRole == Aspect_XRTrackedDeviceRole_LeftHand ? myXRLastPickDepthLeft : myXRLastPickDepthRight;
|
||||
aPickDepth = Precision::Infinite();
|
||||
Graphic3d_Vec3 aPickNorm;
|
||||
const gp_Trsf aHandBase = theView->View()->PoseXRToWorld (aPose.Orientation);
|
||||
const Standard_Real aHeadHeight = theView->View()->XRSession()->HeadPose().TranslationPart().Y();
|
||||
{
|
||||
const Standard_Integer aPickedId = handleXRMoveTo (theCtx, theView, aPose.Orientation, false);
|
||||
if (aPickedId >= 1)
|
||||
{
|
||||
const SelectMgr_SortCriterion& aPickedData = theCtx->MainSelector()->PickedData (aPickedId);
|
||||
aPickNorm = aPickedData.Normal;
|
||||
if (aPickNorm.SquareModulus() > ShortRealEpsilon())
|
||||
{
|
||||
aPickDepth = aPickedData.Point.Distance (aHandBase.TranslationPart());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isClicked)
|
||||
{
|
||||
myXRLastTeleportHand = Aspect_XRTrackedDeviceRole_Other;
|
||||
if (!Precision::IsInfinite (aPickDepth))
|
||||
{
|
||||
const gp_Dir aTeleDir = -gp::DZ().Transformed (aHandBase);
|
||||
const gp_Dir anUpDir = theView->View()->BaseXRCamera()->Up();
|
||||
|
||||
bool isHorizontal = false;
|
||||
gp_Dir aPickNormDir (aPickNorm.x(), aPickNorm.y(), aPickNorm.z());
|
||||
if (anUpDir.IsEqual ( aPickNormDir, M_PI_4)
|
||||
|| anUpDir.IsEqual (-aPickNormDir, M_PI_4))
|
||||
{
|
||||
isHorizontal = true;
|
||||
}
|
||||
|
||||
gp_Pnt aNewEye = aHandBase.TranslationPart();
|
||||
if (isHorizontal)
|
||||
{
|
||||
aNewEye = aHandBase.TranslationPart()
|
||||
+ aTeleDir.XYZ() * aPickDepth
|
||||
+ anUpDir.XYZ() * aHeadHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aPickNormDir.Dot (aTeleDir) < 0.0)
|
||||
{
|
||||
aPickNormDir.Reverse();
|
||||
}
|
||||
aNewEye = aHandBase.TranslationPart()
|
||||
+ aTeleDir.XYZ() * aPickDepth
|
||||
- aPickNormDir.XYZ() * aHeadHeight / 4;
|
||||
}
|
||||
|
||||
theView->View()->PosedXRCamera()->MoveEyeTo (aNewEye);
|
||||
theView->View()->ComputeXRBaseCameraFromPosed (theView->View()->PosedXRCamera(), theView->View()->XRSession()->HeadPose());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (myXRLastTeleportHand != aTeleOld)
|
||||
{
|
||||
if (aTeleOld != Aspect_XRTrackedDeviceRole_Other)
|
||||
{
|
||||
if (const Handle(Aspect_XRAction)& aHaptic = theView->View()->XRSession()->GenericAction (aTeleOld, Aspect_XRGenericAction_OutputHaptic))
|
||||
{
|
||||
theView->View()->XRSession()->AbortHapticVibrationAction (aHaptic);
|
||||
}
|
||||
}
|
||||
if (myXRLastTeleportHand != Aspect_XRTrackedDeviceRole_Other)
|
||||
{
|
||||
if (const Handle(Aspect_XRAction)& aHaptic = theView->View()->XRSession()->GenericAction (myXRLastTeleportHand, Aspect_XRGenericAction_OutputHaptic))
|
||||
{
|
||||
theView->View()->XRSession()->TriggerHapticVibrationAction (aHaptic, myXRTeleportHaptic);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : handleXRPicking
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void AIS_ViewController::handleXRPicking (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView)
|
||||
{
|
||||
if (!theView->View()->IsActiveXR())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// handle selection on trigger clicks
|
||||
Aspect_XRTrackedDeviceRole aPickDevOld = myXRLastPickingHand;
|
||||
myXRLastPickingHand = Aspect_XRTrackedDeviceRole_Other;
|
||||
for (int aHand = 0; aHand < 2; ++aHand)
|
||||
{
|
||||
const Aspect_XRTrackedDeviceRole aRole = aHand == 0 ? Aspect_XRTrackedDeviceRole_RightHand : Aspect_XRTrackedDeviceRole_LeftHand;
|
||||
const Handle(Aspect_XRAction)& aTrigClickAct = theView->View()->XRSession()->GenericAction (aRole, Aspect_XRGenericAction_InputTriggerClick);
|
||||
const Handle(Aspect_XRAction)& aTrigPullAct = theView->View()->XRSession()->GenericAction (aRole, Aspect_XRGenericAction_InputTriggerPull);
|
||||
if (aTrigClickAct.IsNull()
|
||||
|| aTrigPullAct.IsNull())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const Aspect_XRDigitalActionData aTrigClick = theView->View()->XRSession()->GetDigitalActionData (aTrigClickAct);
|
||||
const Aspect_XRAnalogActionData aTrigPos = theView->View()->XRSession()->GetAnalogActionData (aTrigPullAct);
|
||||
if (aTrigPos.IsActive
|
||||
&& Abs (aTrigPos.VecXYZ.x()) > 0.1f)
|
||||
{
|
||||
myXRLastPickingHand = aRole;
|
||||
handleXRHighlight (theCtx, theView);
|
||||
if (aTrigClick.IsActive
|
||||
&& aTrigClick.IsPressed
|
||||
&& aTrigClick.IsChanged)
|
||||
{
|
||||
theCtx->Select (false);
|
||||
OnSelectionChanged (theCtx, theView);
|
||||
if (const Handle(Aspect_XRAction)& aHaptic = theView->View()->XRSession()->GenericAction (myXRLastPickingHand, Aspect_XRGenericAction_OutputHaptic))
|
||||
{
|
||||
theView->View()->XRSession()->TriggerHapticVibrationAction (aHaptic, myXRSelectHaptic);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (myXRLastPickingHand != aPickDevOld)
|
||||
{
|
||||
theCtx->ClearDetected();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OnSelectionChanged
|
||||
// purpose :
|
||||
@@ -2034,6 +2325,7 @@ void AIS_ViewController::contextLazyMoveTo (const Handle(AIS_InteractiveContext)
|
||||
myPrevMoveTo = thePnt;
|
||||
|
||||
Handle(SelectMgr_EntityOwner) aLastPicked = theCtx->DetectedOwner();
|
||||
theView->AutoZFit();
|
||||
theCtx->MoveTo (thePnt.x(), thePnt.y(), theView, false);
|
||||
Handle(SelectMgr_EntityOwner) aNewPicked = theCtx->DetectedOwner();
|
||||
|
||||
@@ -2113,14 +2405,16 @@ void AIS_ViewController::handleSelectionPoly (const Handle(AIS_InteractiveContex
|
||||
{
|
||||
// rubber-band & window polygon selection
|
||||
if (myGL.Selection.Tool == AIS_ViewSelectionTool_RubberBand
|
||||
|| myGL.Selection.Tool == AIS_ViewSelectionTool_Polygon)
|
||||
|| myGL.Selection.Tool == AIS_ViewSelectionTool_Polygon
|
||||
|| myGL.Selection.Tool == AIS_ViewSelectionTool_ZoomWindow)
|
||||
{
|
||||
if (!myGL.Selection.Points.IsEmpty())
|
||||
{
|
||||
myRubberBand->ClearPoints();
|
||||
myRubberBand->SetToUpdate();
|
||||
|
||||
const bool anIsRubber = myGL.Selection.Tool == AIS_ViewSelectionTool_RubberBand;
|
||||
const bool anIsRubber = myGL.Selection.Tool == AIS_ViewSelectionTool_RubberBand
|
||||
|| myGL.Selection.Tool == AIS_ViewSelectionTool_ZoomWindow;
|
||||
if (anIsRubber)
|
||||
{
|
||||
myRubberBand->SetRectangle (myGL.Selection.Points.First().x(), -myGL.Selection.Points.First().y(),
|
||||
@@ -2147,8 +2441,8 @@ void AIS_ViewController::handleSelectionPoly (const Handle(AIS_InteractiveContex
|
||||
}
|
||||
catch (const Standard_Failure& theEx)
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Internal error while displaying rubber-band: ")
|
||||
+ theEx.DynamicType()->Name() + ", " + theEx.GetMessageString(), Message_Warning);
|
||||
Message::SendWarning (TCollection_AsciiString ("Internal error while displaying rubber-band: ")
|
||||
+ theEx.DynamicType()->Name() + ", " + theEx.GetMessageString());
|
||||
myRubberBand->ClearPoints();
|
||||
}
|
||||
if (!theView->Viewer()->ZLayerSettings (myRubberBand->ZLayer()).IsImmediate())
|
||||
@@ -2184,20 +2478,28 @@ void AIS_ViewController::handleSelectionPoly (const Handle(AIS_InteractiveContex
|
||||
{
|
||||
const Graphic3d_Vec2i aPnt1 (aPoints.Value (1).x(), -aPoints.Value (1).y());
|
||||
const Graphic3d_Vec2i aPnt2 (aPoints.Value (3).x(), -aPoints.Value (3).y());
|
||||
theCtx->MainSelector()->AllowOverlapDetection (aPnt1.y() != Min (aPnt1.y(), aPnt2.y()));
|
||||
if (myGL.Selection.IsXOR)
|
||||
if (myGL.Selection.Tool == AIS_ViewSelectionTool_ZoomWindow)
|
||||
{
|
||||
theCtx->ShiftSelect (Min (aPnt1.x(), aPnt2.x()), Min (aPnt1.y(), aPnt2.y()),
|
||||
Max (aPnt1.x(), aPnt2.x()), Max (aPnt1.y(), aPnt2.y()),
|
||||
theView, false);
|
||||
theView->WindowFitAll (aPnt1.x(), aPnt1.y(), aPnt2.x(), aPnt2.y());
|
||||
theView->Invalidate();
|
||||
}
|
||||
else
|
||||
{
|
||||
theCtx->Select (Min (aPnt1.x(), aPnt2.x()), Min (aPnt1.y(), aPnt2.y()),
|
||||
Max (aPnt1.x(), aPnt2.x()), Max (aPnt1.y(), aPnt2.y()),
|
||||
theView, false);
|
||||
theCtx->MainSelector()->AllowOverlapDetection (aPnt1.y() != Min (aPnt1.y(), aPnt2.y()));
|
||||
if (myGL.Selection.IsXOR)
|
||||
{
|
||||
theCtx->ShiftSelect (Min (aPnt1.x(), aPnt2.x()), Min (aPnt1.y(), aPnt2.y()),
|
||||
Max (aPnt1.x(), aPnt2.x()), Max (aPnt1.y(), aPnt2.y()),
|
||||
theView, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
theCtx->Select (Min (aPnt1.x(), aPnt2.x()), Min (aPnt1.y(), aPnt2.y()),
|
||||
Max (aPnt1.x(), aPnt2.x()), Max (aPnt1.y(), aPnt2.y()),
|
||||
theView, false);
|
||||
}
|
||||
theCtx->MainSelector()->AllowOverlapDetection (false);
|
||||
}
|
||||
theCtx->MainSelector()->AllowOverlapDetection (false);
|
||||
}
|
||||
else if (aPoints.Length() >= 3)
|
||||
{
|
||||
@@ -2210,7 +2512,6 @@ void AIS_ViewController::handleSelectionPoly (const Handle(AIS_InteractiveContex
|
||||
aPolyIter.ChangeValue() = gp_Pnt2d (aNewPnt.x(), -aNewPnt.y());
|
||||
}
|
||||
|
||||
theCtx->MainSelector()->AllowOverlapDetection (false);
|
||||
if (myGL.Selection.IsXOR)
|
||||
{
|
||||
theCtx->ShiftSelect (aPolyline, theView, false);
|
||||
@@ -2219,14 +2520,17 @@ void AIS_ViewController::handleSelectionPoly (const Handle(AIS_InteractiveContex
|
||||
{
|
||||
theCtx->Select (aPolyline, theView, false);
|
||||
}
|
||||
theCtx->MainSelector()->AllowOverlapDetection (false);
|
||||
}
|
||||
}
|
||||
|
||||
// selection affects all Views
|
||||
theView->Viewer()->Invalidate();
|
||||
|
||||
myRubberBand->ClearPoints();
|
||||
OnSelectionChanged (theCtx, theView);
|
||||
if (myGL.Selection.Tool != AIS_ViewSelectionTool_ZoomWindow)
|
||||
{
|
||||
// selection affects all Views
|
||||
theView->Viewer()->Invalidate();
|
||||
OnSelectionChanged (theCtx, theView);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2253,9 +2557,10 @@ void AIS_ViewController::handleDynamicHighlight (const Handle(AIS_InteractiveCon
|
||||
else if (myToAllowHighlight)
|
||||
{
|
||||
if (myPrevMoveTo != aMoveToPnt
|
||||
|| myGL.OrbitRotation.ToRotate
|
||||
|| myGL.ViewRotation.ToRotate
|
||||
|| theView->IsInvalidated())
|
||||
|| (!theView->View()->IsActiveXR()
|
||||
&& (myGL.OrbitRotation.ToRotate
|
||||
|| myGL.ViewRotation.ToRotate
|
||||
|| theView->IsInvalidated())))
|
||||
{
|
||||
ResetPreviousMoveTo();
|
||||
contextLazyMoveTo (theCtx, theView, aMoveToPnt);
|
||||
@@ -2321,6 +2626,12 @@ void AIS_ViewController::handleViewRedraw (const Handle(AIS_InteractiveContext)&
|
||||
setAskNextFrame();
|
||||
}
|
||||
|
||||
if (theView->View()->IsActiveXR())
|
||||
{
|
||||
// VR requires continuous rendering
|
||||
myToAskNextFrame = true;
|
||||
}
|
||||
|
||||
for (V3d_ListOfViewIterator aViewIter (theView->Viewer()->ActiveViewIterator()); aViewIter.More(); aViewIter.Next())
|
||||
{
|
||||
const Handle(V3d_View)& aView = aViewIter.Value();
|
||||
@@ -2349,6 +2660,266 @@ void AIS_ViewController::handleViewRedraw (const Handle(AIS_InteractiveContext)&
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : handleXRMoveTo
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Integer AIS_ViewController::handleXRMoveTo (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView,
|
||||
const gp_Trsf& thePose,
|
||||
const Standard_Boolean theToHighlight)
|
||||
{
|
||||
//ResetPreviousMoveTo();
|
||||
Standard_Integer aPickResult = 0;
|
||||
|
||||
Handle(Graphic3d_Camera) aCamBack = theView->Camera();
|
||||
myXRCameraTmp->Copy (aCamBack);
|
||||
theView->View()->ComputeXRPosedCameraFromBase (*myXRCameraTmp, thePose);
|
||||
theView->SetCamera (myXRCameraTmp);
|
||||
Graphic3d_Vec2i aPickPixel;
|
||||
theView->Window()->Size (aPickPixel.x(), aPickPixel.y());
|
||||
aPickPixel /= 2;
|
||||
const Standard_Integer aSelTolerBack = theCtx->MainSelector()->CustomPixelTolerance();
|
||||
theCtx->MainSelector()->SetPixelTolerance (1);
|
||||
theView->AutoZFit();
|
||||
if (theToHighlight)
|
||||
{
|
||||
theCtx->MoveTo (aPickPixel.x(), aPickPixel.y(), theView, false);
|
||||
if (!theCtx->DetectedOwner().IsNull())
|
||||
{
|
||||
// ignore 2D objects
|
||||
for (aPickResult = 1; !theCtx->DetectedOwner()->Selectable()->TransformPersistence().IsNull(); ++aPickResult)
|
||||
{
|
||||
if (theCtx->HilightNextDetected (theView, false) <= 1)
|
||||
{
|
||||
theCtx->ClearDetected();
|
||||
aPickResult = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
theCtx->MainSelector()->Pick (aPickPixel.x(), aPickPixel.y(), theView);
|
||||
for (Standard_Integer aPickIter = 1; aPickIter <= theCtx->MainSelector()->NbPicked(); ++aPickIter)
|
||||
{
|
||||
const SelectMgr_SortCriterion& aPickedData = theCtx->MainSelector()->PickedData (aPickIter);
|
||||
if (!aPickedData.Entity->OwnerId()->Selectable()->TransformPersistence().IsNull())
|
||||
{
|
||||
// skip 2d objects
|
||||
continue;
|
||||
}
|
||||
|
||||
aPickResult = aPickIter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
theCtx->MainSelector()->SetPixelTolerance (aSelTolerBack);
|
||||
theView->SetCamera (aCamBack);
|
||||
return aPickResult;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : handleXRHighlight
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void AIS_ViewController::handleXRHighlight (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView)
|
||||
{
|
||||
if (myXRLastPickingHand != Aspect_XRTrackedDeviceRole_LeftHand
|
||||
&& myXRLastPickingHand != Aspect_XRTrackedDeviceRole_RightHand)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const Standard_Integer aDeviceId = theView->View()->XRSession()->NamedTrackedDevice (myXRLastPickingHand);
|
||||
if (aDeviceId == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const Aspect_TrackedDevicePose& aPose = theView->View()->XRSession()->TrackedPoses()[aDeviceId];
|
||||
if (!aPose.IsValidPose)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(SelectMgr_EntityOwner) aDetOld = theCtx->DetectedOwner();
|
||||
handleXRMoveTo (theCtx, theView, aPose.Orientation, true);
|
||||
if (!theCtx->DetectedOwner().IsNull()
|
||||
&& theCtx->DetectedOwner() != aDetOld)
|
||||
{
|
||||
if (const Handle(Aspect_XRAction)& aHaptic = theView->View()->XRSession()->GenericAction (myXRLastPickingHand, Aspect_XRGenericAction_OutputHaptic))
|
||||
{
|
||||
theView->View()->XRSession()->TriggerHapticVibrationAction (aHaptic, myXRPickingHaptic);
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Real& aPickDepth = myXRLastPickingHand == Aspect_XRTrackedDeviceRole_LeftHand ? myXRLastPickDepthLeft : myXRLastPickDepthRight;
|
||||
aPickDepth = Precision::Infinite();
|
||||
if (theCtx->MainSelector()->NbPicked() > 0)
|
||||
{
|
||||
const gp_Trsf aHandBase = theView->View()->PoseXRToWorld (aPose.Orientation);
|
||||
const SelectMgr_SortCriterion& aPicked = theCtx->MainSelector()->PickedData (1);
|
||||
aPickDepth = aPicked.Point.Distance (aHandBase.TranslationPart());
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : handleXRPresentations
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void AIS_ViewController::handleXRPresentations (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView)
|
||||
{
|
||||
if (!theView->View()->IsActiveXR()
|
||||
|| (!myToDisplayXRAuxDevices
|
||||
&& !myToDisplayXRHands))
|
||||
{
|
||||
for (NCollection_Array1<Handle(AIS_XRTrackedDevice)>::Iterator aPrsIter (myXRPrsDevices); aPrsIter.More(); aPrsIter.Next())
|
||||
{
|
||||
if (!aPrsIter.Value().IsNull()
|
||||
&& aPrsIter.Value()->HasInteractiveContext())
|
||||
{
|
||||
theCtx->Remove (aPrsIter.Value(), false);
|
||||
}
|
||||
aPrsIter.ChangeValue().Nullify();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (myXRPrsDevices.Length() != theView->View()->XRSession()->TrackedPoses().Length())
|
||||
{
|
||||
for (NCollection_Array1<Handle(AIS_XRTrackedDevice)>::Iterator aPrsIter (myXRPrsDevices); aPrsIter.More(); aPrsIter.Next())
|
||||
{
|
||||
if (!aPrsIter.Value().IsNull())
|
||||
{
|
||||
theCtx->Remove (aPrsIter.Value(), false);
|
||||
}
|
||||
}
|
||||
myXRPrsDevices.Resize (theView->View()->XRSession()->TrackedPoses().Lower(), theView->View()->XRSession()->TrackedPoses().Upper(), false);
|
||||
}
|
||||
|
||||
const Standard_Integer aHeadDevice = theView->View()->XRSession()->NamedTrackedDevice (Aspect_XRTrackedDeviceRole_Head);
|
||||
const Standard_Integer aLeftDevice = theView->View()->XRSession()->NamedTrackedDevice (Aspect_XRTrackedDeviceRole_LeftHand);
|
||||
const Standard_Integer aRightDevice = theView->View()->XRSession()->NamedTrackedDevice (Aspect_XRTrackedDeviceRole_RightHand);
|
||||
for (Standard_Integer aDeviceIter = theView->View()->XRSession()->TrackedPoses().Lower(); aDeviceIter <= theView->View()->XRSession()->TrackedPoses().Upper(); ++aDeviceIter)
|
||||
{
|
||||
const Aspect_TrackedDevicePose& aPose = theView->View()->XRSession()->TrackedPoses()[aDeviceIter];
|
||||
Handle(AIS_XRTrackedDevice)& aPosePrs = myXRPrsDevices[aDeviceIter];
|
||||
if (!aPose.IsValidPose)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const bool isHand = aDeviceIter == aLeftDevice
|
||||
|| aDeviceIter == aRightDevice;
|
||||
if ((!myToDisplayXRHands && isHand)
|
||||
|| (!myToDisplayXRAuxDevices && !isHand))
|
||||
{
|
||||
if (!aPosePrs.IsNull()
|
||||
&& aPosePrs->HasInteractiveContext())
|
||||
{
|
||||
theCtx->Remove (aPosePrs, false);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
Aspect_XRTrackedDeviceRole aRole = Aspect_XRTrackedDeviceRole_Other;
|
||||
if (aDeviceIter == aLeftDevice)
|
||||
{
|
||||
aRole = Aspect_XRTrackedDeviceRole_LeftHand;
|
||||
}
|
||||
else if (aDeviceIter == aRightDevice)
|
||||
{
|
||||
aRole = Aspect_XRTrackedDeviceRole_RightHand;
|
||||
}
|
||||
|
||||
if (!aPosePrs.IsNull()
|
||||
&& aPosePrs->UnitFactor() != (float )theView->View()->UnitFactor())
|
||||
{
|
||||
theCtx->Remove (aPosePrs, false);
|
||||
aPosePrs.Nullify();
|
||||
}
|
||||
|
||||
if (aPosePrs.IsNull())
|
||||
{
|
||||
Handle(Image_Texture) aTexture;
|
||||
Handle(Graphic3d_ArrayOfTriangles) aTris;
|
||||
if (aDeviceIter != aHeadDevice)
|
||||
{
|
||||
aTris = theView->View()->XRSession()->LoadRenderModel (aDeviceIter, aTexture);
|
||||
}
|
||||
if (!aTris.IsNull())
|
||||
{
|
||||
aPosePrs = new AIS_XRTrackedDevice (aTris, aTexture);
|
||||
}
|
||||
else
|
||||
{
|
||||
aPosePrs = new AIS_XRTrackedDevice();
|
||||
}
|
||||
aPosePrs->SetUnitFactor ((float )theView->View()->UnitFactor());
|
||||
aPosePrs->SetMutable (true);
|
||||
aPosePrs->SetInfiniteState (true);
|
||||
}
|
||||
aPosePrs->SetRole (aRole);
|
||||
|
||||
if (!aPosePrs->HasInteractiveContext())
|
||||
{
|
||||
theCtx->Display (aPosePrs, 0, -1, false);
|
||||
}
|
||||
|
||||
gp_Trsf aPoseLocal = aPose.Orientation;
|
||||
if (aDeviceIter == aHeadDevice)
|
||||
{
|
||||
// show headset position on floor level
|
||||
aPoseLocal.SetTranslationPart (gp_Vec (aPoseLocal.TranslationPart().X(), 0.0, aPoseLocal.TranslationPart().Z()));
|
||||
}
|
||||
const gp_Trsf aPoseWorld = theView->View()->PoseXRToWorld (aPoseLocal);
|
||||
theCtx->SetLocation (aPosePrs, aPoseWorld);
|
||||
|
||||
Standard_Real aLaserLen = 0.0;
|
||||
if (isHand
|
||||
&& aPosePrs->Role() == myXRLastPickingHand)
|
||||
{
|
||||
aLaserLen = myXRLastPickingHand == Aspect_XRTrackedDeviceRole_LeftHand ? myXRLastPickDepthLeft : myXRLastPickDepthRight;
|
||||
if (Precision::IsInfinite (aLaserLen))
|
||||
{
|
||||
const Bnd_Box aViewBox = theView->View()->MinMaxValues (true);
|
||||
if (!aViewBox.IsVoid())
|
||||
{
|
||||
aLaserLen = Sqrt (aViewBox.SquareExtent());
|
||||
}
|
||||
else
|
||||
{
|
||||
aLaserLen = 100.0;
|
||||
}
|
||||
}
|
||||
aPosePrs->SetLaserColor (myXRLaserPickColor);
|
||||
}
|
||||
else if (isHand
|
||||
&& aPosePrs->Role() == myXRLastTeleportHand)
|
||||
{
|
||||
aLaserLen = myXRLastTeleportHand == Aspect_XRTrackedDeviceRole_LeftHand ? myXRLastPickDepthLeft : myXRLastPickDepthRight;
|
||||
if (Precision::IsInfinite (aLaserLen))
|
||||
{
|
||||
const Bnd_Box aViewBox = theView->View()->MinMaxValues (true);
|
||||
if (!aViewBox.IsVoid())
|
||||
{
|
||||
aLaserLen = Sqrt (aViewBox.SquareExtent());
|
||||
}
|
||||
else
|
||||
{
|
||||
aLaserLen = 100.0;
|
||||
}
|
||||
}
|
||||
aPosePrs->SetLaserColor (myXRLaserTeleColor);
|
||||
}
|
||||
aPosePrs->SetLaserLength ((float )aLaserLen);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : HandleViewEvents
|
||||
// purpose :
|
||||
@@ -2356,11 +2927,23 @@ void AIS_ViewController::handleViewRedraw (const Handle(AIS_InteractiveContext)&
|
||||
void AIS_ViewController::HandleViewEvents (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView)
|
||||
{
|
||||
handleMoveTo (theCtx, theView);
|
||||
const bool wasImmediateUpdate = theView->SetImmediateUpdate (false);
|
||||
|
||||
const AIS_WalkDelta aWalk = FetchNavigationKeys (1.0, 1.0);
|
||||
handleXRInput (theCtx, theView, aWalk);
|
||||
if (theView->View()->IsActiveXR())
|
||||
{
|
||||
theView->View()->SetupXRPosedCamera();
|
||||
}
|
||||
handleCameraActions (theCtx, theView, aWalk);
|
||||
theView->View()->SynchronizeXRPosedToBaseCamera(); // handleCameraActions() may modify posed camera position - copy this modifications also to the base camera
|
||||
handleXRPresentations (theCtx, theView);
|
||||
|
||||
handleMoveTo (theCtx, theView);
|
||||
handleViewRedraw (theCtx, theView);
|
||||
theView->View()->UnsetXRPosedCamera();
|
||||
|
||||
theView->SetImmediateUpdate (wasImmediateUpdate);
|
||||
|
||||
// make sure to not process the same events twice
|
||||
myGL.Reset();
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
#include <Aspect_VKeySet.hxx>
|
||||
#include <Aspect_TouchMap.hxx>
|
||||
#include <Aspect_XRHapticActionData.hxx>
|
||||
#include <Aspect_XRTrackedDeviceRole.hxx>
|
||||
#include <AIS_DragAction.hxx>
|
||||
#include <AIS_MouseGesture.hxx>
|
||||
#include <AIS_NavigationMode.hxx>
|
||||
@@ -28,6 +30,7 @@
|
||||
#include <NCollection_Array1.hxx>
|
||||
#include <OSD_Timer.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Quantity_ColorRGBA.hxx>
|
||||
#include <Standard_Mutex.hxx>
|
||||
|
||||
class AIS_AnimationCamera;
|
||||
@@ -35,6 +38,8 @@ class AIS_InteractiveObject;
|
||||
class AIS_InteractiveContext;
|
||||
class AIS_Point;
|
||||
class AIS_RubberBand;
|
||||
class AIS_XRTrackedDevice;
|
||||
class Graphic3d_Camera;
|
||||
class V3d_View;
|
||||
|
||||
//! Auxiliary structure for handling viewer events between GUI and Rendering threads.
|
||||
@@ -200,6 +205,18 @@ public: //! @name global parameters
|
||||
//! Reset previous position of MoveTo.
|
||||
void ResetPreviousMoveTo() { myPrevMoveTo = Graphic3d_Vec2i (-1); }
|
||||
|
||||
//! Return TRUE to display auxiliary tracked XR devices (like tracking stations).
|
||||
bool ToDisplayXRAuxDevices() const { return myToDisplayXRAuxDevices; }
|
||||
|
||||
//! Set if auxiliary tracked XR devices should be displayed.
|
||||
void SetDisplayXRAuxDevices (bool theToDisplay) { myToDisplayXRAuxDevices = theToDisplay; }
|
||||
|
||||
//! Return TRUE to display XR hand controllers.
|
||||
bool ToDisplayXRHands() const { return myToDisplayXRHands; }
|
||||
|
||||
//! Set if tracked XR hand controllers should be displayed.
|
||||
void SetDisplayXRHands (bool theToDisplay) { myToDisplayXRHands = theToDisplay; }
|
||||
|
||||
public: //! @name keyboard input
|
||||
|
||||
//! Return keyboard state.
|
||||
@@ -548,6 +565,40 @@ public:
|
||||
Standard_EXPORT virtual void handleViewRedraw (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView);
|
||||
|
||||
public:
|
||||
|
||||
//! Perform XR input.
|
||||
//! This method is expected to be called from rendering thread.
|
||||
Standard_EXPORT virtual void handleXRInput (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView,
|
||||
const AIS_WalkDelta& theWalk);
|
||||
|
||||
//! Handle trackpad view turn action.
|
||||
Standard_EXPORT virtual void handleXRTurnPad (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView);
|
||||
|
||||
//! Handle trackpad teleportation action.
|
||||
Standard_EXPORT virtual void handleXRTeleport (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView);
|
||||
|
||||
//! Handle picking on trigger click.
|
||||
Standard_EXPORT virtual void handleXRPicking (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView);
|
||||
|
||||
//! Perform dynamic highlighting for active hand.
|
||||
Standard_EXPORT virtual void handleXRHighlight (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView);
|
||||
|
||||
//! Display auxiliary XR presentations.
|
||||
Standard_EXPORT virtual void handleXRPresentations (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView);
|
||||
|
||||
//! Perform picking with/without dynamic highlighting for XR pose.
|
||||
Standard_EXPORT virtual Standard_Integer handleXRMoveTo (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView,
|
||||
const gp_Trsf& thePose,
|
||||
const Standard_Boolean theToHighlight);
|
||||
|
||||
protected:
|
||||
|
||||
//! Flush buffers.
|
||||
@@ -629,6 +680,23 @@ protected:
|
||||
Graphic3d_Vec2i myPrevMoveTo; //!< previous position of MoveTo event in 3D viewer
|
||||
Standard_Boolean myHasHlrOnBeforeRotation; //!< flag for restoring Computed mode after rotation
|
||||
|
||||
protected: //! @name XR input variables
|
||||
|
||||
NCollection_Array1<Handle(AIS_XRTrackedDevice)> myXRPrsDevices; //!< array of XR tracked devices presentations
|
||||
Handle(Graphic3d_Camera) myXRCameraTmp; //!< temporary camera
|
||||
Quantity_Color myXRLaserTeleColor; //!< color of teleport laser
|
||||
Quantity_Color myXRLaserPickColor; //!< color of picking laser
|
||||
Aspect_XRTrackedDeviceRole myXRLastTeleportHand;//!< active hand for teleport
|
||||
Aspect_XRTrackedDeviceRole myXRLastPickingHand; //!< active hand for picking objects
|
||||
Aspect_XRHapticActionData myXRTeleportHaptic; //!< vibration on picking teleport destination
|
||||
Aspect_XRHapticActionData myXRPickingHaptic; //!< vibration on dynamic highlighting
|
||||
Aspect_XRHapticActionData myXRSelectHaptic; //!< vibration on selection
|
||||
Standard_Real myXRLastPickDepthLeft; //!< last picking depth for left hand
|
||||
Standard_Real myXRLastPickDepthRight; //!< last picking depth for right hand
|
||||
Standard_Real myXRTurnAngle; //!< discrete turn angle for XR trackpad
|
||||
Standard_Boolean myToDisplayXRAuxDevices; //!< flag to display auxiliary tracked XR devices
|
||||
Standard_Boolean myToDisplayXRHands; //!< flag to display XR hands
|
||||
|
||||
protected: //! @name keyboard input variables
|
||||
|
||||
Aspect_VKeySet myKeys; //!< keyboard state
|
||||
|
@@ -25,7 +25,8 @@ enum AIS_ViewSelectionTool
|
||||
{
|
||||
AIS_ViewSelectionTool_Picking, //!< pick to select
|
||||
AIS_ViewSelectionTool_RubberBand, //!< rubber-band to select
|
||||
AIS_ViewSelectionTool_Polygon //!< polyline to select
|
||||
AIS_ViewSelectionTool_Polygon, //!< polyline to select
|
||||
AIS_ViewSelectionTool_ZoomWindow, //!< zoom-in window (no selection)
|
||||
};
|
||||
|
||||
//! Input buffer type.
|
||||
|
202
src/AIS/AIS_XRTrackedDevice.cxx
Normal file
202
src/AIS/AIS_XRTrackedDevice.cxx
Normal file
@@ -0,0 +1,202 @@
|
||||
// Copyright (c) 2020 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 <AIS_XRTrackedDevice.hxx>
|
||||
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Texture2Dmanual.hxx>
|
||||
#include <Image_Texture.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
#include <Select3D_SensitivePrimitiveArray.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
|
||||
//! Texture holder.
|
||||
class AIS_XRTrackedDevice::XRTexture : public Graphic3d_Texture2Dmanual
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
XRTexture (const Handle(Image_Texture)& theImageSource,
|
||||
const Graphic3d_TextureUnit theUnit = Graphic3d_TextureUnit_BaseColor)
|
||||
: Graphic3d_Texture2Dmanual (""), myImageSource (theImageSource)
|
||||
{
|
||||
if (!theImageSource->TextureId().IsEmpty())
|
||||
{
|
||||
myTexId = theImageSource->TextureId();
|
||||
}
|
||||
myParams->SetTextureUnit (theUnit);
|
||||
myIsColorMap = theUnit == Graphic3d_TextureUnit_BaseColor
|
||||
|| theUnit == Graphic3d_TextureUnit_Emissive;
|
||||
}
|
||||
|
||||
//! Image reader.
|
||||
virtual Handle(Image_PixMap) GetImage() const Standard_OVERRIDE { return myImageSource->ReadImage(); }
|
||||
|
||||
protected:
|
||||
Handle(Image_Texture) myImageSource;
|
||||
};
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_XRTrackedDevice, AIS_InteractiveObject)
|
||||
|
||||
//=======================================================================
|
||||
//function : AIS_XRTrackedDevice
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_XRTrackedDevice::AIS_XRTrackedDevice (const Handle(Graphic3d_ArrayOfTriangles)& theTris,
|
||||
const Handle(Image_Texture)& theTexture)
|
||||
: myTris (theTris),
|
||||
myLaserColor (Quantity_NOC_BLUE),
|
||||
myLaserLength (0.0f),
|
||||
myUnitFactor (1.0f),
|
||||
myRole (Aspect_XRTrackedDeviceRole_Other),
|
||||
myToShowAxes (false)
|
||||
{
|
||||
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
|
||||
myDrawer->ShadingAspect()->SetMaterial (Graphic3d_NOM_DEFAULT);
|
||||
myDrawer->ShadingAspect()->SetColor (Quantity_NOC_WHITE);
|
||||
if (!theTexture.IsNull())
|
||||
{
|
||||
myDrawer->ShadingAspect()->Aspect()->SetTextureMap (new XRTexture (theTexture));
|
||||
myDrawer->ShadingAspect()->Aspect()->SetTextureMapOn (true);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AIS_XRTrackedDevice
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_XRTrackedDevice::AIS_XRTrackedDevice()
|
||||
: myLaserColor (Quantity_NOC_BLUE),
|
||||
myLaserLength (0.0f),
|
||||
myUnitFactor (1.0f),
|
||||
myRole (Aspect_XRTrackedDeviceRole_Other),
|
||||
myToShowAxes (true)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetLaserColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_XRTrackedDevice::SetLaserColor (const Quantity_Color& theColor)
|
||||
{
|
||||
if (!myLaserColor.IsEqual (theColor))
|
||||
{
|
||||
myLaserColor = theColor;
|
||||
computeLaserRay();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetLaserLength
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_XRTrackedDevice::SetLaserLength (Standard_ShortReal theLength)
|
||||
{
|
||||
if (myLaserLength != theLength)
|
||||
{
|
||||
myLaserLength = theLength;
|
||||
computeLaserRay();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : computeLaserRay
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_XRTrackedDevice::computeLaserRay()
|
||||
{
|
||||
if (myRayGroup.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!myRayGroup->IsEmpty())
|
||||
{
|
||||
myRayGroup->Clear();
|
||||
}
|
||||
if (myLaserLength <= 0.0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Graphic3d_ArrayOfPrimitives) aLines = new Graphic3d_ArrayOfSegments (2, 0, Graphic3d_ArrayFlags_VertexColor);
|
||||
aLines->AddVertex (gp_Pnt (0.0, 0.0, 0.0), myLaserColor);
|
||||
aLines->AddVertex (gp_Pnt (0.0, 0.0, -myLaserLength), myLaserColor);
|
||||
myRayGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
|
||||
myRayGroup->AddPrimitiveArray (aLines, false); // do not extend camera frustum by ray
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_XRTrackedDevice::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
if (theMode != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
thePrs->SetInfiniteState (myInfiniteState);
|
||||
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
|
||||
if (!myTris.IsNull())
|
||||
{
|
||||
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray (myTris);
|
||||
}
|
||||
|
||||
if (myToShowAxes || myTris.IsNull())
|
||||
{
|
||||
const float aSize = 0.1f * myUnitFactor;
|
||||
aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
|
||||
Handle(Graphic3d_ArrayOfPrimitives) aLines = new Graphic3d_ArrayOfSegments (6, 0, Graphic3d_ArrayFlags_VertexColor);
|
||||
aLines->AddVertex (gp_Pnt (0.0, 0.0, 0.0), Quantity_Color (Quantity_NOC_RED));
|
||||
aLines->AddVertex (gp_Pnt (aSize, 0.0, 0.0), Quantity_Color (Quantity_NOC_RED));
|
||||
aLines->AddVertex (gp_Pnt (0.0, 0.0, 0.0), Quantity_Color (Quantity_NOC_GREEN));
|
||||
aLines->AddVertex (gp_Pnt (0.0, aSize, 0.0), Quantity_Color (Quantity_NOC_GREEN));
|
||||
aLines->AddVertex (gp_Pnt (0.0, 0.0, 0.0), Quantity_Color (Quantity_NOC_BLUE));
|
||||
aLines->AddVertex (gp_Pnt (0.0, 0.0, aSize), Quantity_Color (Quantity_NOC_BLUE));
|
||||
aGroup->AddPrimitiveArray (aLines);
|
||||
}
|
||||
|
||||
myRayGroup = thePrs->NewGroup();
|
||||
computeLaserRay();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeSelection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_XRTrackedDevice::ComputeSelection (const Handle(SelectMgr_Selection)& theSel,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
if (theMode != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!myTris.IsNull())
|
||||
{
|
||||
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner (this);
|
||||
Handle(Select3D_SensitivePrimitiveArray) aSensitive = new Select3D_SensitivePrimitiveArray (anOwner);
|
||||
aSensitive->InitTriangulation (myTris->Attributes(), myTris->Indices(), TopLoc_Location(), true);
|
||||
theSel->Add (aSensitive);
|
||||
}
|
||||
}
|
92
src/AIS/AIS_XRTrackedDevice.hxx
Normal file
92
src/AIS/AIS_XRTrackedDevice.hxx
Normal file
@@ -0,0 +1,92 @@
|
||||
// Copyright (c) 2020 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 _AIS_XRTrackedDevice_HeaderFile
|
||||
#define _AIS_XRTrackedDevice_HeaderFile
|
||||
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <Aspect_XRTrackedDeviceRole.hxx>
|
||||
|
||||
class Graphic3d_ArrayOfTriangles;
|
||||
class Image_Texture;
|
||||
|
||||
//! Auxiliary textured mesh presentation of tracked XR device.
|
||||
class AIS_XRTrackedDevice : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_XRTrackedDevice, AIS_InteractiveObject)
|
||||
public:
|
||||
//! Main constructor.
|
||||
Standard_EXPORT AIS_XRTrackedDevice (const Handle(Graphic3d_ArrayOfTriangles)& theTris,
|
||||
const Handle(Image_Texture)& theTexture);
|
||||
|
||||
//! Empty constructor.
|
||||
Standard_EXPORT AIS_XRTrackedDevice();
|
||||
|
||||
//! Return device role.
|
||||
Aspect_XRTrackedDeviceRole Role() const { return myRole; }
|
||||
|
||||
//! Set device role.
|
||||
void SetRole (Aspect_XRTrackedDeviceRole theRole) { myRole = theRole; }
|
||||
|
||||
//! Return laser color.
|
||||
const Quantity_Color& LaserColor() const { return myLaserColor; }
|
||||
|
||||
//! Set laser color.
|
||||
Standard_EXPORT void SetLaserColor (const Quantity_Color& theColor);
|
||||
|
||||
//! Return laser length.
|
||||
Standard_ShortReal LaserLength() const { return myLaserLength; }
|
||||
|
||||
//! Set laser length.
|
||||
Standard_EXPORT void SetLaserLength (Standard_ShortReal theLength);
|
||||
|
||||
//! Return unit scale factor.
|
||||
Standard_ShortReal UnitFactor() const { return myUnitFactor; }
|
||||
|
||||
//! Set unit scale factor.
|
||||
void SetUnitFactor (Standard_ShortReal theFactor) { myUnitFactor = theFactor; }
|
||||
|
||||
protected:
|
||||
|
||||
//! Returns true for 0 mode.
|
||||
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
|
||||
|
||||
//! Compute presentation.
|
||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Compute selection.
|
||||
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Compute laser ray presentation.
|
||||
Standard_EXPORT void computeLaserRay();
|
||||
|
||||
private:
|
||||
//! Texture holder.
|
||||
class XRTexture;
|
||||
|
||||
private:
|
||||
|
||||
Handle(Graphic3d_Group) myRayGroup;
|
||||
|
||||
Handle(Graphic3d_ArrayOfTriangles) myTris;
|
||||
Quantity_Color myLaserColor;
|
||||
Standard_ShortReal myLaserLength;
|
||||
Standard_ShortReal myUnitFactor;
|
||||
Aspect_XRTrackedDeviceRole myRole;
|
||||
Standard_Boolean myToShowAxes;
|
||||
};
|
||||
|
||||
#endif // _AIS_XRTrackedDevice_HeaderFile
|
@@ -118,3 +118,28 @@ AIS_ViewInputBuffer.hxx
|
||||
AIS_ViewCube.cxx
|
||||
AIS_ViewCube.hxx
|
||||
AIS_WalkDelta.hxx
|
||||
AIS_AngleDimension.hxx
|
||||
AIS_Chamf2dDimension.hxx
|
||||
AIS_Chamf3dDimension.hxx
|
||||
AIS_ConcentricRelation.hxx
|
||||
AIS_DiameterDimension.hxx
|
||||
AIS_Dimension.hxx
|
||||
AIS_DimensionOwner.hxx
|
||||
AIS_EllipseRadiusDimension.hxx
|
||||
AIS_EqualDistanceRelation.hxx
|
||||
AIS_EqualRadiusRelation.hxx
|
||||
AIS_FixRelation.hxx
|
||||
AIS_IdenticRelation.hxx
|
||||
AIS_LengthDimension.hxx
|
||||
AIS_MaxRadiusDimension.hxx
|
||||
AIS_MidPointRelation.hxx
|
||||
AIS_MinRadiusDimension.hxx
|
||||
AIS_OffsetDimension.hxx
|
||||
AIS_ParallelRelation.hxx
|
||||
AIS_PerpendicularRelation.hxx
|
||||
AIS_RadiusDimension.hxx
|
||||
AIS_Relation.hxx
|
||||
AIS_SymmetricRelation.hxx
|
||||
AIS_TangentRelation.hxx
|
||||
AIS_XRTrackedDevice.cxx
|
||||
AIS_XRTrackedDevice.hxx
|
||||
|
@@ -378,11 +378,3 @@ Standard_Integer Adaptor2d_Curve2d::NbSamples() const
|
||||
return 20;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpJson
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Adaptor2d_Curve2d::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
|
||||
{
|
||||
OCCT_DUMP_CLASS_BEGIN (theOStream, Adaptor2d_Curve2d)
|
||||
}
|
||||
|
@@ -158,8 +158,6 @@ public:
|
||||
Standard_EXPORT virtual Handle(Geom2d_BSplineCurve) BSpline() const;
|
||||
Standard_EXPORT virtual ~Adaptor2d_Curve2d();
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
|
||||
|
||||
|
||||
|
||||
|
@@ -118,9 +118,6 @@ public:
|
||||
|
||||
virtual Handle(Geom2d_BSplineCurve) BSpline() const;
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
|
||||
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Adaptor2d_HCurve2d,Standard_Transient)
|
||||
};
|
||||
|
@@ -294,11 +294,3 @@ inline Standard_Integer Adaptor2d_HCurve2d::NbKnots() const
|
||||
return Curve2d().BSpline();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpJson
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline void Adaptor2d_HCurve2d::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
|
||||
{
|
||||
OCCT_DUMP_CLASS_BEGIN (theOStream, Adaptor2d_HCurve2d)
|
||||
}
|
||||
|
@@ -364,12 +364,3 @@ Handle(Geom_OffsetCurve) Adaptor3d_Curve::OffsetCurve() const
|
||||
{
|
||||
throw Standard_NotImplemented("Adaptor3d_Curve::OffsetCurve");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpJson
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Adaptor3d_Curve::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
|
||||
{
|
||||
OCCT_DUMP_CLASS_BEGIN (theOStream, Adaptor3d_Curve)
|
||||
}
|
||||
|
@@ -161,8 +161,6 @@ public:
|
||||
|
||||
Standard_EXPORT virtual ~Adaptor3d_Curve();
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
|
||||
|
||||
|
||||
|
||||
|
@@ -1796,23 +1796,5 @@ void Adaptor3d_CurveOnSurface::LocatePart(const gp_Pnt2d& UV, const gp_Vec2d& DU
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpJson
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Adaptor3d_CurveOnSurface::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_CLASS_BEGIN (theOStream, Adaptor3d_CurveOnSurface)
|
||||
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Adaptor3d_CurveOnSurface)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myType)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCirc)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myLin)
|
||||
|
||||
if (!myIntervals.IsNull())
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIntervals->Length())
|
||||
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIntCont)
|
||||
}
|
||||
|
||||
|
||||
|
@@ -181,9 +181,6 @@ public:
|
||||
|
||||
Standard_EXPORT Handle(Geom_BSplineCurve) BSpline() const Standard_OVERRIDE;
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -137,8 +137,6 @@ public:
|
||||
|
||||
Handle(Geom_OffsetCurve) OffsetCurve() const;
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Adaptor3d_HCurve,Standard_Transient)
|
||||
|
||||
|
@@ -302,12 +302,3 @@ inline Standard_Integer Adaptor3d_HCurve::NbKnots() const
|
||||
{
|
||||
return Curve().OffsetCurve();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpJson
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline void Adaptor3d_HCurve::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
|
||||
{
|
||||
OCCT_DUMP_CLASS_BEGIN (theOStream, Adaptor3d_HCurve)
|
||||
}
|
||||
|
@@ -59,8 +59,6 @@ public:
|
||||
//! Returns the curve used to create the GenHCurve.
|
||||
Adaptor3d_CurveOnSurface& ChangeCurve();
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
|
||||
|
||||
|
@@ -40,14 +40,3 @@
|
||||
#define Handle_Adaptor3d_GenHCurve Handle(Adaptor3d_HCurveOnSurface)
|
||||
#include <Adaptor3d_GenHCurve.gxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpJson
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Adaptor3d_HCurveOnSurface::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Adaptor3d_HCurve)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCurve)
|
||||
}
|
||||
|
@@ -161,8 +161,6 @@ public:
|
||||
|
||||
Standard_Real OffsetValue() const;
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
|
||||
|
||||
|
||||
|
||||
|
@@ -483,12 +483,3 @@ inline Standard_Boolean Adaptor3d_HSurface::IsVRational() const
|
||||
{
|
||||
return Surface().OffsetValue();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpJson
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline void Adaptor3d_HSurface::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||
}
|
||||
|
@@ -571,12 +571,3 @@ Standard_Real Adaptor3d_Surface::OffsetValue() const
|
||||
{
|
||||
throw Standard_NotImplemented("Adaptor3d_Surface::OffsetValue");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpJson
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Adaptor3d_Surface::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
|
||||
{
|
||||
OCCT_DUMP_CLASS_BEGIN (theOStream, Adaptor3d_Surface)
|
||||
}
|
||||
|
@@ -20,7 +20,6 @@
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
|
||||
#include <Standard_Real.hxx>
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
@@ -212,9 +211,6 @@ public:
|
||||
Standard_EXPORT virtual Standard_Real OffsetValue() const;
|
||||
Standard_EXPORT virtual ~Adaptor3d_Surface();
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -244,7 +244,7 @@ void AdvApp2Var_ApproxAFunc2Var::InitGrid(const Standard_Integer NbInt)
|
||||
{
|
||||
Standard_Integer iu=myConditions.UOrder(),iv=myConditions.VOrder(),iint;
|
||||
|
||||
AdvApp2Var_Patch M0(myFirstParInU,myLastParInU,myFirstParInV,myLastParInV,iu,iv);
|
||||
Handle(AdvApp2Var_Patch) M0 = new AdvApp2Var_Patch (myFirstParInU,myLastParInU,myFirstParInV,myLastParInV,iu,iv);
|
||||
|
||||
AdvApp2Var_SequenceOfPatch Net;
|
||||
Net.Append(M0);
|
||||
@@ -259,29 +259,29 @@ void AdvApp2Var_ApproxAFunc2Var::InitGrid(const Standard_Integer NbInt)
|
||||
|
||||
|
||||
gp_XY UV1(myFirstParInU,myFirstParInV);
|
||||
AdvApp2Var_Node C1(UV1,iu,iv);
|
||||
Handle(AdvApp2Var_Node) C1 = new AdvApp2Var_Node (UV1,iu,iv);
|
||||
gp_XY UV2(myLastParInU,myFirstParInV);
|
||||
AdvApp2Var_Node C2(UV2,iu,iv);
|
||||
Handle(AdvApp2Var_Node) C2 = new AdvApp2Var_Node (UV2,iu,iv);
|
||||
gp_XY UV4(myLastParInU,myLastParInV);
|
||||
AdvApp2Var_Node C4(UV4,iu,iv);
|
||||
Handle(AdvApp2Var_Node) C4 = new AdvApp2Var_Node (UV4,iu,iv);
|
||||
gp_XY UV3(myFirstParInU,myLastParInV);
|
||||
AdvApp2Var_Node C3(UV3,iu,iv);
|
||||
Handle(AdvApp2Var_Node) C3 = new AdvApp2Var_Node (UV3,iu,iv);
|
||||
AdvApp2Var_SequenceOfNode Bag;
|
||||
Bag.Append(C1);
|
||||
Bag.Append(C2);
|
||||
Bag.Append(C3);
|
||||
Bag.Append(C4);
|
||||
|
||||
AdvApp2Var_Iso V0(GeomAbs_IsoV,myFirstParInV,
|
||||
Handle(AdvApp2Var_Iso) V0 = new AdvApp2Var_Iso (GeomAbs_IsoV,myFirstParInV,
|
||||
myFirstParInU,myLastParInU,myFirstParInV,myLastParInV,
|
||||
1,iu,iv);
|
||||
AdvApp2Var_Iso V1(GeomAbs_IsoV,myLastParInV,
|
||||
Handle(AdvApp2Var_Iso) V1 = new AdvApp2Var_Iso (GeomAbs_IsoV,myLastParInV,
|
||||
myFirstParInU,myLastParInU,myFirstParInV,myLastParInV,
|
||||
2,iu,iv);
|
||||
AdvApp2Var_Iso U0(GeomAbs_IsoU,myFirstParInU,
|
||||
Handle(AdvApp2Var_Iso) U0 = new AdvApp2Var_Iso (GeomAbs_IsoU,myFirstParInU,
|
||||
myFirstParInU,myLastParInU,myFirstParInV,myLastParInV,
|
||||
3,iu,iv);
|
||||
AdvApp2Var_Iso U1(GeomAbs_IsoU,myLastParInU,
|
||||
Handle(AdvApp2Var_Iso) U1 = new AdvApp2Var_Iso (GeomAbs_IsoU,myLastParInU,
|
||||
myFirstParInU,myLastParInU,myFirstParInV,myLastParInV,
|
||||
4,iu,iv);
|
||||
|
||||
@@ -557,68 +557,74 @@ void AdvApp2Var_ApproxAFunc2Var::ComputeConstraints(const AdvApprox_Cutting& UCh
|
||||
Standard_Real dec;
|
||||
Standard_Boolean more;
|
||||
Standard_Integer ind1, ind2, NbPatch, NbU, NbV;
|
||||
AdvApp2Var_Iso Is;
|
||||
Standard_Integer indN1, indN2;
|
||||
Standard_Integer iu = myConditions.UOrder(), iv = myConditions.VOrder();
|
||||
AdvApp2Var_Node N1(iu,iv), N2(iu,iv);
|
||||
|
||||
while ( myConstraints.FirstNotApprox(ind1, ind2, Is) ) {
|
||||
for (Handle(AdvApp2Var_Iso) anIso = myConstraints.FirstNotApprox(ind1, ind2); !anIso.IsNull(); anIso = myConstraints.FirstNotApprox(ind1, ind2))
|
||||
{
|
||||
// approximation of iso and calculation of constraints at extremities
|
||||
const Standard_Integer indN1 = myConstraints.FirstNode(anIso->Type(),ind1,ind2);
|
||||
N1 = *myConstraints.Node(indN1);
|
||||
const Standard_Integer indN2 = myConstraints.LastNode(anIso->Type(),ind1,ind2);
|
||||
N2 = *myConstraints.Node(indN2);
|
||||
|
||||
// approximation of iso and calculation of constraints at extremities
|
||||
indN1 = myConstraints.FirstNode(Is.Type(),ind1,ind2);
|
||||
N1 = myConstraints.Node(indN1);
|
||||
indN2 = myConstraints.LastNode(Is.Type(),ind1,ind2);
|
||||
N2 = myConstraints.Node(indN2);
|
||||
|
||||
Is.MakeApprox(myConditions,
|
||||
myFirstParInU, myLastParInU,
|
||||
myFirstParInV, myLastParInV,
|
||||
Func, N1 , N2);
|
||||
|
||||
if (Is.IsApproximated()) {
|
||||
// iso is approached at the required tolerance
|
||||
myConstraints.ChangeIso(ind1,ind2,Is);
|
||||
myConstraints.ChangeNode(indN1) = N1;
|
||||
myConstraints.ChangeNode(indN2) = N2;
|
||||
// note that old code attempted to make copy of anIso here (but copy was incomplete)
|
||||
anIso->MakeApprox (myConditions,
|
||||
myFirstParInU, myLastParInU,
|
||||
myFirstParInV, myLastParInV,
|
||||
Func, N1 , N2);
|
||||
if (anIso->IsApproximated())
|
||||
{
|
||||
// iso is approached at the required tolerance
|
||||
myConstraints.ChangeIso(ind1,ind2,anIso);
|
||||
*myConstraints.Node(indN1) = N1;
|
||||
*myConstraints.Node(indN2) = N2;
|
||||
}
|
||||
|
||||
else {
|
||||
// Approximation is not satisfactory
|
||||
else
|
||||
{
|
||||
// Approximation is not satisfactory
|
||||
NbU = myResult.NbPatchInU();
|
||||
NbV = myResult.NbPatchInV();
|
||||
if (Is.Type()==GeomAbs_IsoV) {
|
||||
NbPatch = (NbU+1)*NbV;
|
||||
more = UChoice.Value(Is.T0(),Is.T1(),dec);
|
||||
if (anIso->Type()==GeomAbs_IsoV)
|
||||
{
|
||||
NbPatch = (NbU+1)*NbV;
|
||||
more = UChoice.Value(anIso->T0(), anIso->T1(), dec);
|
||||
}
|
||||
else {
|
||||
NbPatch = (NbV+1)*NbU;
|
||||
more = VChoice.Value(Is.T0(),Is.T1(),dec);
|
||||
else
|
||||
{
|
||||
NbPatch = (NbV+1)*NbU;
|
||||
more = VChoice.Value(anIso->T0(),anIso->T1(),dec);
|
||||
}
|
||||
|
||||
if (NbPatch<=myMaxPatches && more) {
|
||||
// It is possible to cut iso
|
||||
if (Is.Type()==GeomAbs_IsoV) {
|
||||
myResult.UpdateInU(dec);
|
||||
myConstraints.UpdateInU(dec);
|
||||
}
|
||||
else {
|
||||
myResult.UpdateInV(dec);
|
||||
myConstraints.UpdateInV(dec);
|
||||
}
|
||||
if (NbPatch<=myMaxPatches && more)
|
||||
{
|
||||
// It is possible to cut iso
|
||||
if (anIso->Type()==GeomAbs_IsoV)
|
||||
{
|
||||
myResult.UpdateInU(dec);
|
||||
myConstraints.UpdateInU(dec);
|
||||
}
|
||||
else
|
||||
{
|
||||
myResult.UpdateInV(dec);
|
||||
myConstraints.UpdateInV(dec);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
// It is not possible to cut : the result is preserved
|
||||
if (Is.HasResult()) {
|
||||
Is.OverwriteApprox();
|
||||
myConstraints.ChangeIso(ind1,ind2,Is);
|
||||
myConstraints.ChangeNode(indN1) = N1;
|
||||
myConstraints.ChangeNode(indN2) = N2;
|
||||
}
|
||||
else {
|
||||
myHasResult = myDone = Standard_False;
|
||||
throw Standard_ConstructionError("AdvApp2Var_ApproxAFunc2Var : Curve Approximation Error");
|
||||
}
|
||||
else
|
||||
{
|
||||
// It is not possible to cut : the result is preserved
|
||||
if (anIso->HasResult())
|
||||
{
|
||||
anIso->OverwriteApprox();
|
||||
myConstraints.ChangeIso(ind1,ind2,anIso);
|
||||
*myConstraints.Node(indN1) = N1;
|
||||
*myConstraints.Node(indN2) = N2;
|
||||
}
|
||||
else
|
||||
{
|
||||
myHasResult = myDone = Standard_False;
|
||||
throw Standard_ConstructionError("AdvApp2Var_ApproxAFunc2Var : Curve Approximation Error");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -638,74 +644,82 @@ void AdvApp2Var_ApproxAFunc2Var::ComputeConstraints(const AdvApprox_Cutting& UCh
|
||||
Standard_Real dec;
|
||||
Standard_Boolean more, CritRel = (Crit.Type() == AdvApp2Var_Relative);
|
||||
Standard_Integer ind1, ind2, NbPatch, NbU, NbV;
|
||||
AdvApp2Var_Iso Is;
|
||||
Standard_Integer indN1, indN2;
|
||||
Standard_Integer iu = myConditions.UOrder(), iv = myConditions.VOrder();
|
||||
AdvApp2Var_Node N1(iu,iv), N2(iu,iv);
|
||||
|
||||
while ( myConstraints.FirstNotApprox(ind1, ind2, Is) ) {
|
||||
for (Handle(AdvApp2Var_Iso) anIso = myConstraints.FirstNotApprox(ind1, ind2); !anIso.IsNull(); anIso = myConstraints.FirstNotApprox(ind1, ind2))
|
||||
{
|
||||
// approximation of the iso and calculation of constraints at the extremities
|
||||
indN1 = myConstraints.FirstNode(anIso->Type(),ind1,ind2);
|
||||
N1 = *myConstraints.Node(indN1);
|
||||
indN2 = myConstraints.LastNode(anIso->Type(),ind1,ind2);
|
||||
N2 = *myConstraints.Node(indN2);
|
||||
|
||||
// approximation of the iso and calculation of constraints at the extremities
|
||||
indN1 = myConstraints.FirstNode(Is.Type(),ind1,ind2);
|
||||
N1 = myConstraints.Node(indN1);
|
||||
indN2 = myConstraints.LastNode(Is.Type(),ind1,ind2);
|
||||
N2 = myConstraints.Node(indN2);
|
||||
// note that old code attempted to make copy of anIso here (but copy was incomplete)
|
||||
anIso->MakeApprox (myConditions,
|
||||
myFirstParInU, myLastParInU,
|
||||
myFirstParInV, myLastParInV,
|
||||
Func, N1 , N2);
|
||||
|
||||
Is.MakeApprox(myConditions,
|
||||
myFirstParInU, myLastParInU,
|
||||
myFirstParInV, myLastParInV,
|
||||
Func, N1 , N2);
|
||||
|
||||
if (Is.IsApproximated()) {
|
||||
// iso is approached at the required tolerance
|
||||
myConstraints.ChangeIso(ind1,ind2,Is);
|
||||
myConstraints.ChangeNode(indN1) = N1;
|
||||
myConstraints.ChangeNode(indN2) = N2;
|
||||
if (anIso->IsApproximated())
|
||||
{
|
||||
// iso is approached at the required tolerance
|
||||
myConstraints.ChangeIso(ind1,ind2,anIso);
|
||||
*myConstraints.Node(indN1) = N1;
|
||||
*myConstraints.Node(indN2) = N2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Approximation is not satisfactory
|
||||
NbU = myResult.NbPatchInU();
|
||||
NbV = myResult.NbPatchInV();
|
||||
if (anIso->Type()==GeomAbs_IsoV)
|
||||
{
|
||||
NbPatch = (NbU+1)*NbV;
|
||||
more = UChoice.Value(anIso->T0(),anIso->T1(),dec);
|
||||
}
|
||||
else
|
||||
{
|
||||
NbPatch = (NbV+1)*NbU;
|
||||
more = VChoice.Value(anIso->T0(),anIso->T1(),dec);
|
||||
}
|
||||
|
||||
else {
|
||||
// Approximation is not satisfactory
|
||||
NbU = myResult.NbPatchInU();
|
||||
NbV = myResult.NbPatchInV();
|
||||
if (Is.Type()==GeomAbs_IsoV) {
|
||||
NbPatch = (NbU+1)*NbV;
|
||||
more = UChoice.Value(Is.T0(),Is.T1(),dec);
|
||||
}
|
||||
else {
|
||||
NbPatch = (NbV+1)*NbU;
|
||||
more = VChoice.Value(Is.T0(),Is.T1(),dec);
|
||||
}
|
||||
// To force Overwrite if the criterion is Absolute
|
||||
more = more && (CritRel);
|
||||
|
||||
// To force Overwrite if the criterion is Absolute
|
||||
more = more && (CritRel);
|
||||
|
||||
if (NbPatch<=myMaxPatches && more) {
|
||||
// It is possible to cut iso
|
||||
if (Is.Type()==GeomAbs_IsoV) {
|
||||
myResult.UpdateInU(dec);
|
||||
myConstraints.UpdateInU(dec);
|
||||
}
|
||||
else {
|
||||
myResult.UpdateInV(dec);
|
||||
myConstraints.UpdateInV(dec);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
// It is not possible to cut: the result is preserved
|
||||
if (Is.HasResult()) {
|
||||
Is.OverwriteApprox();
|
||||
myConstraints.ChangeIso(ind1,ind2,Is);
|
||||
myConstraints.ChangeNode(indN1) = N1;
|
||||
myConstraints.ChangeNode(indN2) = N2;
|
||||
}
|
||||
else {
|
||||
myHasResult = myDone = Standard_False;
|
||||
throw Standard_ConstructionError("AdvApp2Var_ApproxAFunc2Var : Curve Approximation Error");
|
||||
}
|
||||
}
|
||||
if (NbPatch<=myMaxPatches && more)
|
||||
{
|
||||
// It is possible to cut iso
|
||||
if (anIso->Type()==GeomAbs_IsoV)
|
||||
{
|
||||
myResult.UpdateInU(dec);
|
||||
myConstraints.UpdateInU(dec);
|
||||
}
|
||||
else
|
||||
{
|
||||
myResult.UpdateInV(dec);
|
||||
myConstraints.UpdateInV(dec);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// It is not possible to cut: the result is preserved
|
||||
if (anIso->HasResult())
|
||||
{
|
||||
anIso->OverwriteApprox();
|
||||
myConstraints.ChangeIso(ind1,ind2,anIso);
|
||||
*myConstraints.Node(indN1) = N1;
|
||||
*myConstraints.Node(indN2) = N2;
|
||||
}
|
||||
else
|
||||
{
|
||||
myHasResult = myDone = Standard_False;
|
||||
throw Standard_ConstructionError("AdvApp2Var_ApproxAFunc2Var : Curve Approximation Error");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -57,43 +57,30 @@ AdvApp2Var_Framework::AdvApp2Var_Framework(const AdvApp2Var_SequenceOfNode& Fram
|
||||
//purpose : return the first Iso not approximated
|
||||
//==========================================================================================
|
||||
|
||||
Standard_Boolean AdvApp2Var_Framework::FirstNotApprox(Standard_Integer& IndexIso,
|
||||
Standard_Integer& IndexStrip,
|
||||
AdvApp2Var_Iso& anIso) const
|
||||
Handle(AdvApp2Var_Iso) AdvApp2Var_Framework::FirstNotApprox(Standard_Integer& IndexIso,
|
||||
Standard_Integer& IndexStrip) const
|
||||
{
|
||||
Standard_Boolean good = Standard_True;
|
||||
Standard_Integer i,j;
|
||||
AdvApp2Var_Strip S;
|
||||
|
||||
for (i = 1; i <= myUConstraints.Length() && good ; i++) {
|
||||
S = myUConstraints.Value(i);
|
||||
for (j = 1; j <= S.Length() && good ; j++) {
|
||||
good = (S.Value(j)).IsApproximated();
|
||||
if (!good) {
|
||||
IndexIso = j;
|
||||
IndexStrip = i;
|
||||
anIso = S.Value(j);
|
||||
for (int anUVIter = 0; anUVIter < 2; ++anUVIter)
|
||||
{
|
||||
const AdvApp2Var_SequenceOfStrip& aSeq = anUVIter == 0 ? myUConstraints : myVConstraints;
|
||||
Standard_Integer i = 1;
|
||||
for (AdvApp2Var_SequenceOfStrip::Iterator aConstIter (aSeq); aConstIter.More(); aConstIter.Next(), i++)
|
||||
{
|
||||
const AdvApp2Var_Strip& S = aConstIter.Value();
|
||||
Standard_Integer j = 1;
|
||||
for (AdvApp2Var_Strip::Iterator anIsoIter (S); anIsoIter.More(); anIsoIter.Next(), j++)
|
||||
{
|
||||
const Handle(AdvApp2Var_Iso)& anIso = anIsoIter.Value();
|
||||
if (!anIso->IsApproximated())
|
||||
{
|
||||
IndexIso = j;
|
||||
IndexStrip = i;
|
||||
return anIso;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!good) {
|
||||
goto FINISH;
|
||||
}
|
||||
|
||||
for (i = 1; i <= myVConstraints.Length() && good; i++) {
|
||||
S = myVConstraints.Value(i);
|
||||
for (j = 1; j <= S.Length() && good ; j++) {
|
||||
good = (S.Value(j)).IsApproximated();
|
||||
if (!good) {
|
||||
IndexIso = j;
|
||||
IndexStrip = i;
|
||||
anIso = S.Value(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FINISH:
|
||||
return !good;
|
||||
return Handle(AdvApp2Var_Iso)();
|
||||
}
|
||||
|
||||
//==========================================================================================
|
||||
@@ -145,19 +132,12 @@ Standard_Integer AdvApp2Var_Framework::LastNode(const GeomAbs_IsoType Type,
|
||||
|
||||
void AdvApp2Var_Framework::ChangeIso(const Standard_Integer IndexIso,
|
||||
const Standard_Integer IndexStrip,
|
||||
const AdvApp2Var_Iso& anIso)
|
||||
const Handle(AdvApp2Var_Iso)& theIso)
|
||||
{
|
||||
AdvApp2Var_Strip S0;
|
||||
if (anIso.Type()==GeomAbs_IsoV) {
|
||||
S0 = myUConstraints.Value(IndexStrip);
|
||||
S0.SetValue(IndexIso,anIso);
|
||||
myUConstraints.SetValue(IndexStrip,S0);
|
||||
}
|
||||
else {
|
||||
S0 = myVConstraints.Value(IndexStrip);
|
||||
S0.SetValue(IndexIso,anIso);
|
||||
myVConstraints.SetValue(IndexStrip,S0);
|
||||
}
|
||||
AdvApp2Var_Strip& S0 = theIso->Type() == GeomAbs_IsoV
|
||||
? myUConstraints.ChangeValue (IndexStrip)
|
||||
: myVConstraints.ChangeValue (IndexStrip);
|
||||
S0.SetValue (IndexIso, theIso);
|
||||
}
|
||||
|
||||
//==========================================================================================
|
||||
@@ -165,16 +145,19 @@ void AdvApp2Var_Framework::ChangeIso(const Standard_Integer IndexIso,
|
||||
//purpose : return the node of coordinates (U,V)
|
||||
//==========================================================================================
|
||||
|
||||
const AdvApp2Var_Node& AdvApp2Var_Framework::Node(const Standard_Real U,
|
||||
const Handle(AdvApp2Var_Node)& AdvApp2Var_Framework::Node(const Standard_Real U,
|
||||
const Standard_Real V) const
|
||||
{
|
||||
Standard_Integer Index=1;
|
||||
while ( ( ((myNodeConstraints.Value(Index)).Coord()).X() != U
|
||||
|| ((myNodeConstraints.Value(Index)).Coord()).Y() != V )
|
||||
&& (Index<myNodeConstraints.Length()) ) {
|
||||
Index++;
|
||||
for (AdvApp2Var_SequenceOfNode::Iterator aNodeIter (myNodeConstraints); aNodeIter.More(); aNodeIter.Next())
|
||||
{
|
||||
const Handle(AdvApp2Var_Node)& aNode = aNodeIter.Value();
|
||||
if (aNode->Coord().X() == U
|
||||
&& aNode->Coord().Y() == V)
|
||||
{
|
||||
return aNode;
|
||||
}
|
||||
}
|
||||
return myNodeConstraints.Value(Index);
|
||||
return myNodeConstraints.Last();
|
||||
}
|
||||
|
||||
//==========================================================================================
|
||||
@@ -187,17 +170,20 @@ AdvApp2Var_Framework::IsoU(const Standard_Real U,
|
||||
const Standard_Real V0,
|
||||
const Standard_Real V1) const
|
||||
{
|
||||
Standard_Integer IndexStrip=1,IndexIso=1;
|
||||
while ( ( ((myVConstraints.Value(IndexStrip)).Value(1)).T0() != V0
|
||||
|| ((myVConstraints.Value(IndexStrip)).Value(1)).T1() != V1 )
|
||||
&& (IndexStrip<myVConstraints.Length()) ) {
|
||||
Standard_Integer IndexStrip = 1;
|
||||
while (IndexStrip < myVConstraints.Length()
|
||||
&& (myVConstraints.Value(IndexStrip).First()->T0() != V0
|
||||
|| myVConstraints.Value(IndexStrip).First()->T1() != V1))
|
||||
{
|
||||
IndexStrip++;
|
||||
}
|
||||
while ( ( ((myVConstraints.Value(IndexStrip)).Value(IndexIso)).Constante() != U)
|
||||
&& (IndexIso<=myUConstraints.Length()) ) {
|
||||
Standard_Integer IndexIso = 1;
|
||||
while (IndexIso<=myUConstraints.Length()
|
||||
&& myVConstraints.Value(IndexStrip).Value(IndexIso)->Constante() != U)
|
||||
{
|
||||
IndexIso++;
|
||||
}
|
||||
return (myVConstraints.Value(IndexStrip)).Value(IndexIso);
|
||||
return *(myVConstraints.Value(IndexStrip).Value(IndexIso));
|
||||
}
|
||||
|
||||
//==========================================================================================
|
||||
@@ -210,17 +196,20 @@ AdvApp2Var_Framework::IsoV(const Standard_Real U0,
|
||||
const Standard_Real U1,
|
||||
const Standard_Real V) const
|
||||
{
|
||||
Standard_Integer IndexStrip=1,IndexIso=1;
|
||||
while ( ( ((myUConstraints.Value(IndexStrip)).Value(1)).T0() != U0
|
||||
|| ((myUConstraints.Value(IndexStrip)).Value(1)).T1() != U1 )
|
||||
&& (IndexStrip<myUConstraints.Length()) ) {
|
||||
Standard_Integer IndexStrip = 1;
|
||||
while (IndexStrip < myUConstraints.Length()
|
||||
&& (myUConstraints.Value(IndexStrip).First()->T0() != U0
|
||||
|| myUConstraints.Value(IndexStrip).First()->T1() != U1))
|
||||
{
|
||||
IndexStrip++;
|
||||
}
|
||||
while ( ( ((myUConstraints.Value(IndexStrip)).Value(IndexIso)).Constante() != V)
|
||||
&& (IndexIso<=myVConstraints.Length()) ) {
|
||||
Standard_Integer IndexIso = 1;
|
||||
while (IndexIso<=myVConstraints.Length()
|
||||
&& myUConstraints.Value(IndexStrip).Value(IndexIso)->Constante() != V)
|
||||
{
|
||||
IndexIso++;
|
||||
}
|
||||
return (myUConstraints.Value(IndexStrip)).Value(IndexIso);
|
||||
return *(myUConstraints.Value(IndexStrip).Value(IndexIso));
|
||||
}
|
||||
|
||||
//==========================================================================================
|
||||
@@ -230,65 +219,74 @@ AdvApp2Var_Framework::IsoV(const Standard_Real U0,
|
||||
|
||||
void AdvApp2Var_Framework::UpdateInU(const Standard_Real CuttingValue)
|
||||
{
|
||||
Standard_Integer i=1,j;
|
||||
while (((myUConstraints.Value(i)).Value(1)).U0()>CuttingValue
|
||||
|| ((myUConstraints.Value(i)).Value(1)).U1()<CuttingValue) {
|
||||
i++;
|
||||
Standard_Integer i = 1;
|
||||
for (AdvApp2Var_SequenceOfStrip::Iterator anUConstIter (myUConstraints); anUConstIter.More(); anUConstIter.Next(), ++i)
|
||||
{
|
||||
if (anUConstIter.Value().First()->U0() <= CuttingValue
|
||||
&& anUConstIter.Value().First()->U1() >= CuttingValue)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
AdvApp2Var_Strip S0;
|
||||
AdvApp2Var_Iso Is;
|
||||
S0 = myUConstraints.Value(i);
|
||||
Standard_Real Udeb = (S0.Value(1)).U0(), Ufin = (S0.Value(1)).U1();
|
||||
|
||||
// modification des Isos V de la bande en U d'indice i
|
||||
for (j=1;j<=S0.Length();j++) {
|
||||
Is = S0.Value(j);
|
||||
Is.ChangeDomain(Udeb,CuttingValue);
|
||||
Is.ResetApprox();
|
||||
S0.SetValue(j,Is);
|
||||
}
|
||||
myUConstraints.SetValue(i,S0);
|
||||
{
|
||||
const AdvApp2Var_Strip& S0 = myUConstraints.Value(i);
|
||||
const Standard_Real Udeb = S0.First()->U0(), Ufin = S0.First()->U1();
|
||||
|
||||
// insertion d'une nouvelle bande en U apres l'indice i
|
||||
AdvApp2Var_Strip NewStrip;
|
||||
for (j=1;j<=S0.Length();j++) {
|
||||
AdvApp2Var_Iso NewIso((S0.Value(j)).Type(),(S0.Value(j)).Constante(),
|
||||
CuttingValue,Ufin,(S0.Value(j)).V0(),(S0.Value(j)).V1(),
|
||||
0,(S0.Value(j)).UOrder(),(S0.Value(j)).VOrder());
|
||||
NewIso.ResetApprox();
|
||||
NewStrip.Append(NewIso);
|
||||
// modification des Isos V de la bande en U d'indice i
|
||||
for (AdvApp2Var_Strip::Iterator aStripIter (S0); aStripIter.More(); aStripIter.Next())
|
||||
{
|
||||
const Handle(AdvApp2Var_Iso)& anIso = aStripIter.Value();
|
||||
anIso->ChangeDomain (Udeb, CuttingValue);
|
||||
anIso->ResetApprox();
|
||||
}
|
||||
|
||||
// insertion d'une nouvelle bande en U apres l'indice i
|
||||
AdvApp2Var_Strip aNewStrip;
|
||||
for (AdvApp2Var_Strip::Iterator aStripIter (S0); aStripIter.More(); aStripIter.Next())
|
||||
{
|
||||
const Handle(AdvApp2Var_Iso)& anIso = aStripIter.Value();
|
||||
Handle(AdvApp2Var_Iso) aNewIso = new AdvApp2Var_Iso (anIso->Type(), anIso->Constante(),
|
||||
CuttingValue, Ufin, anIso->V0(), anIso->V1(),
|
||||
0, anIso->UOrder(), anIso->VOrder());
|
||||
aNewIso->ResetApprox();
|
||||
aNewStrip.Append (aNewIso);
|
||||
}
|
||||
myUConstraints.InsertAfter (i, aNewStrip);
|
||||
}
|
||||
myUConstraints.InsertAfter(i,NewStrip);
|
||||
|
||||
// insertion d'une nouvelle Iso U=U* dans chaque bande en V apres l'indice i
|
||||
// et restriction des paves des Isos adjacentes
|
||||
for (j=1;j<=myVConstraints.Length();j++) {
|
||||
S0 = myVConstraints.Value(j);
|
||||
Is = S0.Value(i);
|
||||
Is.ChangeDomain(Is.U0(),CuttingValue,Is.V0(),Is.V1());
|
||||
S0.SetValue(i,Is);
|
||||
AdvApp2Var_Iso NewIso(Is.Type(),CuttingValue,Is.U0(),CuttingValue,Is.V0(),Is.V1(),
|
||||
0,Is.UOrder(),Is.VOrder());
|
||||
NewIso.ResetApprox();
|
||||
S0.InsertAfter(i,NewIso);
|
||||
Is = S0.Value(i+2);
|
||||
Is.ChangeDomain(CuttingValue,Is.U1(),Is.V0(),Is.V1());
|
||||
S0.SetValue(i+2,Is);
|
||||
myVConstraints.SetValue(j,S0);
|
||||
for (Standard_Integer j = 1; j <= myVConstraints.Length(); j++)
|
||||
{
|
||||
AdvApp2Var_Strip& S0 = myVConstraints.ChangeValue(j);
|
||||
Handle(AdvApp2Var_Iso) anIso = S0.Value(i);
|
||||
anIso->ChangeDomain (anIso->U0(), CuttingValue, anIso->V0(), anIso->V1());
|
||||
|
||||
Handle(AdvApp2Var_Iso) aNewIso = new AdvApp2Var_Iso (anIso->Type(), CuttingValue, anIso->U0(), CuttingValue, anIso->V0(), anIso->V1(),
|
||||
0, anIso->UOrder(), anIso->VOrder());
|
||||
aNewIso->ResetApprox();
|
||||
S0.InsertAfter (i, aNewIso);
|
||||
|
||||
anIso = S0.Value(i+2);
|
||||
anIso->ChangeDomain (CuttingValue, anIso->U1(), anIso->V0(), anIso->V1());
|
||||
}
|
||||
|
||||
// insertion des nouveaux noeuds (U*,Vj)
|
||||
AdvApp2Var_Node Prev, Next;
|
||||
Prev=myNodeConstraints.Value(1);
|
||||
for (j=1;j<myNodeConstraints.Length();j++) {
|
||||
Next=myNodeConstraints.Value(j+1);
|
||||
if ((Prev.Coord()).X()<CuttingValue && ((Next.Coord()).X()>CuttingValue)
|
||||
&& ((Prev.Coord()).Y()==(Next.Coord()).Y())) {
|
||||
gp_XY NewUV(CuttingValue,(Prev.Coord()).Y());
|
||||
AdvApp2Var_Node NewNode(NewUV,Prev.UOrder(),Prev.VOrder());
|
||||
myNodeConstraints.InsertAfter(j,NewNode);
|
||||
Handle(AdvApp2Var_Node) aNext;
|
||||
Handle(AdvApp2Var_Node) aPrev = myNodeConstraints.First();
|
||||
for (Standard_Integer j = 1; j < myNodeConstraints.Length(); j++)
|
||||
{
|
||||
aNext = myNodeConstraints.Value(j+1);
|
||||
if (aPrev->Coord().X() < CuttingValue
|
||||
&& aNext->Coord().X() > CuttingValue
|
||||
&& aPrev->Coord().Y() == aNext->Coord().Y())
|
||||
{
|
||||
gp_XY aNewUV (CuttingValue, aPrev->Coord().Y());
|
||||
Handle(AdvApp2Var_Node) aNewNode = new AdvApp2Var_Node (aNewUV, aPrev->UOrder(), aPrev->VOrder());
|
||||
myNodeConstraints.InsertAfter (j, aNewNode);
|
||||
}
|
||||
Prev=Next;
|
||||
aPrev = aNext;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,65 +297,69 @@ void AdvApp2Var_Framework::UpdateInU(const Standard_Real CuttingValue)
|
||||
|
||||
void AdvApp2Var_Framework::UpdateInV(const Standard_Real CuttingValue)
|
||||
{
|
||||
Standard_Integer i,j=1;
|
||||
while (((myVConstraints.Value(j)).Value(1)).V0()>CuttingValue
|
||||
|| ((myVConstraints.Value(j)).Value(1)).V1()<CuttingValue) {
|
||||
Standard_Integer j=1;
|
||||
while (myVConstraints.Value(j).First()->V0() > CuttingValue
|
||||
|| myVConstraints.Value(j).First()->V1() < CuttingValue)
|
||||
{
|
||||
j++;
|
||||
}
|
||||
AdvApp2Var_Strip S0;
|
||||
AdvApp2Var_Iso Is;
|
||||
S0 = myVConstraints.Value(j);
|
||||
Standard_Real Vdeb = (S0.Value(1)).V0(), Vfin = (S0.Value(1)).V1();
|
||||
|
||||
// modification des Isos U de la bande en V d'indice j
|
||||
for (i=1;i<=S0.Length();i++) {
|
||||
Is = S0.Value(i);
|
||||
Is.ChangeDomain(Vdeb,CuttingValue);
|
||||
Is.ResetApprox();
|
||||
S0.SetValue(i,Is);
|
||||
{
|
||||
AdvApp2Var_Strip& S0 = myVConstraints.ChangeValue(j);
|
||||
const Standard_Real Vdeb = S0.First()->V0(), Vfin = S0.First()->V1();
|
||||
|
||||
// modification des Isos U de la bande en V d'indice j
|
||||
for (AdvApp2Var_Strip::Iterator anIsoIter (S0); anIsoIter.More(); anIsoIter.Next())
|
||||
{
|
||||
const Handle(AdvApp2Var_Iso)& anIso = anIsoIter.Value();
|
||||
anIso->ChangeDomain (Vdeb, CuttingValue);
|
||||
anIso->ResetApprox();
|
||||
}
|
||||
|
||||
// insertion d'une nouvelle bande en V apres l'indice j
|
||||
AdvApp2Var_Strip aNewStrip;
|
||||
for (AdvApp2Var_Strip::Iterator anIsoIter (S0); anIsoIter.More(); anIsoIter.Next())
|
||||
{
|
||||
const Handle(AdvApp2Var_Iso)& anIso = anIsoIter.Value();
|
||||
Handle(AdvApp2Var_Iso) aNewIso = new AdvApp2Var_Iso (anIso->Type(), anIso->Constante(),
|
||||
anIso->U0(), anIso->U1(), CuttingValue, Vfin,
|
||||
0, anIso->UOrder(), anIso->VOrder());
|
||||
aNewIso->ResetApprox();
|
||||
aNewStrip.Append (aNewIso);
|
||||
}
|
||||
myVConstraints.InsertAfter(j, aNewStrip);
|
||||
}
|
||||
myVConstraints.SetValue(j,S0);
|
||||
|
||||
// insertion d'une nouvelle bande en V apres l'indice j
|
||||
AdvApp2Var_Strip NewStrip;
|
||||
for (i=1;i<=S0.Length();i++) {
|
||||
AdvApp2Var_Iso NewIso((S0.Value(i)).Type(),(S0.Value(i)).Constante(),
|
||||
(S0.Value(i)).U0(),(S0.Value(i)).U1(),CuttingValue,Vfin,
|
||||
0,(S0.Value(i)).UOrder(),(S0.Value(i)).VOrder());
|
||||
NewIso.ResetApprox();
|
||||
NewStrip.Append(NewIso);
|
||||
}
|
||||
myVConstraints.InsertAfter(j,NewStrip);
|
||||
// insertion d'une nouvelle Iso V=V* dans chaque bande en U apres l'indice j
|
||||
// et restriction des paves des Isos adjacentes
|
||||
for (AdvApp2Var_SequenceOfStrip::Iterator anUConstIter (myUConstraints); anUConstIter.More(); anUConstIter.Next())
|
||||
{
|
||||
AdvApp2Var_Strip& S0 = anUConstIter.ChangeValue();
|
||||
Handle(AdvApp2Var_Iso) anIso = S0.Value(j);
|
||||
anIso->ChangeDomain (anIso->U0(), anIso->U1(), anIso->V0(), CuttingValue);
|
||||
|
||||
// insertion d'une nouvelle Iso V=V* dans chaque bande en U apres l'indice j
|
||||
// et restriction des paves des Isos adjacentes
|
||||
for (i=1;i<=myUConstraints.Length();i++) {
|
||||
S0 = myUConstraints.Value(i);
|
||||
Is = S0.Value(j);
|
||||
Is.ChangeDomain(Is.U0(),Is.U1(),Is.V0(),CuttingValue);
|
||||
S0.SetValue(j,Is);
|
||||
AdvApp2Var_Iso NewIso(Is.Type(),CuttingValue,Is.U0(),Is.U1(),Is.V0(),CuttingValue,
|
||||
0,Is.UOrder(),Is.VOrder());
|
||||
NewIso.ResetApprox();
|
||||
S0.InsertAfter(j,NewIso);
|
||||
Is = S0.Value(j+2);
|
||||
Is.ChangeDomain(Is.U0(),Is.U1(),CuttingValue,Is.V1());
|
||||
S0.SetValue(j+2,Is);
|
||||
myUConstraints.SetValue(i,S0);
|
||||
Handle(AdvApp2Var_Iso) aNewIso = new AdvApp2Var_Iso (anIso->Type(), CuttingValue, anIso->U0(), anIso->U1(), anIso->V0(), CuttingValue,
|
||||
0, anIso->UOrder(), anIso->VOrder());
|
||||
aNewIso->ResetApprox();
|
||||
S0.InsertAfter (j, aNewIso);
|
||||
|
||||
anIso = S0.Value (j + 2);
|
||||
anIso->ChangeDomain (anIso->U0(), anIso->U1(), CuttingValue, anIso->V1());
|
||||
}
|
||||
|
||||
// insertion des nouveaux noeuds (Ui,V*)
|
||||
i = 1;
|
||||
while ( i<=myNodeConstraints.Length()
|
||||
&& ( ((myNodeConstraints.Value(i)).Coord()).Y()) < CuttingValue) {
|
||||
i+=myUConstraints.Length()+1;
|
||||
Standard_Integer i = 1;
|
||||
while (i <= myNodeConstraints.Length()
|
||||
&& myNodeConstraints.Value(i)->Coord().Y() < CuttingValue)
|
||||
{
|
||||
i += myUConstraints.Length() + 1;
|
||||
}
|
||||
for (j=1;j<=myUConstraints.Length()+1;j++) {
|
||||
gp_XY NewUV(((myNodeConstraints.Value(j)).Coord()).X(),CuttingValue);
|
||||
AdvApp2Var_Node NewNode(NewUV,
|
||||
(myNodeConstraints.Value(j)).UOrder(),
|
||||
(myNodeConstraints.Value(j)).VOrder());
|
||||
myNodeConstraints.InsertAfter(i+j-2,NewNode);
|
||||
for (j = 1; j <= myUConstraints.Length() + 1; j++)
|
||||
{
|
||||
const Handle(AdvApp2Var_Node)& aJNode = myNodeConstraints.Value(j);
|
||||
gp_XY NewUV (aJNode->Coord().X(), CuttingValue);
|
||||
Handle(AdvApp2Var_Node) aNewNode = new AdvApp2Var_Node (NewUV, aJNode->UOrder(), aJNode->VOrder());
|
||||
myNodeConstraints.InsertAfter (i+j-2, aNewNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,7 +372,7 @@ const Handle(TColStd_HArray1OfReal)&
|
||||
AdvApp2Var_Framework::UEquation(const Standard_Integer IndexIso,
|
||||
const Standard_Integer IndexStrip) const
|
||||
{
|
||||
return ((myVConstraints.Value(IndexStrip)).Value(IndexIso)).Polynom();
|
||||
return myVConstraints.Value(IndexStrip).Value(IndexIso)->Polynom();
|
||||
}
|
||||
|
||||
//==========================================================================================
|
||||
@@ -382,6 +384,6 @@ const Handle(TColStd_HArray1OfReal)&
|
||||
AdvApp2Var_Framework::VEquation(const Standard_Integer IndexIso,
|
||||
const Standard_Integer IndexStrip) const
|
||||
{
|
||||
return myUConstraints.Value(IndexStrip).Value(IndexIso).Polynom();
|
||||
return myUConstraints.Value(IndexStrip).Value(IndexIso)->Polynom();
|
||||
}
|
||||
|
||||
|
@@ -44,27 +44,25 @@ public:
|
||||
Standard_EXPORT AdvApp2Var_Framework();
|
||||
|
||||
Standard_EXPORT AdvApp2Var_Framework(const AdvApp2Var_SequenceOfNode& Frame, const AdvApp2Var_SequenceOfStrip& UFrontier, const AdvApp2Var_SequenceOfStrip& VFrontier);
|
||||
|
||||
|
||||
//! search the Index of the first Iso not approximated,
|
||||
//! if all Isos are approximated Standard_False is returned.
|
||||
Standard_EXPORT Standard_Boolean FirstNotApprox (Standard_Integer& IndexIso, Standard_Integer& IndexStrip, AdvApp2Var_Iso& anIso) const;
|
||||
//! if all Isos are approximated NULL is returned.
|
||||
Standard_EXPORT Handle(AdvApp2Var_Iso) FirstNotApprox (Standard_Integer& IndexIso, Standard_Integer& IndexStrip) const;
|
||||
|
||||
Standard_EXPORT Standard_Integer FirstNode (const GeomAbs_IsoType Type, const Standard_Integer IndexIso, const Standard_Integer IndexStrip) const;
|
||||
|
||||
Standard_EXPORT Standard_Integer LastNode (const GeomAbs_IsoType Type, const Standard_Integer IndexIso, const Standard_Integer IndexStrip) const;
|
||||
|
||||
Standard_EXPORT void ChangeIso (const Standard_Integer IndexIso, const Standard_Integer IndexStrip, const AdvApp2Var_Iso& anIso);
|
||||
Standard_EXPORT void ChangeIso (const Standard_Integer IndexIso, const Standard_Integer IndexStrip, const Handle(AdvApp2Var_Iso)& anIso);
|
||||
|
||||
const AdvApp2Var_Node& Node (const Standard_Integer IndexNode) const;
|
||||
const Handle(AdvApp2Var_Node)& Node (const Standard_Integer IndexNode) const { return myNodeConstraints.Value(IndexNode); }
|
||||
|
||||
Standard_EXPORT const AdvApp2Var_Node& Node (const Standard_Real U, const Standard_Real V) const;
|
||||
Standard_EXPORT const Handle(AdvApp2Var_Node)& Node (const Standard_Real U, const Standard_Real V) const;
|
||||
|
||||
Standard_EXPORT const AdvApp2Var_Iso& IsoU (const Standard_Real U, const Standard_Real V0, const Standard_Real V1) const;
|
||||
|
||||
Standard_EXPORT const AdvApp2Var_Iso& IsoV (const Standard_Real U0, const Standard_Real U1, const Standard_Real V) const;
|
||||
|
||||
AdvApp2Var_Node& ChangeNode (const Standard_Integer IndexNode);
|
||||
|
||||
Standard_EXPORT void UpdateInU (const Standard_Real CuttingValue);
|
||||
|
||||
Standard_EXPORT void UpdateInV (const Standard_Real CuttingValue);
|
||||
@@ -73,31 +71,12 @@ public:
|
||||
|
||||
Standard_EXPORT const Handle(TColStd_HArray1OfReal)& VEquation (const Standard_Integer IndexIso, const Standard_Integer IndexStrip) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
AdvApp2Var_SequenceOfNode myNodeConstraints;
|
||||
AdvApp2Var_SequenceOfStrip myUConstraints;
|
||||
AdvApp2Var_SequenceOfStrip myVConstraints;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <AdvApp2Var_Framework.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _AdvApp2Var_Framework_HeaderFile
|
||||
|
@@ -14,16 +14,18 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <AdvApp2Var_Iso.hxx>
|
||||
|
||||
#include <AdvApp2Var_ApproxF2var.hxx>
|
||||
#include <AdvApp2Var_Context.hxx>
|
||||
#include <AdvApp2Var_Iso.hxx>
|
||||
#include <AdvApp2Var_Node.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TColStd_HArray1OfInteger.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <TColStd_HArray2OfReal.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AdvApp2Var_Iso, Standard_Transient)
|
||||
|
||||
//=======================================================================
|
||||
//function : AdvApp2Var_Iso
|
||||
//purpose :
|
||||
|
@@ -31,16 +31,12 @@
|
||||
class AdvApp2Var_Context;
|
||||
class AdvApp2Var_Node;
|
||||
|
||||
|
||||
|
||||
//! used to store constraints on a line U = Ui or V = Vj
|
||||
class AdvApp2Var_Iso
|
||||
class AdvApp2Var_Iso : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AdvApp2Var_Iso, Standard_Transient)
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
Standard_EXPORT AdvApp2Var_Iso();
|
||||
|
||||
Standard_EXPORT AdvApp2Var_Iso(const GeomAbs_IsoType type, const Standard_Integer iu, const Standard_Integer iv);
|
||||
@@ -99,20 +95,12 @@ public:
|
||||
|
||||
Standard_EXPORT Handle(TColStd_HArray2OfReal) MoyErrors() const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Standard_EXPORT AdvApp2Var_Iso(const AdvApp2Var_Iso& Other);
|
||||
AdvApp2Var_Iso(const AdvApp2Var_Iso& Other);
|
||||
AdvApp2Var_Iso& operator= (const AdvApp2Var_Iso& theOther);
|
||||
|
||||
private:
|
||||
|
||||
GeomAbs_IsoType myType;
|
||||
Standard_Real myConstPar;
|
||||
@@ -132,13 +120,6 @@ private:
|
||||
Handle(TColStd_HArray1OfReal) mySomTab;
|
||||
Handle(TColStd_HArray1OfReal) myDifTab;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _AdvApp2Var_Iso_HeaderFile
|
||||
|
@@ -52,15 +52,19 @@ AdvApp2Var_Network::AdvApp2Var_Network(const AdvApp2Var_SequenceOfPatch& Net,
|
||||
//purpose : return the first Patch not approximated
|
||||
//==========================================================================================
|
||||
|
||||
Standard_Boolean AdvApp2Var_Network::FirstNotApprox(Standard_Integer& Index) const
|
||||
Standard_Boolean AdvApp2Var_Network::FirstNotApprox(Standard_Integer& theIndex) const
|
||||
{
|
||||
Standard_Boolean good = Standard_True;
|
||||
Standard_Integer i;
|
||||
for (i = 1; i <= myNet.Length() && good; i++) {
|
||||
good = myNet.Value(i).IsApproximated();
|
||||
if (!good) {Index = i;}
|
||||
Standard_Integer anIndex = 1;
|
||||
for (AdvApp2Var_SequenceOfPatch::Iterator aPatchIter (myNet); aPatchIter.More(); aPatchIter.Next(), ++anIndex)
|
||||
{
|
||||
const Handle(AdvApp2Var_Patch)& aPatch = aPatchIter.Value();
|
||||
if (!aPatch->IsApproximated())
|
||||
{
|
||||
theIndex = anIndex;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return !good;
|
||||
return false;
|
||||
}
|
||||
|
||||
//==========================================================================================
|
||||
@@ -78,23 +82,20 @@ void AdvApp2Var_Network::UpdateInU(const Standard_Real CuttingValue)
|
||||
}
|
||||
myUParameters.InsertBefore(i,CuttingValue);
|
||||
|
||||
Standard_Integer indice;
|
||||
for (j=1; j< myVParameters.Length() ; j++){
|
||||
|
||||
for (j=1; j< myVParameters.Length() ; j++)
|
||||
{
|
||||
// modification des patches concernes par la decoupe
|
||||
AdvApp2Var_Patch Pat;
|
||||
indice = (myUParameters.Length()-1) * (j-1) + i - 1;
|
||||
Pat = myNet.Value(indice);
|
||||
Pat.ChangeDomain(Pat.U0(), CuttingValue, Pat.V0(), Pat.V1());
|
||||
Pat.ResetApprox();
|
||||
myNet.SetValue(indice, Pat);
|
||||
Standard_Integer indice = (myUParameters.Length()-1) * (j-1) + i - 1;
|
||||
const Handle(AdvApp2Var_Patch)& aPat = myNet.Value(indice);
|
||||
aPat->ChangeDomain (aPat->U0(), CuttingValue, aPat->V0(), aPat->V1());
|
||||
aPat->ResetApprox();
|
||||
|
||||
// insertion des nouveaux patches
|
||||
AdvApp2Var_Patch NewPat(CuttingValue,myUParameters.Value(i+1),
|
||||
Handle(AdvApp2Var_Patch) aNewPat = new AdvApp2Var_Patch (CuttingValue,myUParameters.Value(i+1),
|
||||
myVParameters.Value(j),myVParameters.Value(j+1),
|
||||
Pat.UOrder(),Pat.VOrder());
|
||||
NewPat.ResetApprox();
|
||||
myNet.InsertAfter(indice, NewPat);
|
||||
aPat->UOrder(), aPat->VOrder());
|
||||
aNewPat->ResetApprox();
|
||||
myNet.InsertAfter(indice, aNewPat);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -108,31 +109,32 @@ void AdvApp2Var_Network::UpdateInV(const Standard_Real CuttingValue)
|
||||
{
|
||||
|
||||
// insertion du nouveau parametre de decoupe
|
||||
Standard_Integer i,j=1;
|
||||
AdvApp2Var_Patch Pat;
|
||||
while (myVParameters.Value(j)<CuttingValue) {
|
||||
Standard_Integer j = 1;
|
||||
Handle(AdvApp2Var_Patch) Pat;
|
||||
while (myVParameters.Value(j)<CuttingValue)
|
||||
{
|
||||
j++;
|
||||
}
|
||||
myVParameters.InsertBefore(j,CuttingValue);
|
||||
|
||||
// modification des patches concernes par la decoupe
|
||||
Standard_Integer indice;
|
||||
for (i=1; i< myUParameters.Length() ; i++){
|
||||
indice = (myUParameters.Length()-1) * (j-2) + i;
|
||||
for (Standard_Integer i = 1; i < myUParameters.Length(); i++)
|
||||
{
|
||||
const Standard_Integer indice = (myUParameters.Length()-1) * (j-2) + i;
|
||||
Pat = myNet.Value(indice);
|
||||
Pat.ChangeDomain(Pat.U0(), Pat.U1(), Pat.V0(), CuttingValue);
|
||||
Pat.ResetApprox();
|
||||
myNet.SetValue(indice,Pat);
|
||||
Pat->ChangeDomain(Pat->U0(), Pat->U1(), Pat->V0(), CuttingValue);
|
||||
Pat->ResetApprox();
|
||||
}
|
||||
|
||||
// insertion des nouveaux patches
|
||||
for (i=1; i< myUParameters.Length() ; i++){
|
||||
indice = (myUParameters.Length()-1) * (j-1) + i-1;
|
||||
AdvApp2Var_Patch NewPat(myUParameters.Value(i), myUParameters.Value(i+1),
|
||||
for (Standard_Integer i = 1; i < myUParameters.Length(); i++)
|
||||
{
|
||||
const Standard_Integer indice = (myUParameters.Length()-1) * (j-1) + i-1;
|
||||
Handle(AdvApp2Var_Patch) aNewPat = new AdvApp2Var_Patch (myUParameters.Value(i), myUParameters.Value(i+1),
|
||||
CuttingValue,myVParameters.Value(j+1),
|
||||
Pat.UOrder(),Pat.VOrder());
|
||||
NewPat.ResetApprox();
|
||||
myNet.InsertAfter(indice,NewPat);
|
||||
Pat->UOrder(),Pat->VOrder());
|
||||
aNewPat->ResetApprox();
|
||||
myNet.InsertAfter (indice, aNewPat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,22 +148,21 @@ void AdvApp2Var_Network::SameDegree(const Standard_Integer iu,
|
||||
Standard_Integer& ncfu,
|
||||
Standard_Integer& ncfv)
|
||||
{
|
||||
|
||||
// calcul des coeff. max avec init selon l'ordre de continuite
|
||||
Standard_Integer IndPat;
|
||||
ncfu = 2*iu+2;
|
||||
ncfv = 2*iv+2;
|
||||
for (IndPat=1;IndPat<=myNet.Length();IndPat++) {
|
||||
ncfu = Max(ncfu,myNet.Value(IndPat).NbCoeffInU());
|
||||
ncfv = Max(ncfv,myNet.Value(IndPat).NbCoeffInV());
|
||||
for (AdvApp2Var_SequenceOfPatch::Iterator aPatIter (myNet); aPatIter.More(); aPatIter.Next())
|
||||
{
|
||||
const Handle(AdvApp2Var_Patch)& aPat = aPatIter.Value();
|
||||
ncfu = Max(ncfu, aPat->NbCoeffInU());
|
||||
ncfv = Max(ncfv, aPat->NbCoeffInV());
|
||||
}
|
||||
|
||||
// augmentation des nombres de coeff.
|
||||
AdvApp2Var_Patch Pat;
|
||||
for (IndPat=1;IndPat<=myNet.Length();IndPat++) {
|
||||
Pat = myNet.Value(IndPat);
|
||||
Pat.ChangeNbCoeff(ncfu,ncfv);
|
||||
myNet.SetValue(IndPat,Pat);
|
||||
for (AdvApp2Var_SequenceOfPatch::Iterator aPatIter (myNet); aPatIter.More(); aPatIter.Next())
|
||||
{
|
||||
const Handle(AdvApp2Var_Patch)& aPat = aPatIter.Value();
|
||||
aPat->ChangeNbCoeff (ncfu, ncfv);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -46,11 +46,8 @@ public:
|
||||
//! if all Patches are approximated Standard_False is returned
|
||||
Standard_EXPORT Standard_Boolean FirstNotApprox (Standard_Integer& Index) const;
|
||||
|
||||
AdvApp2Var_Patch& ChangePatch (const Standard_Integer Index);
|
||||
AdvApp2Var_Patch& operator() (const Standard_Integer Index)
|
||||
{
|
||||
return ChangePatch(Index);
|
||||
}
|
||||
AdvApp2Var_Patch& ChangePatch (const Standard_Integer Index) { return *myNet.Value(Index); }
|
||||
AdvApp2Var_Patch& operator() (const Standard_Integer Index) { return ChangePatch(Index); }
|
||||
|
||||
Standard_EXPORT void UpdateInU (const Standard_Real CuttingValue);
|
||||
|
||||
@@ -67,38 +64,23 @@ public:
|
||||
Standard_EXPORT Standard_Real UParameter (const Standard_Integer Index) const;
|
||||
|
||||
Standard_EXPORT Standard_Real VParameter (const Standard_Integer Index) const;
|
||||
|
||||
const AdvApp2Var_Patch& Patch (const Standard_Integer UIndex, const Standard_Integer VIndex) const;
|
||||
|
||||
const AdvApp2Var_Patch& Patch (const Standard_Integer UIndex, const Standard_Integer VIndex) const
|
||||
{
|
||||
return *myNet.Value ((VIndex-1)*(myUParameters.Length()-1) + UIndex);
|
||||
}
|
||||
|
||||
const AdvApp2Var_Patch& operator() (const Standard_Integer UIndex, const Standard_Integer VIndex) const
|
||||
{
|
||||
return Patch(UIndex,VIndex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
return Patch(UIndex,VIndex);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
AdvApp2Var_SequenceOfPatch myNet;
|
||||
TColStd_SequenceOfReal myUParameters;
|
||||
TColStd_SequenceOfReal myVParameters;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <AdvApp2Var_Network.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _AdvApp2Var_Network_HeaderFile
|
||||
|
@@ -14,26 +14,23 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <AdvApp2Var_Node.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_XY.hxx>
|
||||
#include <TColgp_HArray2OfPnt.hxx>
|
||||
#include <TColStd_HArray2OfReal.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AdvApp2Var_Node, Standard_Transient)
|
||||
|
||||
//=======================================================================
|
||||
//function : AdvApp2Var_Node
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AdvApp2Var_Node::AdvApp2Var_Node() :
|
||||
myOrdInU(2),
|
||||
myOrdInV(2)
|
||||
AdvApp2Var_Node::AdvApp2Var_Node()
|
||||
: myTruePoints(0, 2, 0, 2),
|
||||
myErrors (0, 2, 0, 2),
|
||||
myOrdInU (2),
|
||||
myOrdInV (2)
|
||||
{
|
||||
myTruePoints = new TColgp_HArray2OfPnt ( 0, 2, 0, 2);
|
||||
gp_Pnt P0(0.,0.,0.);
|
||||
myTruePoints->Init(P0);
|
||||
myErrors = new TColStd_HArray2OfReal( 0, 2, 0, 2);
|
||||
myErrors->Init(0.);
|
||||
myTruePoints.Init(P0);
|
||||
myErrors.Init(0.);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -42,15 +39,15 @@ myOrdInV(2)
|
||||
//=======================================================================
|
||||
|
||||
AdvApp2Var_Node::AdvApp2Var_Node(const Standard_Integer iu,
|
||||
const Standard_Integer iv) :
|
||||
myOrdInU(iu),
|
||||
myOrdInV(iv)
|
||||
const Standard_Integer iv)
|
||||
: myTruePoints(0, Max(0,iu), 0, Max(0,iv)),
|
||||
myErrors (0, Max(0,iu), 0, Max(0,iv)),
|
||||
myOrdInU (iu),
|
||||
myOrdInV (iv)
|
||||
{
|
||||
myTruePoints = new TColgp_HArray2OfPnt ( 0, Max(0,iu), 0, Max(0,iv));
|
||||
gp_Pnt P0(0.,0.,0.);
|
||||
myTruePoints->Init(P0);
|
||||
myErrors = new TColStd_HArray2OfReal( 0, Max(0,iu), 0, Max(0,iv));
|
||||
myErrors->Init(0.);
|
||||
myTruePoints.Init(P0);
|
||||
myErrors.Init(0.);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -60,118 +57,14 @@ myOrdInV(iv)
|
||||
|
||||
AdvApp2Var_Node::AdvApp2Var_Node(const gp_XY& UV,
|
||||
const Standard_Integer iu,
|
||||
const Standard_Integer iv) :
|
||||
myCoord(UV),
|
||||
myOrdInU(iu),
|
||||
myOrdInV(iv)
|
||||
const Standard_Integer iv)
|
||||
: myTruePoints(0, iu, 0, iv),
|
||||
myErrors (0, iu, 0, iv),
|
||||
myCoord (UV),
|
||||
myOrdInU(iu),
|
||||
myOrdInV(iv)
|
||||
{
|
||||
myTruePoints = new TColgp_HArray2OfPnt ( 0, iu, 0, iv);
|
||||
gp_Pnt P0(0.,0.,0.);
|
||||
myTruePoints->Init(P0);
|
||||
myErrors = new TColStd_HArray2OfReal( 0, iu, 0, iv);
|
||||
myErrors->Init(0.);
|
||||
myTruePoints.Init(P0);
|
||||
myErrors.Init(0.);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Coord
|
||||
//purpose : returns the coordinates (U,V) of the node
|
||||
//=======================================================================
|
||||
|
||||
gp_XY AdvApp2Var_Node::Coord() const
|
||||
{
|
||||
return myCoord;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetCoord
|
||||
//purpose : changes the coordinates (U,V) to (x1,x2)
|
||||
//=======================================================================
|
||||
|
||||
void AdvApp2Var_Node::SetCoord(const Standard_Real x1,
|
||||
const Standard_Real x2)
|
||||
{
|
||||
myCoord.SetX(x1);
|
||||
myCoord.SetY(x2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UOrder
|
||||
//purpose : returns the continuity order in U of the node
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer AdvApp2Var_Node::UOrder() const
|
||||
{
|
||||
return myOrdInU;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VOrder
|
||||
//purpose : returns the continuity order in V of the node
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer AdvApp2Var_Node::VOrder() const
|
||||
{
|
||||
return myOrdInV;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetPoint
|
||||
//purpose : affects the value F(U,V) or its derivates on the node (U,V)
|
||||
//=======================================================================
|
||||
|
||||
void AdvApp2Var_Node::SetPoint(const Standard_Integer iu,
|
||||
const Standard_Integer iv,
|
||||
const gp_Pnt& Pt)
|
||||
{
|
||||
myTruePoints->SetValue(iu, iv, Pt);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Point
|
||||
//purpose : returns the value F(U,V) or its derivates on the node (U,V)
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt AdvApp2Var_Node::Point(const Standard_Integer iu,
|
||||
const Standard_Integer iv) const
|
||||
{
|
||||
return myTruePoints->Value(iu, iv);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetError
|
||||
//purpose : affects the error between F(U,V) and its approximation
|
||||
//=======================================================================
|
||||
|
||||
void AdvApp2Var_Node::SetError(const Standard_Integer iu,
|
||||
const Standard_Integer iv,
|
||||
const Standard_Real error)
|
||||
{
|
||||
myErrors->SetValue(iu, iv, error);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Error
|
||||
//purpose : returns the error between F(U,V) and its approximation
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real AdvApp2Var_Node::Error(const Standard_Integer iu,
|
||||
const Standard_Integer iv) const
|
||||
{
|
||||
return myErrors->Value(iu, iv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -17,78 +17,85 @@
|
||||
#ifndef _AdvApp2Var_Node_HeaderFile
|
||||
#define _AdvApp2Var_Node_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <gp_XY.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <TColgp_HArray2OfPnt.hxx>
|
||||
#include <TColStd_HArray2OfReal.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
class gp_XY;
|
||||
class gp_Pnt;
|
||||
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TColgp_Array2OfPnt.hxx>
|
||||
#include <TColStd_Array2OfReal.hxx>
|
||||
|
||||
//! used to store constraints on a (Ui,Vj) point
|
||||
class AdvApp2Var_Node
|
||||
class AdvApp2Var_Node : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AdvApp2Var_Node, Standard_Transient)
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
Standard_EXPORT AdvApp2Var_Node();
|
||||
|
||||
Standard_EXPORT AdvApp2Var_Node(const Standard_Integer iu, const Standard_Integer iv);
|
||||
|
||||
Standard_EXPORT AdvApp2Var_Node(const gp_XY& UV, const Standard_Integer iu, const Standard_Integer iv);
|
||||
|
||||
Standard_EXPORT gp_XY Coord() const;
|
||||
|
||||
Standard_EXPORT void SetCoord (const Standard_Real x1, const Standard_Real x2);
|
||||
|
||||
Standard_EXPORT Standard_Integer UOrder() const;
|
||||
|
||||
Standard_EXPORT Standard_Integer VOrder() const;
|
||||
|
||||
Standard_EXPORT void SetPoint (const Standard_Integer iu, const Standard_Integer iv, const gp_Pnt& Cte);
|
||||
|
||||
Standard_EXPORT gp_Pnt Point (const Standard_Integer iu, const Standard_Integer iv) const;
|
||||
|
||||
Standard_EXPORT void SetError (const Standard_Integer iu, const Standard_Integer iv, const Standard_Real error);
|
||||
|
||||
Standard_EXPORT Standard_Real Error (const Standard_Integer iu, const Standard_Integer iv) const;
|
||||
|
||||
//! Returns the coordinates (U,V) of the node
|
||||
const gp_XY& Coord() const { return myCoord; }
|
||||
|
||||
//! changes the coordinates (U,V) to (x1,x2)
|
||||
void SetCoord (const Standard_Real x1, const Standard_Real x2)
|
||||
{
|
||||
myCoord.SetX(x1);
|
||||
myCoord.SetY(x2);
|
||||
}
|
||||
|
||||
//! returns the continuity order in U of the node
|
||||
Standard_Integer UOrder() const { return myOrdInU; }
|
||||
|
||||
protected:
|
||||
//! returns the continuity order in V of the node
|
||||
Standard_Integer VOrder() const { return myOrdInV; }
|
||||
|
||||
//! affects the value F(U,V) or its derivates on the node (U,V)
|
||||
void SetPoint (const Standard_Integer iu, const Standard_Integer iv, const gp_Pnt& Pt)
|
||||
{
|
||||
myTruePoints.SetValue(iu, iv, Pt);
|
||||
}
|
||||
|
||||
//! returns the value F(U,V) or its derivates on the node (U,V)
|
||||
const gp_Pnt& Point (const Standard_Integer iu, const Standard_Integer iv) const
|
||||
{
|
||||
return myTruePoints.Value(iu, iv);
|
||||
}
|
||||
|
||||
//! affects the error between F(U,V) and its approximation
|
||||
void SetError (const Standard_Integer iu, const Standard_Integer iv, const Standard_Real error)
|
||||
{
|
||||
myErrors.SetValue(iu, iv, error);
|
||||
}
|
||||
|
||||
//! returns the error between F(U,V) and its approximation
|
||||
Standard_Real Error (const Standard_Integer iu, const Standard_Integer iv) const { return myErrors.Value(iu, iv); }
|
||||
|
||||
//! Assign operator.
|
||||
AdvApp2Var_Node& operator= (const AdvApp2Var_Node& theOther)
|
||||
{
|
||||
myTruePoints = theOther.myTruePoints;
|
||||
myErrors = theOther.myErrors;
|
||||
myCoord = theOther.myCoord;
|
||||
myOrdInU = theOther.myOrdInU;
|
||||
myOrdInV = theOther.myOrdInV;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Standard_EXPORT AdvApp2Var_Node(const AdvApp2Var_Node& Other);
|
||||
AdvApp2Var_Node (const AdvApp2Var_Node& theOther);
|
||||
|
||||
private:
|
||||
|
||||
TColgp_Array2OfPnt myTruePoints;
|
||||
TColStd_Array2OfReal myErrors;
|
||||
gp_XY myCoord;
|
||||
Standard_Integer myOrdInU;
|
||||
Standard_Integer myOrdInV;
|
||||
Handle(TColgp_HArray2OfPnt) myTruePoints;
|
||||
Handle(TColStd_HArray2OfReal) myErrors;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _AdvApp2Var_Node_HeaderFile
|
||||
|
@@ -40,6 +40,8 @@
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <TColStd_HArray2OfReal.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AdvApp2Var_Patch, Standard_Transient)
|
||||
|
||||
//============================================================================
|
||||
//function : AdvApp2Var_Patch
|
||||
//purpose :
|
||||
@@ -144,35 +146,35 @@ void AdvApp2Var_Patch::Discretise(const AdvApp2Var_Context& Conditions,
|
||||
rho = pow(du,iu)*pow(dv,iv);
|
||||
|
||||
// F(U0,V0) and its derivatives normalized on (-1,1)
|
||||
valnorm = rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).X();
|
||||
valnorm = rho * ((Constraints.Node(myU0,myV0))->Point(iu,iv)).X();
|
||||
HCOINS->SetValue( 1+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv , valnorm );
|
||||
valnorm = rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).Y();
|
||||
valnorm = rho * ((Constraints.Node(myU0,myV0))->Point(iu,iv)).Y();
|
||||
HCOINS->SetValue( 2+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
|
||||
valnorm = rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).Z();
|
||||
valnorm = rho * ((Constraints.Node(myU0,myV0))->Point(iu,iv)).Z();
|
||||
HCOINS->SetValue( 3+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
|
||||
|
||||
// F(U1,V0) and its derivatives normalized on (-1,1)
|
||||
valnorm = rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).X();
|
||||
valnorm = rho * ((Constraints.Node(myU1,myV0))->Point(iu,iv)).X();
|
||||
HCOINS->SetValue( SIZE+1+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
|
||||
valnorm = rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).Y();
|
||||
valnorm = rho * ((Constraints.Node(myU1,myV0))->Point(iu,iv)).Y();
|
||||
HCOINS->SetValue( SIZE+2+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
|
||||
valnorm = rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).Z();
|
||||
valnorm = rho * ((Constraints.Node(myU1,myV0))->Point(iu,iv)).Z();
|
||||
HCOINS->SetValue( SIZE+3+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
|
||||
|
||||
// F(U0,V1) and its derivatives normalized on (-1,1)
|
||||
valnorm = rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).X();
|
||||
valnorm = rho * ((Constraints.Node(myU0,myV1))->Point(iu,iv)).X();
|
||||
HCOINS->SetValue( 2*SIZE+1+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
|
||||
valnorm = rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).Y();
|
||||
valnorm = rho * ((Constraints.Node(myU0,myV1))->Point(iu,iv)).Y();
|
||||
HCOINS->SetValue( 2*SIZE+2+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
|
||||
valnorm = rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).Z();
|
||||
valnorm = rho * ((Constraints.Node(myU0,myV1))->Point(iu,iv)).Z();
|
||||
HCOINS->SetValue( 2*SIZE+3+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
|
||||
|
||||
// F(U1,V1) and its derivatives normalized on (-1,1)
|
||||
valnorm = rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).X();
|
||||
valnorm = rho * ((Constraints.Node(myU1,myV1))->Point(iu,iv)).X();
|
||||
HCOINS->SetValue( 3*SIZE+1+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
|
||||
valnorm = rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).Y();
|
||||
valnorm = rho * ((Constraints.Node(myU1,myV1))->Point(iu,iv)).Y();
|
||||
HCOINS->SetValue( 3*SIZE+2+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
|
||||
valnorm = rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).Z();
|
||||
valnorm = rho * ((Constraints.Node(myU1,myV1))->Point(iu,iv)).Z();
|
||||
HCOINS->SetValue( 3*SIZE+3+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
|
||||
}
|
||||
}
|
||||
@@ -543,38 +545,38 @@ void AdvApp2Var_Patch::AddConstraints(const AdvApp2Var_Context& Conditions,
|
||||
|
||||
// -F(U0,V0) and its derivatives normalized on (-1,1)
|
||||
ideb = HCOINS->Lower() + NDIMEN*iu+NDIMEN*(IORDRU+2)*iv - 1;
|
||||
valnorm = -rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).X();
|
||||
valnorm = -rho * ((Constraints.Node(myU0,myV0))->Point(iu,iv)).X();
|
||||
HCOINS->SetValue( 1+ideb , valnorm );
|
||||
valnorm = -rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).Y();
|
||||
valnorm = -rho * ((Constraints.Node(myU0,myV0))->Point(iu,iv)).Y();
|
||||
HCOINS->SetValue( 2+ideb , valnorm );
|
||||
valnorm = -rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).Z();
|
||||
valnorm = -rho * ((Constraints.Node(myU0,myV0))->Point(iu,iv)).Z();
|
||||
HCOINS->SetValue( 3+ideb , valnorm );
|
||||
|
||||
// -F(U1,V0) and its derivatives normalized on (-1,1)
|
||||
ideb += SIZE;
|
||||
valnorm = -rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).X();
|
||||
valnorm = -rho * ((Constraints.Node(myU1,myV0))->Point(iu,iv)).X();
|
||||
HCOINS->SetValue( 1+ideb , valnorm );
|
||||
valnorm = -rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).Y();
|
||||
valnorm = -rho * ((Constraints.Node(myU1,myV0))->Point(iu,iv)).Y();
|
||||
HCOINS->SetValue( 2+ideb , valnorm );
|
||||
valnorm = -rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).Z();
|
||||
valnorm = -rho * ((Constraints.Node(myU1,myV0))->Point(iu,iv)).Z();
|
||||
HCOINS->SetValue( 3+ideb , valnorm );
|
||||
|
||||
// -F(U0,V1) and its derivatives normalized on (-1,1)
|
||||
ideb += SIZE;
|
||||
valnorm = -rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).X();
|
||||
valnorm = -rho * ((Constraints.Node(myU0,myV1))->Point(iu,iv)).X();
|
||||
HCOINS->SetValue( 1+ideb , valnorm );
|
||||
valnorm = -rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).Y();
|
||||
valnorm = -rho * ((Constraints.Node(myU0,myV1))->Point(iu,iv)).Y();
|
||||
HCOINS->SetValue( 2+ideb , valnorm );
|
||||
valnorm = -rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).Z();
|
||||
valnorm = -rho * ((Constraints.Node(myU0,myV1))->Point(iu,iv)).Z();
|
||||
HCOINS->SetValue( 3+ideb , valnorm );
|
||||
|
||||
// -F(U1,V1) and its derivatives normalized on (-1,1)
|
||||
ideb += SIZE;
|
||||
valnorm = -rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).X();
|
||||
valnorm = -rho * ((Constraints.Node(myU1,myV1))->Point(iu,iv)).X();
|
||||
HCOINS->SetValue( 1+ideb , valnorm );
|
||||
valnorm = -rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).Y();
|
||||
valnorm = -rho * ((Constraints.Node(myU1,myV1))->Point(iu,iv)).Y();
|
||||
HCOINS->SetValue( 2+ideb , valnorm );
|
||||
valnorm = -rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).Z();
|
||||
valnorm = -rho * ((Constraints.Node(myU1,myV1))->Point(iu,iv)).Z();
|
||||
HCOINS->SetValue( 3+ideb , valnorm );
|
||||
}
|
||||
}
|
||||
@@ -721,13 +723,13 @@ void AdvApp2Var_Patch::AddErrors(const AdvApp2Var_Framework& Constraints)
|
||||
Standard_Real emax1=0.,emax2=0.,emax3=0.,emax4=0.,err1,err2,err3,err4;
|
||||
for (iu=0;iu<=myOrdInU;iu++) {
|
||||
for (iv=0;iv<=myOrdInV;iv++) {
|
||||
error = (Constraints.Node(myU0,myV0)).Error(iu,iv);
|
||||
error = (Constraints.Node(myU0,myV0))->Error(iu,iv);
|
||||
emax1 = Max(emax1,error);
|
||||
error = (Constraints.Node(myU1,myV0)).Error(iu,iv);
|
||||
error = (Constraints.Node(myU1,myV0))->Error(iu,iv);
|
||||
emax2 = Max(emax2,error);
|
||||
error = (Constraints.Node(myU0,myV1)).Error(iu,iv);
|
||||
error = (Constraints.Node(myU0,myV1))->Error(iu,iv);
|
||||
emax3 = Max(emax3,error);
|
||||
error = (Constraints.Node(myU1,myV1)).Error(iu,iv);
|
||||
error = (Constraints.Node(myU1,myV1))->Error(iu,iv);
|
||||
emax4 = Max(emax4,error);
|
||||
}
|
||||
}
|
||||
|
@@ -35,12 +35,10 @@ class AdvApp2Var_Criterion;
|
||||
|
||||
|
||||
//! used to store results on a domain [Ui,Ui+1]x[Vj,Vj+1]
|
||||
class AdvApp2Var_Patch
|
||||
class AdvApp2Var_Patch : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AdvApp2Var_Patch, Standard_Transient)
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
Standard_EXPORT AdvApp2Var_Patch();
|
||||
|
||||
@@ -102,20 +100,12 @@ public:
|
||||
|
||||
Standard_EXPORT void SetCritValue (const Standard_Real dist);
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Standard_EXPORT AdvApp2Var_Patch(const AdvApp2Var_Patch& P);
|
||||
AdvApp2Var_Patch(const AdvApp2Var_Patch& P);
|
||||
AdvApp2Var_Patch& operator= (const AdvApp2Var_Patch& theOther);
|
||||
|
||||
private:
|
||||
|
||||
Standard_Real myU0;
|
||||
Standard_Real myU1;
|
||||
|
@@ -20,7 +20,6 @@
|
||||
#include <AdvApp2Var_Node.hxx>
|
||||
#include <NCollection_Sequence.hxx>
|
||||
|
||||
typedef NCollection_Sequence<AdvApp2Var_Node> AdvApp2Var_SequenceOfNode;
|
||||
|
||||
typedef NCollection_Sequence<Handle(AdvApp2Var_Node)> AdvApp2Var_SequenceOfNode;
|
||||
|
||||
#endif
|
||||
|
@@ -20,7 +20,7 @@
|
||||
#include <AdvApp2Var_Patch.hxx>
|
||||
#include <NCollection_Sequence.hxx>
|
||||
|
||||
typedef NCollection_Sequence<AdvApp2Var_Patch> AdvApp2Var_SequenceOfPatch;
|
||||
typedef NCollection_Sequence<Handle(AdvApp2Var_Patch)> AdvApp2Var_SequenceOfPatch;
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -22,6 +22,6 @@
|
||||
|
||||
//! Set of constraints along a same type of Iso on the same level
|
||||
|
||||
typedef NCollection_Sequence<AdvApp2Var_Iso> AdvApp2Var_Strip;
|
||||
typedef NCollection_Sequence<Handle(AdvApp2Var_Iso)> AdvApp2Var_Strip;
|
||||
|
||||
#endif
|
||||
|
@@ -22,7 +22,6 @@ AdvApp2Var_Data_f2c.hxx
|
||||
AdvApp2Var_EvaluatorFunc2Var.hxx
|
||||
AdvApp2Var_Framework.cxx
|
||||
AdvApp2Var_Framework.hxx
|
||||
AdvApp2Var_Framework.lxx
|
||||
AdvApp2Var_Iso.cxx
|
||||
AdvApp2Var_Iso.hxx
|
||||
AdvApp2Var_MathBase.cxx
|
||||
@@ -30,7 +29,6 @@ AdvApp2Var_MathBase.hxx
|
||||
AdvApp2Var_MathBase_mathinit.cxx
|
||||
AdvApp2Var_Network.cxx
|
||||
AdvApp2Var_Network.hxx
|
||||
AdvApp2Var_Network.lxx
|
||||
AdvApp2Var_Node.cxx
|
||||
AdvApp2Var_Node.hxx
|
||||
AdvApp2Var_Patch.cxx
|
||||
|
@@ -54,6 +54,7 @@ const AppParCurves_Constraint LastC)
|
||||
mylastC = LastC;
|
||||
myMaxSegments = MAXSEGM;
|
||||
myInvOrder = Standard_True;
|
||||
myHangChecking = Standard_True;
|
||||
alldone = Standard_False;
|
||||
Perform(Line);
|
||||
}
|
||||
@@ -82,6 +83,7 @@ const AppParCurves_Constraint LastC)
|
||||
mylastC = LastC;
|
||||
myMaxSegments = MAXSEGM;
|
||||
myInvOrder = Standard_True;
|
||||
myHangChecking = Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -97,7 +99,15 @@ void Approx_ComputeCLine::Perform(const MultiLine& Line)
|
||||
Standard_Real thetol3d = Precision::Confusion(), thetol2d = Precision::Confusion();
|
||||
UFirst = Line.FirstParameter();
|
||||
ULast = Line.LastParameter();
|
||||
Standard_Real TolU = Max((ULast - UFirst)*1.e-03, Precision::Confusion());
|
||||
Standard_Real TolU = 0.;
|
||||
if (myHangChecking)
|
||||
{
|
||||
TolU = Max((ULast - UFirst)*1.e-03, Precision::Confusion());
|
||||
}
|
||||
else
|
||||
{
|
||||
TolU = Max((ULast - UFirst)*1.e-05, Precision::PApproximation());
|
||||
}
|
||||
Standard_Real myfirstU = UFirst;
|
||||
Standard_Real mylastU = ULast;
|
||||
Standard_Integer aMaxSegments = 0;
|
||||
@@ -176,7 +186,7 @@ void Approx_ComputeCLine::Perform(const MultiLine& Line)
|
||||
|
||||
//cout << myfirstU << " - " << mylastU << " tol : " << thetol3d << " " << thetol2d << endl;
|
||||
Standard_Boolean aStopCutting = Standard_False;
|
||||
if (aNbCut >= aNbComp)
|
||||
if (myHangChecking && aNbCut >= aNbComp)
|
||||
{
|
||||
if (aNbCut > aNbImp + 1)
|
||||
{
|
||||
@@ -434,6 +444,15 @@ void Approx_ComputeCLine::SetInvOrder(const Standard_Boolean theInvOrder)
|
||||
myInvOrder = theInvOrder;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetHangChecking
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Approx_ComputeCLine::SetHangChecking(const Standard_Boolean theHangChecking)
|
||||
{
|
||||
myHangChecking = theHangChecking;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsAllApproximated
|
||||
//purpose : returns False if at a moment of the approximation,
|
||||
|
@@ -70,6 +70,12 @@ public:
|
||||
//! By default inverse order is used.
|
||||
Standard_EXPORT void SetInvOrder(const Standard_Boolean theInvOrder);
|
||||
|
||||
//! Set value of hang checking flag
|
||||
//! if this flag = true, possible hang of algorithm is checked
|
||||
//! and algorithm is forced to stop.
|
||||
//! By default hang checking is used.
|
||||
Standard_EXPORT void SetHangChecking(const Standard_Boolean theHangChecking);
|
||||
|
||||
//! returns False if at a moment of the approximation,
|
||||
//! the status NoApproximation has been sent by the user
|
||||
//! when more points were needed.
|
||||
@@ -125,6 +131,7 @@ private:
|
||||
AppParCurves_Constraint mylastC;
|
||||
Standard_Integer myMaxSegments;
|
||||
Standard_Boolean myInvOrder;
|
||||
Standard_Boolean myHangChecking;
|
||||
|
||||
|
||||
};
|
||||
|
@@ -70,6 +70,12 @@ public:
|
||||
//! By default inverse order is used.
|
||||
Standard_EXPORT void SetInvOrder(const Standard_Boolean theInvOrder);
|
||||
|
||||
//! Set value of hang checking flag
|
||||
//! if this flag = true, possible hang of algorithm is checked
|
||||
//! and algorithm is forced to stop.
|
||||
//! By default hang checking is used.
|
||||
Standard_EXPORT void SetHangChecking(const Standard_Boolean theHangChecking);
|
||||
|
||||
//! returns False if at a moment of the approximation,
|
||||
//! the status NoApproximation has been sent by the user
|
||||
//! when more points were needed.
|
||||
@@ -125,6 +131,7 @@ private:
|
||||
AppParCurves_Constraint mylastC;
|
||||
Standard_Integer myMaxSegments;
|
||||
Standard_Boolean myInvOrder;
|
||||
Standard_Boolean myHangChecking;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
// Copyright (c) 1998-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
@@ -12,23 +11,16 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
inline TCollection_AsciiString Storage_BaseDriver::Name() const
|
||||
{
|
||||
return myName;
|
||||
}
|
||||
#ifndef _Aspect_ColorSpace_HeaderFile
|
||||
#define _Aspect_ColorSpace_HeaderFile
|
||||
|
||||
inline Storage_OpenMode Storage_BaseDriver::OpenMode() const
|
||||
{
|
||||
return myOpenMode;
|
||||
}
|
||||
#include <Aspect_GraphicsLibrary.hxx>
|
||||
|
||||
inline void Storage_BaseDriver::SetName(const TCollection_AsciiString& aName)
|
||||
//! Texture color spaces accepted by XR composer.
|
||||
enum Aspect_ColorSpace
|
||||
{
|
||||
myName = aName;
|
||||
}
|
||||
|
||||
inline void Storage_BaseDriver::SetOpenMode(const Storage_OpenMode aMode)
|
||||
{
|
||||
myOpenMode = aMode;
|
||||
}
|
||||
Aspect_ColorSpace_sRGB = 0, //!< non-linear sRGB color space
|
||||
Aspect_ColorSpace_Linear = 1, //!< linear RGB color space
|
||||
};
|
||||
|
||||
#endif // _Aspect_ColorSpace_HeaderFile
|
@@ -1,7 +1,4 @@
|
||||
// Created on: 1991-02-26
|
||||
// Created by: Isabelle GRIGNON
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
@@ -14,14 +11,14 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Extrema_ExtAlgo_HeaderFile
|
||||
#define _Extrema_ExtAlgo_HeaderFile
|
||||
#ifndef _Aspect_Eye_HeaderFile
|
||||
#define _Aspect_Eye_HeaderFile
|
||||
|
||||
|
||||
enum Extrema_ExtAlgo
|
||||
//! Camera eye index within stereoscopic pair.
|
||||
enum Aspect_Eye
|
||||
{
|
||||
Extrema_ExtAlgo_Grad,
|
||||
Extrema_ExtAlgo_Tree
|
||||
Aspect_Eye_Left,
|
||||
Aspect_Eye_Right
|
||||
};
|
||||
|
||||
#endif // _Extrema_ExtAlgo_HeaderFile
|
||||
#endif // _Aspect_Eye_HeaderFile
|
55
src/Aspect/Aspect_FrustumLRBT.hxx
Normal file
55
src/Aspect/Aspect_FrustumLRBT.hxx
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright (c) 2020 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 _Aspect_FrustumLRBT_HeaderFile
|
||||
#define _Aspect_FrustumLRBT_HeaderFile
|
||||
|
||||
//! Structure defining frustum boundaries.
|
||||
template<typename Elem_t>
|
||||
struct Aspect_FrustumLRBT
|
||||
{
|
||||
Elem_t Left;
|
||||
Elem_t Right;
|
||||
Elem_t Bottom;
|
||||
Elem_t Top;
|
||||
|
||||
//! Empty constructor.
|
||||
Aspect_FrustumLRBT() : Left (0), Right (0), Bottom (0), Top (0) {}
|
||||
|
||||
//! Copy/cast constructor.
|
||||
template<typename Other_t>
|
||||
explicit Aspect_FrustumLRBT (const Aspect_FrustumLRBT<Other_t>& theOther)
|
||||
: Left (static_cast<Elem_t> (theOther.Left)),
|
||||
Right (static_cast<Elem_t> (theOther.Right)),
|
||||
Bottom(static_cast<Elem_t> (theOther.Bottom)),
|
||||
Top (static_cast<Elem_t> (theOther.Top)) {}
|
||||
|
||||
//! Apply multiply factor.
|
||||
void Multiply (Elem_t theScale)
|
||||
{
|
||||
Left *= theScale;
|
||||
Right *= theScale;
|
||||
Bottom *= theScale;
|
||||
Top *= theScale;
|
||||
}
|
||||
|
||||
//! Return multiplied frustum.
|
||||
Aspect_FrustumLRBT<Elem_t> Multiplied (Elem_t theScale)
|
||||
{
|
||||
Aspect_FrustumLRBT<Elem_t> aCopy (*this);
|
||||
aCopy.Multiply (theScale);
|
||||
return aCopy;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _Aspect_FrustumLRBT_HeaderFile
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user