mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0024337: Draw Harness - relax vinit syntax
Support "vinit name w=512 h=512" syntax
This commit is contained in:
parent
23b894f730
commit
e79a94b9a5
@ -635,16 +635,17 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
|
|||||||
if (ViewerTest::GetAISContext().IsNull() ||
|
if (ViewerTest::GetAISContext().IsNull() ||
|
||||||
!(ViewerTest_myContexts.IsBound1(aViewNames.GetViewerName())))
|
!(ViewerTest_myContexts.IsBound1(aViewNames.GetViewerName())))
|
||||||
{
|
{
|
||||||
Handle(AIS_InteractiveContext) aContext =
|
Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext (a3DViewer);
|
||||||
new AIS_InteractiveContext(a3DViewer);
|
|
||||||
ViewerTest::SetAISContext (aContext);
|
ViewerTest::SetAISContext (aContext);
|
||||||
ViewerTest_myContexts.Bind (aViewNames.GetViewerName(), ViewerTest::GetAISContext());
|
ViewerTest_myContexts.Bind (aViewNames.GetViewerName(), ViewerTest::GetAISContext());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ViewerTest::ResetEventManager();
|
ViewerTest::ResetEventManager();
|
||||||
|
}
|
||||||
|
|
||||||
// Create window
|
// Create window
|
||||||
#if defined(_WIN32) || defined(__WIN32__)
|
#if defined(_WIN32)
|
||||||
VT_GetWindow() = new WNT_Window (aTitle.ToCString(),
|
VT_GetWindow() = new WNT_Window (aTitle.ToCString(),
|
||||||
Handle(WNT_WClass)::DownCast (WClass()),
|
Handle(WNT_WClass)::DownCast (WClass()),
|
||||||
Draw_VirtualWindows ? WS_POPUPWINDOW : WS_OVERLAPPEDWINDOW,
|
Draw_VirtualWindows ? WS_POPUPWINDOW : WS_OVERLAPPEDWINDOW,
|
||||||
@ -688,7 +689,7 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
|
|||||||
a3DViewer->SetLightOn();
|
a3DViewer->SetLightOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
||||||
#if TCL_MAJOR_VERSION < 8
|
#if TCL_MAJOR_VERSION < 8
|
||||||
Tk_CreateFileHandler((void*)XConnectionNumber(GetDisplayConnection()->GetDisplay()),
|
Tk_CreateFileHandler((void*)XConnectionNumber(GetDisplayConnection()->GetDisplay()),
|
||||||
TK_READABLE, VProcessEvents, (ClientData) VT_GetWindow()->XWindow() );
|
TK_READABLE, VProcessEvents, (ClientData) VT_GetWindow()->XWindow() );
|
||||||
@ -749,70 +750,87 @@ Standard_Boolean splitParameter (const TCollection_AsciiString& theString,
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
//function : Vinit
|
//function : Vinit
|
||||||
//purpose : Create the window viewer and initialize all the global variable
|
//purpose : Create the window viewer and initialize all the global variable
|
||||||
// Use Tk_CreateFileHandler on UNIX to cath the X11 Viewer event
|
// Use Tk_CreateFileHandler on UNIX to catch the X11 Viewer event
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
|
static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
|
||||||
{
|
{
|
||||||
if (theArgsNb > 9)
|
if (theArgsNb > 9)
|
||||||
{
|
{
|
||||||
theDi << theArgVec[0] << ": incorrect number of command arguments.\n"
|
std::cerr << theArgVec[0] << ": incorrect number of command arguments.\n"
|
||||||
<< "Type help for more information.\n";
|
<< "Type help for more information.\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
TCollection_AsciiString aViewName (""),
|
|
||||||
aDisplayName ("");
|
|
||||||
Standard_Integer aPxLeft = 0,
|
|
||||||
aPxTop = 0,
|
|
||||||
aPxWidth = 0,
|
|
||||||
aPxHeight = 0;
|
|
||||||
|
|
||||||
for (Standard_Integer i = 1; i < theArgsNb; ++i)
|
TCollection_AsciiString aViewName, aDisplayName;
|
||||||
|
Standard_Integer aPxLeft = 0, aPxTop = 0, aPxWidth = 0, aPxHeight = 0;
|
||||||
|
TCollection_AsciiString aName, aValue;
|
||||||
|
for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
|
||||||
{
|
{
|
||||||
TCollection_AsciiString aName = "", aValue = "";
|
const TCollection_AsciiString anArg = theArgVec[anArgIt];
|
||||||
if(!splitParameter (TCollection_AsciiString(theArgVec[i]),aName,aValue) && theArgsNb == 2)
|
TCollection_AsciiString anArgCase = anArg;
|
||||||
|
anArgCase.UpperCase();
|
||||||
|
if (splitParameter (anArg, aName, aValue))
|
||||||
{
|
{
|
||||||
// In case of syntax: vinit ViewName
|
aName.UpperCase();
|
||||||
aViewName = theArgVec[1];
|
if (aName.IsEqual ("NAME"))
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (aName == "name")
|
|
||||||
{
|
{
|
||||||
aViewName = aValue;
|
aViewName = aValue;
|
||||||
}
|
}
|
||||||
else if (aName == "l" || aName == "left")
|
else if (aName.IsEqual ("L")
|
||||||
|
|| aName.IsEqual ("LEFT"))
|
||||||
|
{
|
||||||
aPxLeft = aValue.IntegerValue();
|
aPxLeft = aValue.IntegerValue();
|
||||||
else if (aName == "t" || aName == "top")
|
}
|
||||||
|
else if (aName.IsEqual ("T")
|
||||||
|
|| aName.IsEqual ("TOP"))
|
||||||
|
{
|
||||||
aPxTop = aValue.IntegerValue();
|
aPxTop = aValue.IntegerValue();
|
||||||
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
}
|
||||||
else if (aName == "display")
|
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
||||||
|
else if (aName.IsEqual ("DISP")
|
||||||
|
|| aName.IsEqual ("DISPLAY"))
|
||||||
|
{
|
||||||
aDisplayName = aValue;
|
aDisplayName = aValue;
|
||||||
#endif
|
}
|
||||||
else if (aName == "w" || aName == "width")
|
#endif
|
||||||
|
else if (aName.IsEqual ("W")
|
||||||
|
|| aName.IsEqual ("WIDTH"))
|
||||||
|
{
|
||||||
aPxWidth = aValue.IntegerValue();
|
aPxWidth = aValue.IntegerValue();
|
||||||
else if (aName == "h" || aName == "height")
|
}
|
||||||
|
else if (aName.IsEqual ("H")
|
||||||
|
|| aName.IsEqual ("HEIGHT"))
|
||||||
|
{
|
||||||
aPxHeight = aValue.IntegerValue();
|
aPxHeight = aValue.IntegerValue();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
theDi << theArgVec[0] << ": Warning: unknown parameter " << aName.ToCString() << ".\n";
|
std::cerr << theArgVec[0] << ": Warning: unknown argument " << anArg << ".\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (aViewName.IsEmpty())
|
||||||
|
{
|
||||||
|
aViewName = anArg;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << theArgVec[0] << ": Warning: unknown argument " << anArg << ".\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewerTest_Names aViewNames (aViewName);
|
ViewerTest_Names aViewNames (aViewName);
|
||||||
if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName ()))
|
if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName()))
|
||||||
{
|
{
|
||||||
TCollection_AsciiString aCommand("vactivate ");
|
TCollection_AsciiString aCommand = TCollection_AsciiString ("vactivate ") + aViewNames.GetViewName();
|
||||||
aCommand = aCommand + aViewNames.GetViewName();
|
theDi.Eval (aCommand.ToCString());
|
||||||
theDi.Eval(aCommand.ToCString());
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight,
|
TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight,
|
||||||
aViewName.ToCString(),
|
aViewName.ToCString(),
|
||||||
aDisplayName.ToCString());
|
aDisplayName.ToCString());
|
||||||
cout << theArgVec[0] << ": 3D View - " << aViewId << " was created.\n";
|
theDi << aViewId;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1499,29 +1517,31 @@ void VT_ProcessConfigure()
|
|||||||
//function : VT_ProcessButton1Press
|
//function : VT_ProcessButton1Press
|
||||||
//purpose : Picking
|
//purpose : Picking
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
Standard_Boolean VT_ProcessButton1Press(
|
Standard_Boolean VT_ProcessButton1Press (Standard_Integer ,
|
||||||
Standard_Integer ,
|
const char** theArgVec,
|
||||||
const char** argv,
|
Standard_Boolean theToPick,
|
||||||
Standard_Boolean pick,
|
Standard_Boolean theIsShift)
|
||||||
Standard_Boolean shift)
|
|
||||||
{
|
{
|
||||||
Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
|
if (theToPick)
|
||||||
if ( pick ) {
|
{
|
||||||
Standard_Real X, Y, Z;
|
Standard_Real X, Y, Z;
|
||||||
|
ViewerTest::CurrentView()->Convert (X_Motion, Y_Motion, X, Y, Z);
|
||||||
|
|
||||||
ViewerTest::CurrentView()->Convert(X_Motion, Y_Motion, X, Y, Z);
|
Draw::Set (theArgVec[1], X);
|
||||||
|
Draw::Set (theArgVec[2], Y);
|
||||||
|
Draw::Set (theArgVec[3], Z);
|
||||||
|
}
|
||||||
|
|
||||||
Draw::Set(argv[1], X);
|
if (theIsShift)
|
||||||
Draw::Set(argv[2], Y);
|
{
|
||||||
Draw::Set(argv[3], Z);}
|
ViewerTest::CurrentEventManager()->ShiftSelect();
|
||||||
|
}
|
||||||
if(shift)
|
|
||||||
EM->ShiftSelect();
|
|
||||||
else
|
else
|
||||||
EM->Select();
|
{
|
||||||
|
ViewerTest::CurrentEventManager()->Select();
|
||||||
|
}
|
||||||
|
|
||||||
pick = 0;
|
return Standard_False;
|
||||||
return pick;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
Loading…
x
Reference in New Issue
Block a user