#include <NCollection_DoubleMap.hxx>
#include <NCollection_List.hxx>
#include <NCollection_Vector.hxx>
-#include <NIS_View.hxx>
-#include <NIS_Triangulated.hxx>
-#include <NIS_InteractiveContext.hxx>
#include <AIS_InteractiveContext.hxx>
#include <Draw_Interpretor.hxx>
#include <Draw.hxx>
Standard_IMPORT Standard_Boolean Draw_Interprete (const char* theCommand);
Standard_EXPORT int ViewerMainLoop(Standard_Integer , const char** argv);
-extern const Handle(NIS_InteractiveContext)& TheNISContext();
extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
extern int VErase (Draw_Interpretor& theDI,
static void OSWindowSetup();
+static struct
+{
+ Quantity_Color FlatColor;
+ Quantity_Color GradientColor1;
+ Quantity_Color GradientColor2;
+ Aspect_GradientFillMethod FillMethod;
+} ViewerTest_DefaultBackground = { Quantity_NOC_BLACK, Quantity_NOC_BLACK, Quantity_NOC_BLACK, Aspect_GFM_NONE };
+
//==============================================================================
// EVENT GLOBAL VARIABLES
//==============================================================================
toCreateViewer = Standard_True;
TCollection_ExtendedString NameOfWindow("Viewer3D");
a3DViewer = new V3d_Viewer(aGraphicDriver, NameOfWindow.ToExtString());
-
- NameOfWindow = TCollection_ExtendedString("Collector");
-
- a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK);
+ a3DViewer->SetDefaultBackgroundColor (ViewerTest_DefaultBackground.FlatColor);
+ a3DViewer->SetDefaultBgGradientColors (ViewerTest_DefaultBackground.GradientColor1,
+ ViewerTest_DefaultBackground.GradientColor2,
+ ViewerTest_DefaultBackground.FillMethod);
}
// AIS context setup
#if defined(_WIN32)
VT_GetWindow() = new WNT_Window (aTitle.ToCString(),
Handle(WNT_WClass)::DownCast (WClass()),
- Draw_VirtualWindows ? WS_POPUPWINDOW : WS_OVERLAPPEDWINDOW,
+ Draw_VirtualWindows ? WS_POPUP : WS_OVERLAPPEDWINDOW,
aPxLeft, aPxTop,
aPxWidth, aPxHeight,
Quantity_NOC_BLACK);
#endif
VT_GetWindow()->SetVirtual (Draw_VirtualWindows);
- // NIS setup
- Handle(NIS_View) aView = new NIS_View (a3DViewer, VT_GetWindow());
+ // View setup
+ Handle(V3d_View) aView = a3DViewer->CreateView();
+ aView->SetWindow (VT_GetWindow());
ViewerTest::CurrentView(aView);
ViewerTest_myViews.Bind (aViewNames.GetViewName(), aView);
- TheNISContext()->AttachView (aView);
// Setup for X11 or NT
OSWindowSetup();
Handle(AIS_InteractiveContext) aCurrentContext = FindContextByView(aView);
// Remove view resources
- TheNISContext()->DetachView(Handle(NIS_View)::DownCast(aView));
ViewerTest_myViews.UnBind1(theViewName);
aView->Remove();
{
//cout << "KeyPress" << endl;
const Handle(V3d_View) aView = ViewerTest::CurrentView();
- const Handle(NIS_View) aNisView = Handle(NIS_View)::DownCast (aView);
// Letter in alphabetic order
if (!strcasecmp (buf_ret, "A"))
}
else if (!strcasecmp (buf_ret, "F"))
{
- // FitAll
- if (aNisView.IsNull())
- aView->FitAll();
+ if (ViewerTest::GetAISContext()->NbSelected() > 0)
+ {
+ ViewerTest::GetAISContext()->FitSelected (aView);
+ }
else
- aNisView->FitAll3d();
+ {
+ // FitAll
+ aView->FitAll();
+ }
}
else if (!strcasecmp (buf_ret, "H"))
{
{
ViewerTest::GetAISContext()->HilightPreviousDetected(ViewerTest::CurrentView());
}
+ else if (!strcasecmp (buf_ret, "/"))
+ {
+ Handle(Graphic3d_Camera) aCamera = aView->Camera();
+ if (aCamera->IsStereo())
+ {
+ aCamera->SetIOD (aCamera->GetIODType(), aCamera->IOD() - 0.01);
+ aView->Redraw();
+ }
+ }
+ else if (!strcasecmp (buf_ret, "*"))
+ {
+ Handle(Graphic3d_Camera) aCamera = aView->Camera();
+ if (aCamera->IsStereo())
+ {
+ aCamera->SetIOD (aCamera->GetIODType(), aCamera->IOD() + 0.01);
+ aView->Redraw();
+ }
+ }
else if (*buf_ret == THE_KEY_DELETE)
{
Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
if (theIsShift)
{
- EM->ShiftSelect (Min (X_ButtonPress, X_Motion), Max (Y_ButtonPress, Y_Motion),
- Max (X_ButtonPress, X_Motion), Min (Y_ButtonPress, Y_Motion));
+ EM->ShiftSelect (X_ButtonPress, Y_ButtonPress,
+ X_Motion, Y_Motion);
}
else
{
- EM->Select (Min (X_ButtonPress, X_Motion), Max (Y_ButtonPress, Y_Motion),
- Max (X_ButtonPress, X_Motion), Min (Y_ButtonPress, Y_Motion));
+ EM->Select (X_ButtonPress, Y_ButtonPress,
+ X_Motion, Y_Motion);
}
}
}
LPARAM lParam )
{
static int Up = 1;
+ const Handle(V3d_View)& aView = ViewerTest::CurrentView();
+ if (aView.IsNull())
+ {
+ return DefWindowProc( hwnd, Msg, wParam, lParam );
+ }
- if ( !ViewerTest::CurrentView().IsNull() ) {
PAINTSTRUCT ps;
switch( Msg ) {
case WM_SIZE:
VT_ProcessConfigure();
break;
+ case WM_MOVE:
+ case WM_MOVING:
+ case WM_SIZING:
+ switch (aView->RenderingParams().StereoMode)
+ {
+ case Graphic3d_StereoMode_RowInterlaced:
+ case Graphic3d_StereoMode_ColumnInterlaced:
+ case Graphic3d_StereoMode_ChessBoard:
+ VT_ProcessConfigure(); // track window moves to reverse stereo pair
+ break;
+ default:
+ break;
+ }
+ break;
case WM_KEYDOWN:
if ((wParam != VK_SHIFT) && (wParam != VK_CONTROL))
{
c[0] = '.';
}
+ else if (wParam == VK_DIVIDE)
+ {
+ c[0] = '/';
+ }
+ // dot
+ else if (wParam == VK_MULTIPLY)
+ {
+ c[0] = '*';
+ }
VT_ProcessKeyPress (c);
}
break;
}
break;
+ case WM_MOUSEWHEEL:
+ {
+ int aDelta = GET_WHEEL_DELTA_WPARAM (wParam);
+ if (wParam & MK_CONTROL)
+ {
+ if (aView->Camera()->IsStereo())
+ {
+ Standard_Real aFocus = aView->Camera()->ZFocus() + (aDelta > 0 ? 0.05 : -0.05);
+ if (aFocus > 0.2
+ && aFocus < 2.0)
+ {
+ aView->Camera()->SetZFocus (aView->Camera()->ZFocusType(), aFocus);
+ aView->Redraw();
+ }
+ }
+ }
+ else
+ {
+ aView->Zoom (0, 0, aDelta / 40, aDelta / 40);
+ }
+ break;
+ }
+
case WM_MOUSEMOVE:
{
//cout << "\t WM_MOUSEMOVE" << endl;
return( DefWindowProc( hwnd, Msg, wParam, lParam ));
}
return 0L;
- }
-
- return DefWindowProc( hwnd, Msg, wParam, lParam );
}
}
-
//==============================================================================
//function : VFit
//Draw arg : No args
//==============================================================================
-static int VFit(Draw_Interpretor& , Standard_Integer , const char** )
+static int VFit (Draw_Interpretor& /*theDi*/, Standard_Integer theArgc, const char** theArgv)
{
+ if (theArgc > 2)
+ {
+ std::cout << "Wrong number of arguments! Use: vfit [-selected]" << std::endl;
+ }
+
const Handle(V3d_View) aView = ViewerTest::CurrentView();
- Handle(NIS_View) V = Handle(NIS_View)::DownCast(aView);
- if (V.IsNull() == Standard_False) {
- V->FitAll3d();
- } else if (aView.IsNull() == Standard_False) {
+
+ if (theArgc == 2)
+ {
+ TCollection_AsciiString anArg (theArgv[1]);
+ anArg.LowerCase();
+ if (anArg == "-selected")
+ {
+ ViewerTest::GetAISContext()->FitSelected (aView);
+ return 0;
+ }
+ }
+ if (aView.IsNull() == Standard_False) {
+
aView->FitAll();
}
return 0;
return 0;
}
+//==============================================================================
+//function : VSetDefaultBg
+//purpose : Set default viewer background fill color
+//==============================================================================
+static int VSetDefaultBg (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
+{
+ if (theArgNb != 4
+ && theArgNb != 8)
+ {
+ std::cout << "Error: wrong syntax! See usage:\n";
+ theDI.PrintHelp (theArgVec[0]);
+ return 1;
+ }
+
+ ViewerTest_DefaultBackground.FillMethod =
+ theArgNb == 4 ? Aspect_GFM_NONE
+ : (Aspect_GradientFillMethod) Draw::Atoi (theArgVec[7]);
+
+ if (theArgNb == 4)
+ {
+ Standard_Real R = Draw::Atof (theArgVec[1]) / 255.;
+ Standard_Real G = Draw::Atof (theArgVec[2]) / 255.;
+ Standard_Real B = Draw::Atof (theArgVec[3]) / 255.;
+ ViewerTest_DefaultBackground.FlatColor.SetValues (R, G, B, Quantity_TOC_RGB);
+ }
+ else
+ {
+ Standard_Real R1 = Draw::Atof (theArgVec[1]) / 255.;
+ Standard_Real G1 = Draw::Atof (theArgVec[2]) / 255.;
+ Standard_Real B1 = Draw::Atof (theArgVec[3]) / 255.;
+ ViewerTest_DefaultBackground.GradientColor1.SetValues (R1, G1, B1, Quantity_TOC_RGB);
+
+ Standard_Real R2 = Draw::Atof (theArgVec[4]) / 255.;
+ Standard_Real G2 = Draw::Atof (theArgVec[5]) / 255.;
+ Standard_Real B2 = Draw::Atof (theArgVec[6]) / 255.;
+ ViewerTest_DefaultBackground.GradientColor2.SetValues (R2, G2, B2, Quantity_TOC_RGB);
+ }
+
+ for (NCollection_DoubleMap<TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
+ anIter (ViewerTest_myContexts); anIter.More(); anIter.Next())
+ {
+ const Handle(V3d_Viewer)& aViewer = anIter.Value()->CurrentViewer();
+ aViewer->SetDefaultBackgroundColor (ViewerTest_DefaultBackground.FlatColor);
+ aViewer->SetDefaultBgGradientColors (ViewerTest_DefaultBackground.GradientColor1,
+ ViewerTest_DefaultBackground.GradientColor2,
+ ViewerTest_DefaultBackground.FillMethod);
+ }
+
+ return 0;
+}
+
//==============================================================================
//function : VScale
//purpose : View Scaling
return 0;
}
-DEFINE_STANDARD_HANDLE(V3d_TextItem, Visual3d_LayerItem)
-
// this class provides a presentation of text item in v3d view under-/overlayer
class V3d_TextItem : public Visual3d_LayerItem
{
public:
// CASCADE RTTI
- DEFINE_STANDARD_RTTI(V3d_TextItem)
+ DEFINE_STANDARD_RTTI(V3d_TextItem, Visual3d_LayerItem)
// constructor
Standard_EXPORT V3d_TextItem(const TCollection_AsciiString& theText,
TCollection_AsciiString myFontName;
};
-IMPLEMENT_STANDARD_HANDLE(V3d_TextItem, Visual3d_LayerItem)
-IMPLEMENT_STANDARD_RTTIEXT(V3d_TextItem, Visual3d_LayerItem)
// create and add to display the text item
V3d_TextItem::V3d_TextItem (const TCollection_AsciiString& theText,
myLayer->DrawText (myText.ToCString (), myX1, myY1, myHeight);
}
-DEFINE_STANDARD_HANDLE(V3d_LineItem, Visual3d_LayerItem)
-
// The Visual3d_LayerItem line item for "vlayerline" command
// it provides a presentation of line with user-defined
// linewidth, linetype and transparency.
{
public:
// CASCADE RTTI
- DEFINE_STANDARD_RTTI(V3d_LineItem)
+ DEFINE_STANDARD_RTTI(V3d_LineItem, Visual3d_LayerItem)
// constructor
Standard_EXPORT V3d_LineItem(Standard_Real X1, Standard_Real Y1,
Standard_Real myTransparency;
};
-IMPLEMENT_STANDARD_HANDLE(V3d_LineItem, Visual3d_LayerItem)
-IMPLEMENT_STANDARD_RTTIEXT(V3d_LineItem, Visual3d_LayerItem)
// default constructor for line item
V3d_LineItem::V3d_LineItem(Standard_Real X1, Standard_Real Y1,
theDI << "FPS: " << aFpsAver << "\n"
<< "CPU: " << (1000.0 * aCpuAver) << " msec\n";
+ // compute additional statistics in ray-tracing mode
+ Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams();
+
+ if (aParams.Method == Graphic3d_RM_RAYTRACING)
+ {
+ Standard_Integer aSizeX;
+ Standard_Integer aSizeY;
+
+ aView->Window()->Size (aSizeX, aSizeY);
+
+ // 1 shadow ray and 1 secondary ray pew each bounce
+ const Standard_Real aMRays = aSizeX * aSizeY * aFpsAver * aParams.RaytracingDepth * 2 / 1.0e6f;
+
+ theDI << "MRays/sec (upper bound): " << aMRays << "\n";
+ }
+
return 0;
}
theDI << "Sprites: " << (aCaps->pntSpritesDisable ? "0" : "1") << "\n";
theDI << "SoftMode:" << (aCaps->contextNoAccel ? "1" : "0") << "\n";
theDI << "FFP: " << (aCaps->ffpEnable ? "1" : "0") << "\n";
+ theDI << "VSync: " << aCaps->swapInterval << "\n";
theDI << "Compatible:" << (aCaps->contextCompatible ? "1" : "0") << "\n";
+ theDI << "Stereo: " << (aCaps->contextStereo ? "1" : "0") << "\n";
return 0;
}
{
continue;
}
+ else if (anArgCase == "-vsync"
+ || anArgCase == "-swapinterval")
+ {
+ Standard_Boolean toEnable = Standard_True;
+ if (++anArgIter < theArgNb
+ && !parseOnOff (theArgVec[anArgIter], toEnable))
+ {
+ --anArgIter;
+ }
+ aCaps->swapInterval = toEnable;
+ }
else if (anArgCase == "-ffp")
{
Standard_Boolean toEnable = Standard_True;
aCaps->ffpEnable = Standard_False;
}
}
+ else if (anArgCase == "-stereo"
+ || anArgCase == "-quadbuffer")
+ {
+ Standard_Boolean toEnable = Standard_True;
+ if (++anArgIter < theArgNb
+ && !parseOnOff (theArgVec[anArgIter], toEnable))
+ {
+ --anArgIter;
+ }
+ aCaps->contextStereo = toEnable;
+ }
else
{
std::cout << "Error: unknown argument '" << anArg << "'\n";
di << "use 'vinit' command before " << argv[0] << "\n";
return 1;
}
- const Standard_Boolean isShiftSelection = (argc>3 && !(argc%2) && (atoi(argv[argc-1])==1));
+
+ const Standard_Boolean isShiftSelection = (argc > 3 && !(argc % 2) && (atoi (argv[argc - 1]) == 1));
+ Standard_Integer aCoordsNb = isShiftSelection ? argc - 2 : argc - 1;
+ TCollection_AsciiString anArg;
+ anArg = isShiftSelection ? argv[argc - 3] : argv[argc - 2];
+ anArg.LowerCase();
+ if (anArg == "-allowoverlap")
+ {
+ Standard_Boolean isValidated = isShiftSelection ? argc == 8
+ : argc == 7;
+ if (!isValidated)
+ {
+ di << "Wrong number of arguments! -allowoverlap key is applied only for rectangle selection";
+ return 1;
+ }
+
+ Standard_Integer isToAllow = isShiftSelection ? Draw::Atoi(argv[argc - 2]) : Draw::Atoi(argv[argc - 1]);
+ myAIScontext->MainSelector()->AllowOverlapDetection((Standard_Boolean)isToAllow);
+ aCoordsNb -= 2;
+ }
+
Handle(ViewerTest_EventManager) aCurrentEventManager = ViewerTest::CurrentEventManager();
aCurrentEventManager->MoveTo(atoi(argv[1]),atoi(argv[2]));
- if(argc <= 4)
+ if(aCoordsNb == 2)
{
if(isShiftSelection)
aCurrentEventManager->ShiftSelect();
else
aCurrentEventManager->Select();
}
- else if(argc <= 6)
+ else if(aCoordsNb == 4)
{
if(isShiftSelection)
- aCurrentEventManager->ShiftSelect(atoi(argv[1]),atoi(argv[2]),atoi(argv[3]),atoi(argv[4]));
+ aCurrentEventManager->ShiftSelect (atoi (argv[1]), atoi (argv[2]), atoi (argv[3]), atoi (argv[4]), Standard_False);
else
- aCurrentEventManager->Select(atoi(argv[1]),atoi(argv[2]),atoi(argv[3]),atoi(argv[4]));
+ aCurrentEventManager->Select (atoi (argv[1]), atoi (argv[2]), atoi (argv[3]), atoi (argv[4]), Standard_False);
}
else
{
- Standard_Integer anUpper = 0;
+ TColgp_Array1OfPnt2d aPolyline (1,aCoordsNb / 2);
- if(isShiftSelection)
- anUpper = (argc-1)/2;
- else
- anUpper = argc/2;
- TColgp_Array1OfPnt2d aPolyline(1,anUpper);
-
- for(Standard_Integer i=1;i<=anUpper;++i)
+ for(Standard_Integer i=1;i<=aCoordsNb / 2;++i)
aPolyline.SetValue(i,gp_Pnt2d(atoi(argv[2*i-1]),atoi(argv[2*i])));
if(isShiftSelection)
const Standard_ShortReal theXShift,
const Standard_ShortReal theYShift,
const Standard_ShortReal theAngle);
- DEFINE_STANDARD_RTTI(OCC_TextureEnv);
+ DEFINE_STANDARD_RTTI(OCC_TextureEnv, Graphic3d_TextureEnv);
};
DEFINE_STANDARD_HANDLE(OCC_TextureEnv, Graphic3d_TextureEnv);
-IMPLEMENT_STANDARD_HANDLE(OCC_TextureEnv, Graphic3d_TextureEnv);
-IMPLEMENT_STANDARD_RTTIEXT(OCC_TextureEnv, Graphic3d_TextureEnv);
+
+
+
OCC_TextureEnv::OCC_TextureEnv(const Standard_CString theFileName)
: Graphic3d_TextureEnv(theFileName)
return 0;
}
+//! Parse stereo output mode
+inline Standard_Boolean parseStereoMode (Standard_CString theArg,
+ Graphic3d_StereoMode& theMode)
+{
+ TCollection_AsciiString aFlag (theArg);
+ aFlag.LowerCase();
+ if (aFlag == "quadbuffer")
+ {
+ theMode = Graphic3d_StereoMode_QuadBuffer;
+ }
+ else if (aFlag == "anaglyph")
+ {
+ theMode = Graphic3d_StereoMode_Anaglyph;
+ }
+ else if (aFlag == "row"
+ || aFlag == "rowinterlaced")
+ {
+ theMode = Graphic3d_StereoMode_RowInterlaced;
+ }
+ else if (aFlag == "col"
+ || aFlag == "colinterlaced"
+ || aFlag == "columninterlaced")
+ {
+ theMode = Graphic3d_StereoMode_ColumnInterlaced;
+ }
+ else if (aFlag == "chess"
+ || aFlag == "chessboard")
+ {
+ theMode = Graphic3d_StereoMode_ChessBoard;
+ }
+ else if (aFlag == "sbs"
+ || aFlag == "sidebyside")
+ {
+ theMode = Graphic3d_StereoMode_SideBySide;
+ }
+ else if (aFlag == "ou"
+ || aFlag == "overunder")
+ {
+ theMode = Graphic3d_StereoMode_OverUnder;
+ }
+ else if (aFlag == "pageflip"
+ || aFlag == "softpageflip")
+ {
+ theMode = Graphic3d_StereoMode_SoftPageFlip;
+ }
+ else
+ {
+ return Standard_False;
+ }
+ return Standard_True;
+}
+
+//! Parse anaglyph filter
+inline Standard_Boolean parseAnaglyphFilter (Standard_CString theArg,
+ Graphic3d_RenderingParams::Anaglyph& theFilter)
+{
+ TCollection_AsciiString aFlag (theArg);
+ aFlag.LowerCase();
+ if (aFlag == "redcyansimple")
+ {
+ theFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Simple;
+ }
+ else if (aFlag == "redcyan"
+ || aFlag == "redcyanoptimized")
+ {
+ theFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Optimized;
+ }
+ else if (aFlag == "yellowbluesimple")
+ {
+ theFilter = Graphic3d_RenderingParams::Anaglyph_YellowBlue_Simple;
+ }
+ else if (aFlag == "yellowblue"
+ || aFlag == "yellowblueoptimized")
+ {
+ theFilter = Graphic3d_RenderingParams::Anaglyph_YellowBlue_Optimized;
+ }
+ else if (aFlag == "greenmagenta"
+ || aFlag == "greenmagentasimple")
+ {
+ theFilter = Graphic3d_RenderingParams::Anaglyph_GreenMagenta_Simple;
+ }
+ else
+ {
+ return Standard_False;
+ }
+ return Standard_True;
+}
+
//==============================================================================
//function : VStereo
//purpose :
Standard_Integer theArgNb,
const char** theArgVec)
{
+ Handle(V3d_View) aView = ViewerTest::CurrentView();
if (theArgNb < 2)
{
- Handle(V3d_View) aView = ViewerTest::CurrentView();
if (aView.IsNull())
{
- std::cerr << "No active view. Please call vinit.\n";
+ std::cout << "Error: no active viewer!\n";
return 0;
}
return 0;
}
- ViewerTest_myDefaultCaps.contextStereo = Draw::Atoi (theArgVec[1]) != 0;
+ Handle(Graphic3d_Camera) aCamera;
+ Graphic3d_RenderingParams* aParams = NULL;
+ Graphic3d_StereoMode aMode = Graphic3d_StereoMode_QuadBuffer;
+ if (!aView.IsNull())
+ {
+ aParams = &aView->ChangeRenderingParams();
+ aMode = aParams->StereoMode;
+ aCamera = aView->Camera();
+ }
+
+ ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
+ for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
+ {
+ Standard_CString anArg = theArgVec[anArgIter];
+ TCollection_AsciiString aFlag (anArg);
+ aFlag.LowerCase();
+ if (anUpdateTool.parseRedrawMode (aFlag))
+ {
+ continue;
+ }
+ else if (aFlag == "0"
+ || aFlag == "off")
+ {
+ if (++anArgIter < theArgNb)
+ {
+ std::cout << "Error: wrong number of arguments!\n";
+ return 1;
+ }
+
+ if (!aCamera.IsNull()
+ && aCamera->ProjectionType() == Graphic3d_Camera::Projection_Stereo)
+ {
+ aCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective);
+ }
+ ViewerTest_myDefaultCaps.contextStereo = Standard_False;
+ return 0;
+ }
+ else if (aFlag == "1"
+ || aFlag == "on")
+ {
+ if (++anArgIter < theArgNb)
+ {
+ std::cout << "Error: wrong number of arguments!\n";
+ return 1;
+ }
+
+ if (!aCamera.IsNull())
+ {
+ aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
+ }
+ ViewerTest_myDefaultCaps.contextStereo = Standard_True;
+ return 0;
+ }
+ else if (aFlag == "-reverse"
+ || aFlag == "-reversed"
+ || aFlag == "-swap")
+ {
+ Standard_Boolean toEnable = Standard_True;
+ if (++anArgIter < theArgNb
+ && !parseOnOff (theArgVec[anArgIter], toEnable))
+ {
+ --anArgIter;
+ }
+ aParams->ToReverseStereo = toEnable;
+ }
+ else if (aFlag == "-noreverse"
+ || aFlag == "-noswap")
+ {
+ Standard_Boolean toDisable = Standard_True;
+ if (++anArgIter < theArgNb
+ && !parseOnOff (theArgVec[anArgIter], toDisable))
+ {
+ --anArgIter;
+ }
+ aParams->ToReverseStereo = !toDisable;
+ }
+ else if (aFlag == "-mode"
+ || aFlag == "-stereomode")
+ {
+ if (++anArgIter >= theArgNb
+ || !parseStereoMode (theArgVec[anArgIter], aMode))
+ {
+ std::cout << "Error: syntax error at '" << anArg << "'\n";
+ return 1;
+ }
+
+ if (aMode == Graphic3d_StereoMode_QuadBuffer)
+ {
+ ViewerTest_myDefaultCaps.contextStereo = Standard_True;
+ }
+ }
+ else if (aFlag == "-anaglyph"
+ || aFlag == "-anaglyphfilter")
+ {
+ Graphic3d_RenderingParams::Anaglyph aFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Simple;
+ if (++anArgIter >= theArgNb
+ || !parseAnaglyphFilter (theArgVec[anArgIter], aFilter))
+ {
+ std::cout << "Error: syntax error at '" << anArg << "'\n";
+ return 1;
+ }
+
+ aMode = Graphic3d_StereoMode_Anaglyph;
+ aParams->AnaglyphFilter = aFilter;
+ }
+ else if (parseStereoMode (anArg, aMode)) // short syntax
+ {
+ if (aMode == Graphic3d_StereoMode_QuadBuffer)
+ {
+ ViewerTest_myDefaultCaps.contextStereo = Standard_True;
+ }
+ }
+ else
+ {
+ std::cout << "Error: syntax error at '" << anArg << "'\n";
+ return 1;
+ }
+ }
+
+ if (!aView.IsNull())
+ {
+ aParams->StereoMode = aMode;
+ aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
+ }
return 0;
}
// currently HLRDeviationAngle is used instead of DeviationAngle in most places
aDefParams->SetHLRAngle (M_PI * Draw::Atof (theArgVec[anArgIter]) / 180.0);
}
- if (anArg == "-AUTOTR"
- || anArg == "-AUTOTRIANG"
- || anArg == "-AUTOTRIANGULATION")
+ else if (anArg == "-AUTOTR"
+ || anArg == "-AUTOTRIANG"
+ || anArg == "-AUTOTRIANGULATION")
{
if (++anArgIter >= theArgsNb)
{
{
case V3d_AMBIENT:
{
- theDi << " Type: Ambient\n";
+ theDi << " Type: Ambient\n";
+ theDi << " Intensity: " << aLight->Intensity() << "\n";
break;
}
case V3d_DIRECTIONAL:
{
Handle(V3d_DirectionalLight) aLightDir = Handle(V3d_DirectionalLight)::DownCast (aLight);
- theDi << " Type: Directional\n";
- theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
+ theDi << " Type: Directional\n";
+ theDi << " Intensity: " << aLight->Intensity() << "\n";
+ theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
+ theDi << " Smoothness: " << aLight->Smoothness() << "\n";
if (!aLightDir.IsNull())
{
aLightDir->Position (anXYZ[0], anXYZ[1], anXYZ[2]);
- theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
+ theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
aLightDir->Direction (anXYZ[0], anXYZ[1], anXYZ[2]);
- theDi << " Direction: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
+ theDi << " Direction: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
}
break;
}
case V3d_POSITIONAL:
{
Handle(V3d_PositionalLight) aLightPos = Handle(V3d_PositionalLight)::DownCast (aLight);
- theDi << " Type: Positional\n";
- theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
+ theDi << " Type: Positional\n";
+ theDi << " Intensity: " << aLight->Intensity() << "\n";
+ theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
+ theDi << " Smoothness: " << aLight->Smoothness() << "\n";
if (!aLightPos.IsNull())
{
aLightPos->Position (anXYZ[0], anXYZ[1], anXYZ[2]);
- theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
+ theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
aLightPos->Attenuation (anAtten[0], anAtten[1]);
- theDi << " Atten.: " << anAtten[0] << " " << anAtten[1] << "\n";
+ theDi << " Atten.: " << anAtten[0] << " " << anAtten[1] << "\n";
}
break;
}
case V3d_SPOT:
{
Handle(V3d_SpotLight) aLightSpot = Handle(V3d_SpotLight)::DownCast (aLight);
- theDi << " Type: Spot\n";
- theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
+ theDi << " Type: Spot\n";
+ theDi << " Intensity: " << aLight->Intensity() << "\n";
+ theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
if (!aLightSpot.IsNull())
{
aLightSpot->Position (anXYZ[0], anXYZ[1], anXYZ[2]);
- theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
+ theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
aLightSpot->Direction (anXYZ[0], anXYZ[1], anXYZ[2]);
- theDi << " Direction: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
+ theDi << " Direction: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
aLightSpot->Attenuation (anAtten[0], anAtten[1]);
- theDi << " Atten.: " << anAtten[0] << " " << anAtten[1] << "\n";
- theDi << " Angle: " << (aLightSpot->Angle() * 180.0 / M_PI) << "\n";
- theDi << " Exponent: " << aLightSpot->Concentration() << "\n";
+ theDi << " Atten.: " << anAtten[0] << " " << anAtten[1] << "\n";
+ theDi << " Angle: " << (aLightSpot->Angle() * 180.0 / M_PI) << "\n";
+ theDi << " Exponent: " << aLightSpot->Concentration() << "\n";
}
break;
}
default:
{
- theDi << " Type: UNKNOWN\n";
+ theDi << " Type: UNKNOWN\n";
break;
}
}
return 1;
}
}
+ else if (anArgCase.IsEqual ("SM")
+ || anArgCase.IsEqual ("SMOOTHNESS"))
+ {
+ if (++anArgIt >= theArgsNb)
+ {
+ std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+ return 1;
+ }
+
+ Standard_Real aSmoothness = Atof (theArgVec[anArgIt]);
+
+ if (fabs (aSmoothness) < Precision::Confusion())
+ {
+ aLightCurr->SetIntensity (1.f);
+ }
+ else if (fabs (aLightCurr->Smoothness()) < Precision::Confusion())
+ {
+ aLightCurr->SetIntensity ((aSmoothness * aSmoothness) / 3.f);
+ }
+ else
+ {
+ Standard_ShortReal aSmoothnessRatio = static_cast<Standard_ShortReal> (aSmoothness / aLightCurr->Smoothness());
+ aLightCurr->SetIntensity (aLightCurr->Intensity() / (aSmoothnessRatio * aSmoothnessRatio));
+ }
+
+ if (!aLightPos.IsNull())
+ {
+ aLightPos->SetSmoothRadius (aSmoothness);
+ }
+ else if (!aLightDir.IsNull())
+ {
+ aLightDir->SetSmoothAngle (aSmoothness);
+ }
+ }
+ else if (anArgCase.IsEqual ("INT")
+ || anArgCase.IsEqual ("INTENSITY"))
+ {
+ if (++anArgIt >= theArgsNb)
+ {
+ std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+ return 1;
+ }
+
+ Standard_Real aIntensity = Atof (theArgVec[anArgIt]);
+
+ if (!aLightCurr.IsNull())
+ {
+ aLightCurr->SetIntensity (aIntensity);
+ }
+ }
else if (anArgCase.IsEqual ("ANG")
|| anArgCase.IsEqual ("ANGLE"))
{
case Graphic3d_RM_RAYTRACING: theDI << "raytrace "; break;
}
theDI << "\n";
- theDI << "fsaa: " << (aParams.IsAntialiasingEnabled ? "on" : "off") << "\n";
- theDI << "shadows: " << (aParams.IsShadowEnabled ? "on" : "off") << "\n";
- theDI << "reflections: " << (aParams.IsReflectionEnabled ? "on" : "off") << "\n";
- theDI << "rayDepth: " << aParams.RaytracingDepth << "\n";
- theDI << "gleam: " << (aParams.IsTransparentShadowEnabled ? "on" : "off") << "\n";
+ theDI << "fsaa: " << (aParams.IsAntialiasingEnabled ? "on" : "off") << "\n";
+ theDI << "shadows: " << (aParams.IsShadowEnabled ? "on" : "off") << "\n";
+ theDI << "reflections: " << (aParams.IsReflectionEnabled ? "on" : "off") << "\n";
+ theDI << "rayDepth: " << aParams.RaytracingDepth << "\n";
+ theDI << "gleam: " << (aParams.IsTransparentShadowEnabled ? "on" : "off") << "\n";
+ theDI << "GI: " << (aParams.IsGlobalIlluminationEnabled ? "on" : "off") << "\n";
+ theDI << "blocked RNG: " << (aParams.CoherentPathTracingMode ? "on" : "off") << "\n";
theDI << "shadingModel: ";
switch (aView->ShadingModel())
{
}
const Standard_Integer aDepth = Draw::Atoi (theArgVec[anArgIter]);
- if (aDepth < 1 || aDepth > 10)
+
+ // We allow RaytracingDepth be more than 10 in case of GI enabled
+ if (aDepth < 1 || (aDepth > 10 && !aParams.IsGlobalIlluminationEnabled))
{
std::cerr << "Error: invalid ray-tracing depth " << aDepth << ". Should be within range [1; 10]\n";
return 1;
}
aParams.IsTransparentShadowEnabled = toEnable;
}
+ else if (aFlag == "-gi")
+ {
+ if (toPrint)
+ {
+ theDI << (aParams.IsGlobalIlluminationEnabled ? "on" : "off") << " ";
+ continue;
+ }
+
+ Standard_Boolean toEnable = Standard_True;
+ if (++anArgIter < theArgNb
+ && !parseOnOff (theArgVec[anArgIter], toEnable))
+ {
+ --anArgIter;
+ }
+ aParams.IsGlobalIlluminationEnabled = toEnable;
+ if (!toEnable)
+ {
+ aParams.RaytracingDepth = Min (aParams.RaytracingDepth, 10);
+ }
+ }
+ else if (aFlag == "-blockedrng"
+ || aFlag == "-brng")
+ {
+ if (toPrint)
+ {
+ theDI << (aParams.CoherentPathTracingMode ? "on" : "off") << " ";
+ continue;
+ }
+
+ Standard_Boolean toEnable = Standard_True;
+ if (++anArgIter < theArgNb
+ && !parseOnOff (theArgVec[anArgIter], toEnable))
+ {
+ --anArgIter;
+ }
+ aParams.CoherentPathTracingMode = toEnable;
+ }
+ else if (aFlag == "-env")
+ {
+ if (toPrint)
+ {
+ theDI << (aParams.UseEnvironmentMapBackground ? "on" : "off") << " ";
+ continue;
+ }
+
+ Standard_Boolean toEnable = Standard_True;
+ if (++anArgIter < theArgNb
+ && !parseOnOff (theArgVec[anArgIter], toEnable))
+ {
+ --anArgIter;
+ }
+ aParams.UseEnvironmentMapBackground = toEnable;
+ }
else if (aFlag == "-shademodel"
|| aFlag == "-shadingmodel"
|| aFlag == "-shading")
return 1;
}
}
+
+ return 0;
+}
+
+//=======================================================================
+//function : VProgressiveMode
+//purpose :
+//=======================================================================
+#if defined(_WIN32)
+static Standard_Integer VProgressiveMode (Draw_Interpretor& /*theDI*/,
+ Standard_Integer /*theNbArgs*/,
+ const char** /*theArgs*/)
+{
+ Handle(V3d_View) aView = ViewerTest::CurrentView();
+ if (aView.IsNull())
+ {
+ std::cerr << "Error: no active viewer!\n";
+ return 1;
+ }
+
+ std::cout << "Press Enter or Escape key to exit progressive rendering mode" << std::endl;
+
+ for (;;)
+ {
+ aView->Redraw();
+
+ Standard_Boolean toExit = Standard_False;
+
+ MSG aMsg;
+ while (PeekMessage (&aMsg, NULL, NULL, NULL, PM_REMOVE))
+ {
+ if (aMsg.message == WM_KEYDOWN && (aMsg.wParam == 0x0d || aMsg.wParam == 0x1b))
+ {
+ toExit = Standard_True;
+ }
+
+ TranslateMessage (&aMsg);
+ DispatchMessage (&aMsg);
+ }
+
+ if (toExit)
+ {
+ break;
+ }
+ }
+
return 0;
}
+#endif
//=======================================================================
//function : VFrustumCulling
"vpick : vpick X Y Z [shape subshape] ( all variables as string )",
VPick,group);
theCommands.Add("vfit" ,
- "vfit or <F> : vfit",
+ "vfit or <F> [-selected]"
+ "\n\t\t: [-selected] fits the scene according to bounding box of currently selected objects",
__FILE__,VFit,group);
theCommands.Add ("vfitarea",
"vfitarea x1 y1 x2 y2"
theCommands.Add("vsetcolorbg",
"vsetcolorbg : vsetcolorbg r g b : Set background color",
__FILE__,VSetColorBg,group);
+ theCommands.Add("vsetdefaultbg",
+ "vsetdefaultbg r g b\n"
+ "\n\t\t: vsetdefaultbg r1 g1 b1 r2 g2 b2 fillmode"
+ "\n\t\t: Set default viewer background fill color (flat/gradient).",
+ __FILE__,VSetDefaultBg,group);
theCommands.Add("vscale",
"vscale : vscale X Y Z",
__FILE__,VScale,group);
"vvbo [{0|1}] : turn VBO usage On/Off; affects only newly displayed objects",
__FILE__, VVbo, group);
theCommands.Add ("vstereo",
- "\nvstereo [{0|1}] : turn stereo usage On/Off; affects only newly displayed objects",
+ "vstereo [0|1] [-mode Mode] [-reverse {0|1}]"
+ "\n\t\t: [-anaglyph Filter]"
+ "\n\t\t: Control stereo output mode. Available modes for -mode:"
+ "\n\t\t: quadBuffer - OpenGL QuadBuffer stereo,"
+ "\n\t\t: requires driver support."
+ "\n\t\t: Should be called BEFORE vinit!"
+ "\n\t\t: anaglyph - Anaglyph glasses"
+ "\n\t\t: rowInterlaced - row-interlaced display"
+ "\n\t\t: columnInterlaced - column-interlaced display"
+ "\n\t\t: chessBoard - chess-board output"
+ "\n\t\t: sideBySide - horizontal pair"
+ "\n\t\t: overUnder - vertical pair"
+ "\n\t\t: Available Anaglyph filters for -anaglyph:"
+ "\n\t\t: redCyan, redCyanSimple, yellowBlue, yellowBlueSimple,"
+ "\n\t\t: greenMagentaSimple",
__FILE__, VStereo, group);
theCommands.Add ("vcaps",
"vcaps [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}]"
"\n\t\t: [-compatibleContext {0|1}]"
+ "\n\t\t: [-vsync {0|1}]"
+ "\n\t\t: [-quadBuffer {0|1}] [-stereo {0|1}]"
"\n\t\t: [-softMode {0|1}] [-noupdate|-update]"
"\n\t\t: Modify particular graphic driver options:"
"\n\t\t: FFP - use fixed-function pipeline instead of"
"\n\t\t: VBO - use Vertex Buffer Object (copy vertex"
"\n\t\t: arrays to GPU memory)"
"\n\t\t: sprite - use textured sprites instead of bitmaps"
+ "\n\t\t: vsync - switch VSync on or off"
"\n\t\t: Context creation options:"
"\n\t\t: softMode - software OpenGL implementation"
"\n\t\t: compatibleProfile - backward-compatible profile"
+ "\n\t\t: quadbuffer - QuadBuffer"
"\n\t\t: Unlike vrenderparams, these parameters control alternative"
"\n\t\t: rendering paths producing the same visual result when"
"\n\t\t: possible."
"diffimage : diffimage imageFile1 imageFile2 toleranceOfColor(0..1) blackWhite(1|0) borderFilter(1|0) [diffImageFile]",
__FILE__, VDiffImage, group);
theCommands.Add ("vselect",
- "vselect x1 y1 [x2 y2 [x3 y3 ... xn yn]] [shift_selection = 0|1]\n"
+ "vselect x1 y1 [x2 y2 [x3 y3 ... xn yn]] [-allowoverlap 0|1] [shift_selection = 0|1]\n"
"- emulates different types of selection:\n"
"- 1) single click selection\n"
"- 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2)\n"
"- 3) selection with polygon having corners in pixel positions (x1,y1), (x2,y2),...,(xn,yn)\n"
- "- 4) any of these selections with shift button pressed",
+ "- 4) -allowoverlap determines will partially included objects be selected in rectangular selection"
+ " (partial inclusion - overlap - is not allowed by default)\n"
+ "- 5) any of these selections with shift button pressed",
__FILE__, VSelect, group);
theCommands.Add ("vmoveto",
"vmoveto x y"
"\n {dir}ection X Y Z (for directional light or for spotlight)"
"\n color colorName"
"\n {head}light 0|1"
+ "\n {sm}oothness value"
+ "\n {int}ensity value"
"\n {constAtten}uation value"
"\n {linearAtten}uation value"
"\n angle angleDeg"
__FILE__, VLight, group);
theCommands.Add("vraytrace",
"vraytrace [0|1]"
- "\n\t\t: Turn on/off raytracing renderer."
+ "\n\t\t: Turns on/off ray-tracing renderer."
"\n\t\t: 'vraytrace 0' alias for 'vrenderparams -raster'."
"\n\t\t: 'vraytrace 1' alias for 'vrenderparams -rayTrace'.",
__FILE__, VRenderParams, group);
"\n '-reflections on|off' Enables/disables specular reflections"
"\n '-fsaa on|off' Enables/disables adaptive anti-aliasing"
"\n '-gleam on|off' Enables/disables transparency shadow effects"
+ "\n '-gi on|off' Enables/disables global illumination effects"
+ "\n '-brng on|off' Enables/disables blocked RNG (fast coherent PT)"
+ "\n '-env on|off' Enables/disables environment map background"
"\n '-shadingModel model' Controls shading model from enumeration"
"\n color, flat, gouraud, phong"
"\n Unlike vcaps, these parameters dramatically change visual properties."
"vxrotate",
__FILE__,VXRotate,group);
+#if defined(_WIN32)
+ theCommands.Add("vprogressive",
+ "vprogressive",
+ __FILE__, VProgressiveMode, group);
+#endif
}