mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-29 14:00:49 +03:00
Compare commits
4 Commits
V7_8_1
...
CR0_robins
Author | SHA1 | Date | |
---|---|---|---|
|
427da5f6b9 | ||
|
3d1ab9a4df | ||
|
d6c2c82034 | ||
|
b4880d3d23 |
2104
src/AIS/AIS_ViewCube.cxx
Normal file
2104
src/AIS/AIS_ViewCube.cxx
Normal file
File diff suppressed because it is too large
Load Diff
1059
src/AIS/AIS_ViewCube.hxx
Normal file
1059
src/AIS/AIS_ViewCube.hxx
Normal file
File diff suppressed because it is too large
Load Diff
@@ -174,3 +174,5 @@ AIS_TypeOfAxis.hxx
|
||||
AIS_TypeOfDist.hxx
|
||||
AIS_TypeOfIso.hxx
|
||||
AIS_TypeOfPlane.hxx
|
||||
AIS_ViewCube.hxx
|
||||
AIS_ViewCube.cxx
|
||||
|
@@ -495,23 +495,26 @@ void OpenGl_GraphicDriver::EnableVBO (const Standard_Boolean theToTurnOn)
|
||||
// function : GetSharedContext
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const Handle(OpenGl_Context)& OpenGl_GraphicDriver::GetSharedContext() const
|
||||
const Handle(OpenGl_Context)& OpenGl_GraphicDriver::GetSharedContext (bool theBound) const
|
||||
{
|
||||
if (myMapOfView.IsEmpty())
|
||||
{
|
||||
return TheNullGlCtx;
|
||||
}
|
||||
|
||||
NCollection_Map<Handle(OpenGl_View)>::Iterator anIter (myMapOfView);
|
||||
for (; anIter.More(); anIter.Next())
|
||||
for (NCollection_Map<Handle(OpenGl_View)>::Iterator aViewIter (myMapOfView); aViewIter.More(); aViewIter.Next())
|
||||
{
|
||||
Handle(OpenGl_Window) aWindow = anIter.Value()->GlWindow();
|
||||
if (aWindow.IsNull())
|
||||
if (const Handle(OpenGl_Window)& aWindow = aViewIter.Value()->GlWindow())
|
||||
{
|
||||
continue;
|
||||
if (!theBound)
|
||||
{
|
||||
return aWindow->GetGlContext();
|
||||
}
|
||||
else if (aWindow->GetGlContext()->IsCurrent())
|
||||
{
|
||||
return aWindow->GetGlContext();
|
||||
}
|
||||
}
|
||||
|
||||
return aWindow->GetGlContext();
|
||||
}
|
||||
|
||||
return TheNullGlCtx;
|
||||
|
@@ -183,7 +183,9 @@ public:
|
||||
|
||||
//! Method to retrieve valid GL context.
|
||||
//! Could return NULL-handle if no window created by this driver.
|
||||
Standard_EXPORT const Handle(OpenGl_Context)& GetSharedContext() const;
|
||||
//! @param theBound if TRUE then currently bound context will be returned,
|
||||
//! any context will be returned otherwise
|
||||
Standard_EXPORT const Handle(OpenGl_Context)& GetSharedContext (bool theBound = false) const;
|
||||
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__)
|
||||
Aspect_Display getRawGlDisplay() const { return myEglDisplay; }
|
||||
|
@@ -109,6 +109,9 @@ public:
|
||||
//! correspondingly) onto far view frustum plane
|
||||
virtual gp_Pnt GetFarPickedPnt() const = 0;
|
||||
|
||||
//! Return mouse coordinates for Point selection mode.
|
||||
virtual gp_Pnt2d GetMousePosition() const = 0;
|
||||
|
||||
//! Stores plane equation coefficients (in the following form:
|
||||
//! Ax + By + Cz + D = 0) to the given vector
|
||||
virtual void GetPlanes (NCollection_Vector<NCollection_Vec4<Standard_Real> >& thePlaneEquations) const = 0;
|
||||
|
@@ -133,6 +133,9 @@ public:
|
||||
//! correspondingly) onto far view frustum plane
|
||||
inline const gp_Pnt& GetFarPnt() const { return myFarPickedPnt; }
|
||||
|
||||
//! Return mouse coordinates.
|
||||
const gp_Pnt2d& GetMousePosition() const { return myMousePos; }
|
||||
|
||||
//! Stores plane equation coefficients (in the following form:
|
||||
//! Ax + By + Cz + D = 0) to the given vector
|
||||
Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE;
|
||||
|
@@ -196,6 +196,17 @@ public:
|
||||
//! correspondingly) onto far view frustum plane
|
||||
Standard_EXPORT virtual gp_Pnt GetFarPickedPnt() const Standard_OVERRIDE;
|
||||
|
||||
//! Return mouse coordinates for Point selection mode.
|
||||
virtual gp_Pnt2d GetMousePosition() const Standard_OVERRIDE
|
||||
{
|
||||
if (myActiveSelectionType != Point)
|
||||
{
|
||||
return gp_Pnt2d (RealLast(), RealLast());
|
||||
}
|
||||
const SelectMgr_RectangularFrustum* aFr = reinterpret_cast<const SelectMgr_RectangularFrustum*> (mySelectingVolumes[myActiveSelectionType / 2].get());
|
||||
return aFr->GetMousePosition();
|
||||
}
|
||||
|
||||
//! Returns active selecting volume that was built during last
|
||||
//! run of OCCT selection mechanism
|
||||
Handle(SelectMgr_BaseFrustum) ActiveVolume() const
|
||||
|
@@ -81,6 +81,11 @@ void SelectMgr_ViewerSelector::updatePoint3d (SelectMgr_SortCriterion& theCriter
|
||||
{
|
||||
theCriterion.Point = thePickResult.PickedPoint();
|
||||
}
|
||||
else if (!thePickResult.IsValid())
|
||||
{
|
||||
theCriterion.Point = thePickResult.PickedPoint();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
theCriterion.Point = theMgr.DetectedPoint (theCriterion.Depth);
|
||||
@@ -106,7 +111,7 @@ void SelectMgr_ViewerSelector::updatePoint3d (SelectMgr_SortCriterion& theCriter
|
||||
}
|
||||
else
|
||||
{
|
||||
const Standard_Real aDistFromEye = (theCriterion.Point.XYZ() - myCameraEye.XYZ()).Dot (myCameraDir.XYZ());
|
||||
const Standard_Real aDistFromEye = Abs ((theCriterion.Point.XYZ() - myCameraEye.XYZ()).Dot (myCameraDir.XYZ()));
|
||||
theCriterion.Tolerance = aDistFromEye * myCameraScale * theEntity->SensitivityFactor();
|
||||
}
|
||||
}
|
||||
|
@@ -6046,6 +6046,170 @@ static int VNormals (Draw_Interpretor& theDI,
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//=======================================================================
|
||||
|
||||
static bool LoadLidarData (const char* theScanFile, const char* thePosFile, std::vector<gp_Pnt>& theResult)
|
||||
{
|
||||
FILE* aScanFile = fopen (theScanFile, "rb");
|
||||
if (! aScanFile)
|
||||
{
|
||||
std::cerr << "Error: cannot open " << theScanFile << std::endl;
|
||||
return false;
|
||||
}
|
||||
FILE* aPosFile = fopen (thePosFile, "rb");
|
||||
if (! aPosFile)
|
||||
{
|
||||
fclose (aScanFile);
|
||||
std::cerr << "Error: cannot open " << thePosFile << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// prepare array of sin & cos values for conversion from polar coordinates
|
||||
// to cartesian ones; we take X directed along mid-range laser scan
|
||||
const int aNbPointsPerLine = 1081;
|
||||
double aStepDeg = 0.25;
|
||||
double aStartDeg = -90. - 45.;
|
||||
double aSinVal[aNbPointsPerLine], aCosVal[aNbPointsPerLine];
|
||||
for (int i = 0; i < aNbPointsPerLine; i++)
|
||||
{
|
||||
double anAngle = (aStartDeg + i * aStepDeg) * M_PI / 180.;
|
||||
aSinVal[i] = Sin (anAngle);
|
||||
aCosVal[i] = Cos (anAngle);
|
||||
}
|
||||
|
||||
// read both files synchronously
|
||||
for (int nLine = 1; ; nLine++)
|
||||
{
|
||||
char aScanLine[1024 * 100];
|
||||
bool hasScan = (fgets (aScanLine, sizeof(aScanLine), aScanFile) == aScanLine);
|
||||
char aPosLine[1024];
|
||||
bool hasPos = (fgets (aPosLine, sizeof(aPosLine), aPosFile) == aPosLine);
|
||||
if (! hasPos || ! hasScan)
|
||||
{
|
||||
if (hasPos && strlen (aPosLine) > 0)
|
||||
std::cerr << "Warning: Positions file contains more lines than scan file" << std::endl;
|
||||
if (hasScan && strlen (aScanLine) > 0)
|
||||
std::cerr << "Warning: Scan file contains more lines than positions file" << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
// parse position line
|
||||
char *aStr = aPosLine, *aNext = 0;
|
||||
double aPosTime = Strtod (aStr, &aNext);
|
||||
if (aNext == aStr)
|
||||
{
|
||||
std::cerr << "Warning: cannot fetch timestamp for position at line " << nLine << std::endl;
|
||||
}
|
||||
|
||||
gp_Trsf aTrsf;
|
||||
double aX = Strtod(aStr = aNext, &aNext);
|
||||
double aY = Strtod(aStr = aNext, &aNext);
|
||||
double aZ = Strtod(aStr = aNext, &aNext);
|
||||
double aA = Strtod(aStr = aNext, &aNext);
|
||||
double aB = Strtod(aStr = aNext, &aNext);
|
||||
double aC = Strtod(aStr = aNext, &aNext);
|
||||
if (aNext == aStr)
|
||||
{
|
||||
std::cerr << "Error: position line " << nLine << " contains less than 7 values, default positiomn will be used" << std::endl;
|
||||
}
|
||||
else {
|
||||
gp_Quaternion aQ;
|
||||
// aQ.SetEulerAngles(gp_Intrinsic_XYZ, aA, aB, aC);
|
||||
// aQ.SetEulerAngles(gp_Intrinsic_ZYX, aA, aB, aC);
|
||||
aQ.SetEulerAngles(gp_Intrinsic_ZYX, aC, aB, aA);
|
||||
aTrsf.SetRotation(aQ);
|
||||
aTrsf.SetTranslationPart(gp_Vec(aX, aY, aZ));
|
||||
}
|
||||
|
||||
// parse scan line
|
||||
aStr = aScanLine;
|
||||
double aScanTime = Strtod (aStr, &aNext);
|
||||
if (aNext == aStr)
|
||||
{
|
||||
std::cerr << "Warning: cannot fetch timestamp for scan line " << nLine << std::endl;
|
||||
}
|
||||
if (aPosTime && aScanTime && Abs (aPosTime - aScanTime) > 0.001)
|
||||
{
|
||||
std::cerr << "Warning: timestamps at scan and position data are differenr at line " << nLine << std::endl;
|
||||
std::cerr << " - position timestamp: " << aPosTime << std::endl;
|
||||
std::cerr << " - scanline timestamp: " << aScanTime << std::endl;
|
||||
}
|
||||
|
||||
for (int i = 0; i < aNbPointsPerLine; i++)
|
||||
{
|
||||
double aDist = Strtod (aStr = aNext, &aNext);
|
||||
if (aNext == aStr)
|
||||
{
|
||||
std::cerr << "Warning: scan line " << nLine << " contains only " << i << " values" << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
// skip nans (no value), distances too small (local object on the drone),
|
||||
// and distances greater than maximal valid range of LIDAR
|
||||
if (std::isnan (aDist) || aDist < 0.5 || aDist > 30.)
|
||||
continue;
|
||||
|
||||
// add a point
|
||||
gp_Pnt aPoint (aDist * aSinVal[i], aDist * aCosVal[i], 0.);
|
||||
theResult.push_back (aPoint.Transformed (aTrsf));
|
||||
}
|
||||
while (IsSpace (*aNext)) aNext++;
|
||||
if (*aNext)
|
||||
std::cerr << "Warning: extra symbols at the end of the scan line " << nLine << std::endl;
|
||||
}
|
||||
|
||||
fclose(aScanFile);
|
||||
fclose(aPosFile);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<gp_Pnt> aLIDARPoints;
|
||||
|
||||
static int LoadLIDAR (Draw_Interpretor& theDI, Standard_Integer theArgNum, const char** theArgs)
|
||||
{
|
||||
aLIDARPoints.clear();
|
||||
|
||||
if (theArgNum < 3)
|
||||
{
|
||||
std::cerr << "Use: " << theArgs[0] << " lidar_data_file positions_file" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (LoadLidarData (theArgs[1], theArgs[2], aLIDARPoints))
|
||||
{
|
||||
theDI << (int)aLIDARPoints.size() << " points loaded";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int SaveLIDAR (Draw_Interpretor& theDI, Standard_Integer theArgNum, const char** theArgs)
|
||||
{
|
||||
if (theArgNum < 2)
|
||||
{
|
||||
std::cerr << "Use: " << theArgs[0] << " ply_data_file " << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
ofstream aFile (theArgs[1], std::ios_base::out);
|
||||
aFile << "ply\nformat ascii 1.0\n";
|
||||
aFile << "element vertex " << aLIDARPoints.size() << "\n";
|
||||
aFile << "property float x\n";
|
||||
aFile << "property float y\n";
|
||||
aFile << "property float z\n";
|
||||
aFile << "end_header\n";
|
||||
for (unsigned int i = 0; i < aLIDARPoints.size(); i++)
|
||||
{
|
||||
const gp_Pnt& aPnt = aLIDARPoints[i];
|
||||
aFile << aPnt.X() << " " << aPnt.Y() << " " << aPnt.Z() << "\n";
|
||||
}
|
||||
theDI << "Points saved to " << theArgs[1];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ObjectsCommands
|
||||
//purpose :
|
||||
@@ -6386,4 +6550,7 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: [-useMesh] [-oriented {0}1}=0]"
|
||||
"\n\t\t: Displays/Hides normals calculated on shape geometry or retrieved from triangulation",
|
||||
__FILE__, VNormals, group);
|
||||
|
||||
theCommands.Add ("loadlidar", "loadlidar scan_file positions_file", __FILE__, LoadLIDAR, group);
|
||||
theCommands.Add ("savelidar", "savelidar ply_file", __FILE__, SaveLIDAR, group);
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <AIS_ListOfInteractive.hxx>
|
||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||
#include <AIS_ViewCube.hxx>
|
||||
#include <Aspect_Grid.hxx>
|
||||
#include <DBRep.hxx>
|
||||
#include <Draw_ProgressIndicator.hxx>
|
||||
@@ -287,6 +288,25 @@ Standard_EXPORT Handle(AIS_Manipulator) GetActiveAISManipulator()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
typedef NCollection_DataMap<Handle(V3d_View), Handle(AIS_ViewCube)> ViewerTest_MapOfViewCube;
|
||||
|
||||
Standard_EXPORT ViewerTest_MapOfViewCube& MapOfViewCube()
|
||||
{
|
||||
static ViewerTest_MapOfViewCube aViewMap;
|
||||
return aViewMap;
|
||||
}
|
||||
|
||||
Standard_EXPORT Handle(AIS_ViewCube) ActiveViewCube()
|
||||
{
|
||||
Handle(AIS_ViewCube) aCube;
|
||||
if (MapOfViewCube().Find (ViewerTest::CurrentView(), aCube))
|
||||
{
|
||||
return aCube;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -12345,6 +12365,215 @@ static int VDumpSelectionImage (Draw_Interpretor& /*theDi*/,
|
||||
return 0;
|
||||
}
|
||||
|
||||
//===============================================================================================
|
||||
//function : VViewCube
|
||||
//purpose :
|
||||
//===============================================================================================
|
||||
static int VViewCube (Draw_Interpretor& theDi,
|
||||
Standard_Integer theArgsNb,
|
||||
const char** theArgVec)
|
||||
{
|
||||
if (theArgsNb < 2)
|
||||
{
|
||||
std::cout << "Syntax error: wrong number arguments for '" << theArgVec[0] << "'\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext();
|
||||
const Handle(V3d_View)& aView = ViewerTest::CurrentView();
|
||||
if (aContext.IsNull() || aView.IsNull())
|
||||
{
|
||||
std::cout << "Error: no active view.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
ViewerTest_AutoUpdater anUpdateTool (aContext, aView);
|
||||
Standard_Integer anArgIter = 1;
|
||||
for (; anArgIter < theArgsNb; ++anArgIter)
|
||||
{
|
||||
anUpdateTool.parseRedrawMode (theArgVec[anArgIter]);
|
||||
}
|
||||
|
||||
Handle(AIS_ViewCube) aViewCube;
|
||||
ViewerTest_CmdParser aCmd;
|
||||
aCmd.AddDescription ("vviewcube Name [options]. Commmand manages View Cube object:");
|
||||
aCmd.AddOption ("enable", "enables view cube");
|
||||
aCmd.AddOption ("disable", "disables view cube");
|
||||
aCmd.AddOption ("remove", "removes view cube presentation from context and view");
|
||||
aCmd.AddOption ("remove", "removes view cube presentation from context and view");
|
||||
aCmd.AddOption ("reset", "reset geomertical and visual attributes");
|
||||
aCmd.AddOption ("size", "... size - set size of View Cube");
|
||||
aCmd.AddOption ("adaptsize", " - adapt all another parameters to input size");
|
||||
aCmd.AddOption ("color", "... r g b - set color of View Cube ");
|
||||
aCmd.AddOption ("boxcolor", "... r g b - set box color of view cube");
|
||||
aCmd.AddOption ("arrowcolor", "... r g b - set arrow color of view cube");
|
||||
aCmd.AddOption ("textcolor", "... r g b - set side text color of view cube");
|
||||
aCmd.AddOption ("innercolor", "... r g b - set inner box color of view cube");
|
||||
aCmd.AddOption ("arrowangle", "... value - set pointer angle of arrows in radians");
|
||||
aCmd.AddOption ("arrowlength", "... value - set length of arrows");
|
||||
aCmd.AddOption ("arrowpadding", "... value - set padding between axis and arrows");
|
||||
aCmd.AddOption ("transparency", "... [0;1] - set transparency of object");
|
||||
aCmd.AddOption ("boxtransparency", "... [0;1] - set transparency of box in View Cube");
|
||||
aCmd.AddOption ("arrowtransparency", "... [0;1] - set transparency of arrows in View Cube");
|
||||
aCmd.AddOption ("font", "... string - set font name");
|
||||
aCmd.AddOption ("fontheight", "... value - set font height");
|
||||
aCmd.AddOption ("boxpadding", "... value - set padding between box sides");
|
||||
aCmd.AddOption ("axispadding", "... value - set padding between box and arrows");
|
||||
aCmd.AddOption ("cornerradius", "... value - set radius of side corners in [0;0.5] (0-50% of box side size)");
|
||||
aCmd.AddOption ("hideedges", " - hide edges of View Cube");
|
||||
aCmd.AddOption ("showedges", " - show edges of View Cube");
|
||||
aCmd.AddOption ("hidevertices", " - hide vertices ov View Cube");
|
||||
aCmd.AddOption ("showvertices", " - show vertices ov View Cube");
|
||||
aCmd.AddOption ("position", "... PixX PixY - 2D position of View Cube from top left corner");
|
||||
|
||||
aCmd.Parse (theArgsNb, theArgVec);
|
||||
|
||||
if (aCmd.HasOption ("help"))
|
||||
{
|
||||
theDi.PrintHelp (theArgVec[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get current view cube entity
|
||||
aViewCube = ActiveViewCube();
|
||||
if (aViewCube.IsNull())
|
||||
{
|
||||
aViewCube = new AIS_ViewCube();
|
||||
MapOfViewCube().Bind (aView, aViewCube);
|
||||
aViewCube->SetAutoTransform (Standard_True);
|
||||
}
|
||||
|
||||
if (aCmd.HasOption ("color"))
|
||||
{
|
||||
aViewCube->SetColor (Quantity_Color (aCmd.ArgVec3f ("color")));
|
||||
}
|
||||
if (aCmd.HasOption ("boxcolor"))
|
||||
{
|
||||
aViewCube->SetBoxColor (Quantity_Color (aCmd.ArgVec3f ("boxcolor")));
|
||||
}
|
||||
if (aCmd.HasOption ("arrowcolor"))
|
||||
{
|
||||
aViewCube->SetArrowColor (Quantity_Color (aCmd.ArgVec3f ("arrowcolor")));
|
||||
}
|
||||
if (aCmd.HasOption ("textcolor"))
|
||||
{
|
||||
aViewCube->SetTextColor (Quantity_Color (aCmd.ArgVec3f ("textcolor")));
|
||||
}
|
||||
if (aCmd.HasOption ("innercolor"))
|
||||
{
|
||||
aViewCube->SetInnerColor (Quantity_Color (aCmd.ArgVec3f ("innercolor")));
|
||||
}
|
||||
if (aCmd.HasOption ("arrowangle"))
|
||||
{
|
||||
aViewCube->SetArrowAngle (aCmd.ArgDouble ("arrowangle") * M_PI / 180.0);
|
||||
}
|
||||
if (aCmd.HasOption ("arrowlength"))
|
||||
{
|
||||
aViewCube->SetArrowLength (aCmd.ArgDouble ("arrowlength"));
|
||||
}
|
||||
if (aCmd.HasOption ("arrowpadding"))
|
||||
{
|
||||
aViewCube->SetArrowPadding (aCmd.ArgDouble ("arrowpadding"));
|
||||
}
|
||||
if (aCmd.HasOption ("transparency"))
|
||||
{
|
||||
aViewCube->SetTransparency (aCmd.ArgDouble ("transparency"));
|
||||
}
|
||||
if (aCmd.HasOption ("boxtransparency"))
|
||||
{
|
||||
aViewCube->SetBoxTransparency (aCmd.ArgDouble ("boxtransparency"));
|
||||
}
|
||||
if (aCmd.HasOption ("arrowtransparency"))
|
||||
{
|
||||
aViewCube->SetArrowTransparency (aCmd.ArgDouble ("arrowtransparency"));
|
||||
}
|
||||
if (aCmd.HasOption ("font"))
|
||||
{
|
||||
aViewCube->SetFont (aCmd.Arg ("font", 0).c_str());
|
||||
}
|
||||
if (aCmd.HasOption ("fontheight"))
|
||||
{
|
||||
aViewCube->SetFontHeight (aCmd.ArgDouble ("fontheight", 0));
|
||||
}
|
||||
if (aCmd.HasOption ("boxpadding"))
|
||||
{
|
||||
aViewCube->SetBoxPadding (aCmd.ArgDouble ("boxpadding"));
|
||||
}
|
||||
if (aCmd.HasOption ("axispadding"))
|
||||
{
|
||||
aViewCube->SetAxisPadding (aCmd.ArgDouble ("axispadding"));
|
||||
}
|
||||
if (aCmd.HasOption ("cornerradius"))
|
||||
{
|
||||
aViewCube->SetCornerRadius (aCmd.ArgDouble ("cornerradius"));
|
||||
}
|
||||
if (aCmd.HasOption ("hideedges"))
|
||||
{
|
||||
aViewCube->SetDrawEdges (Standard_False);
|
||||
}
|
||||
if (aCmd.HasOption ("showedges"))
|
||||
{
|
||||
aViewCube->SetDrawEdges (Standard_True);
|
||||
}
|
||||
if (aCmd.HasOption ("hidevertices"))
|
||||
{
|
||||
aViewCube->SetDrawVertices (Standard_False);
|
||||
}
|
||||
if (aCmd.HasOption ("showvertices"))
|
||||
{
|
||||
aViewCube->SetDrawVertices (Standard_True);
|
||||
}
|
||||
if (aCmd.HasOption ("position", 2))
|
||||
{
|
||||
aViewCube->SetPosition (Graphic3d_Vec2i (aCmd.ArgInt ("position", 0), aCmd.ArgInt ("position", 1)),
|
||||
aView);
|
||||
}
|
||||
if (aCmd.HasOption ("size"))
|
||||
{
|
||||
aViewCube->SetSize (aCmd.ArgDouble ("size", 0), aCmd.HasOption ("adaptsize"));
|
||||
}
|
||||
if (aCmd.HasOption ("reset"))
|
||||
{
|
||||
aViewCube->Reset();
|
||||
}
|
||||
|
||||
// Enable View Cube for current view
|
||||
if (aCmd.HasOption ("enable") && !aContext->IsDisplayed (aViewCube))
|
||||
{
|
||||
aContext->MainSelector()->SetPickClosest (Standard_False);
|
||||
if (aViewCube->View().IsNull())
|
||||
{
|
||||
aViewCube->SetView (aView);
|
||||
aViewCube->AddTo (aContext, aView);
|
||||
}
|
||||
else
|
||||
{
|
||||
aViewCube->Show();
|
||||
}
|
||||
}
|
||||
else if (aCmd.HasOption ("disable") && aContext->IsDisplayed (aViewCube))
|
||||
{
|
||||
ViewerTest::GetAISContext()->MainSelector()->SetPickClosest (Standard_True);
|
||||
aViewCube->Hide();
|
||||
}
|
||||
else if (aCmd.HasOption ("remove") && aContext->IsDisplayed (aViewCube))
|
||||
{
|
||||
ViewerTest::GetAISContext()->MainSelector()->SetPickClosest (Standard_True);
|
||||
MapOfViewCube().UnBind (aViewCube->View());
|
||||
aContext->Remove (aViewCube, Standard_False);
|
||||
}
|
||||
else
|
||||
{
|
||||
TColStd_ListOfInteger aModes;
|
||||
aViewCube->ToBeUpdated (aModes);
|
||||
if (!aModes.IsEmpty())
|
||||
{
|
||||
aContext->Redisplay (aViewCube, Standard_False);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : ViewerCommands
|
||||
//purpose :
|
||||
@@ -13063,4 +13292,39 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"vprogressive",
|
||||
__FILE__, VProgressiveMode, group);
|
||||
#endif
|
||||
|
||||
theCommands.Add ("vviewcube",
|
||||
"\n vviewcube [-enable|-disable]"
|
||||
"\n Warning: after end pf test please call vviewcube -remove, otherwise View Cube will hold down active view from closing"
|
||||
"\n tool to create and manage interactive view manipualtion object for active view."
|
||||
"\n Options: "
|
||||
"\n '-enable|disable' display/erase view cube with defined visual options"
|
||||
"\n '-reset reset geomertical and visual attributes'"
|
||||
"\n '-size Value' adjust position when attaching"
|
||||
"\n '-adaptSize' call with -size to adapt all part to size of 3D box"
|
||||
"\n 'remove' removes view cube presentation from context and view"
|
||||
"\n 'size Size' set size of View Cube"
|
||||
"\n 'color R G B' set color of View Cube in limits [0;1]"
|
||||
"\n 'boxcolor R G B' set box color of view cube in limits [0;1]"
|
||||
"\n 'arrowcolor R G B' set arrow color of view cube in limits [0;1]"
|
||||
"\n 'textcolor R G B' set color of side text of view cube in limits [0;1]"
|
||||
"\n 'innercolor R G B' set inner box color of view cube in limits [0;1]"
|
||||
"\n 'arrowangle Value' set pointer angle of arrows in radians"
|
||||
"\n 'arrowlength Value' set length of arrows"
|
||||
"\n 'arrowpadding Value' set padding between axis and arrows"
|
||||
"\n 'transparency [0;1]' set transparency of object"
|
||||
"\n 'boxtransparency [0;1]' set transparency of box in View Cube"
|
||||
"\n 'arrowtransparency [0;1]' set transparency of arrows in View Cube"
|
||||
"\n 'font Name' set font name"
|
||||
"\n 'fontheight value' set font height"
|
||||
"\n 'boxpadding Value' set padding between box sides"
|
||||
"\n 'axispadding Value' set padding between box and arrows"
|
||||
"\n 'cornerradius Value' set radius of corners of sides"
|
||||
"\n 'hideedges' hide edges of View Cube"
|
||||
"\n 'showedges' show edges of View Cube"
|
||||
"\n 'hidevertices' hide vertices ov View Cube"
|
||||
"\n 'showvertices' show vertices ov View Cube"
|
||||
"\n 'position XPix YPix' 2D position of View Cube from top left corner",
|
||||
__FILE__, VViewCube, group);
|
||||
|
||||
}
|
||||
|
64
tests/v3d/viewcube/default
Normal file
64
tests/v3d/viewcube/default
Normal file
@@ -0,0 +1,64 @@
|
||||
puts "=================================="
|
||||
puts "AIS_ViewCube - display and erase with default settings"
|
||||
puts "=================================="
|
||||
|
||||
set anImage1 $imagedir/${casename}_1.png
|
||||
set anImage2 $imagedir/${casename}_2.png
|
||||
set anImage3 $imagedir/${casename}_3.png
|
||||
set anImage4 $imagedir/${casename}_4.png
|
||||
|
||||
vclear
|
||||
vclose ALL
|
||||
vinit
|
||||
# -------------------------------------
|
||||
# create helper object
|
||||
# -------------------------------------
|
||||
box aBox1 15 20 70
|
||||
vdisplay aBox1 -dispMode 1
|
||||
vaxo
|
||||
vfit
|
||||
|
||||
# -------------------------------------
|
||||
# display view cube object
|
||||
# -------------------------------------
|
||||
vviewcube -enable -size 70 -adaptsize -position 120 250
|
||||
|
||||
vmoveto 118 230
|
||||
if {[vreadpixel 118 230 name] != "DARKTURQUOISE 1"} {
|
||||
puts "ERROR: Highlighting of view cube side is wrong."
|
||||
}
|
||||
vmoveto 0 0
|
||||
vdump $anImage1
|
||||
|
||||
# -------------------------------------
|
||||
# Check side
|
||||
# -------------------------------------
|
||||
vselect 125 200
|
||||
if {[vreadpixel 115 233 name] != "GRAY95 1"} {
|
||||
puts "ERROR: Display of view cube is wrong."
|
||||
}
|
||||
if {[vreadpixel 190 136 name] != "IVORY 1"} {
|
||||
puts "ERROR: Position of TOP camera is wrong."
|
||||
}
|
||||
vdump $anImage2
|
||||
|
||||
# -------------------------------------
|
||||
# Check edge
|
||||
# -------------------------------------
|
||||
vselect 163 242
|
||||
if {[vreadpixel 141 234 name] != "GRAY76 1"} {
|
||||
puts "ERROR: Position of TOP-RIGHT camera is wrong."
|
||||
}
|
||||
vdump $anImage3
|
||||
|
||||
# -------------------------------------
|
||||
# Check vertex
|
||||
# -------------------------------------
|
||||
vselect 121 213
|
||||
if {[vreadpixel 120 250 name] != "GRAY95 1"} {
|
||||
puts "ERROR: Position of TOP-RIGHT-BACK camera is wrong."
|
||||
}
|
||||
vdump $anImage4
|
||||
|
||||
vviewcube -remove
|
||||
vclear
|
46
tests/v3d/viewcube/move
Normal file
46
tests/v3d/viewcube/move
Normal file
@@ -0,0 +1,46 @@
|
||||
puts "=================================="
|
||||
puts "AIS_ViewCube - check positioning of View Cube"
|
||||
puts "=================================="
|
||||
|
||||
set anImage1 $imagedir/${casename}_1.png
|
||||
set anImage2 $imagedir/${casename}_2.png
|
||||
set anImage3 $imagedir/${casename}_3.png
|
||||
set anImage4 $imagedir/${casename}_4.png
|
||||
|
||||
vclear
|
||||
vclose ALL
|
||||
vinit
|
||||
|
||||
# -------------------------------------
|
||||
# display view cube object
|
||||
# -------------------------------------
|
||||
vviewcube -enable -size 70 -adaptsize
|
||||
|
||||
# -------------------------------------
|
||||
# check positioning of view cube object
|
||||
# -------------------------------------
|
||||
if {[vreadpixel 96 285 name] != "GRAY68 1"} {
|
||||
puts "ERROR: Bottom left View Cube fails."
|
||||
}
|
||||
vdump $anImage1
|
||||
|
||||
vviewcube -position 200 200
|
||||
if {[vreadpixel 200 176 name] != "GRAY68 1"} {
|
||||
puts "ERROR: Center View Cube fails."
|
||||
}
|
||||
vdump $anImage2
|
||||
|
||||
vviewcube -position 310 100
|
||||
if {[vreadpixel 310 73 name] != "GRAY68 1"} {
|
||||
puts "ERROR: Top right View Cube fails."
|
||||
}
|
||||
vdump $anImage3
|
||||
|
||||
vviewcube -position 140 240
|
||||
if {[vreadpixel 140 217 name] != "GRAY68 1"} {
|
||||
puts "ERROR: Custom View Cube fails."
|
||||
}
|
||||
vdump $anImage4
|
||||
|
||||
vviewcube -remove
|
||||
vclear
|
33
tests/v3d/viewcube/part
Normal file
33
tests/v3d/viewcube/part
Normal file
@@ -0,0 +1,33 @@
|
||||
puts "====================================="
|
||||
puts "AIS_ViewCube - test custom appearance"
|
||||
puts "====================================="
|
||||
|
||||
set anImage1 $imagedir/${casename}_1.png
|
||||
set anImage2 $imagedir/${casename}_2.png
|
||||
set anImage3 $imagedir/${casename}_3.png
|
||||
|
||||
vclear
|
||||
vclose ALL
|
||||
vinit
|
||||
|
||||
vviewcube -enable -hideedges
|
||||
if {[vreadpixel 186 236 name] != "BLACK 0"} {
|
||||
puts "ERROR: Invalid display of View Cube without edges."
|
||||
}
|
||||
vdump $anImage1
|
||||
|
||||
vviewcube -showedges -hidevertices
|
||||
if {[vreadpixel 150 258 name] != "BLACK 0"} {
|
||||
puts "ERROR: Invalid display of View Cube without vertices."
|
||||
}
|
||||
vdump $anImage2
|
||||
|
||||
vviewcube -hideedges -hidevertices
|
||||
|
||||
if {[vreadpixel 186 236 name] != "BLACK 0" || [vreadpixel 150 258 name] != "BLACK 0"} {
|
||||
puts "ERROR: Invalid display of View Cube without edges & vertices."
|
||||
}
|
||||
vdump $anImage3
|
||||
|
||||
vviewcube -remove
|
||||
vclear
|
84
tests/v3d/viewcube/style
Normal file
84
tests/v3d/viewcube/style
Normal file
@@ -0,0 +1,84 @@
|
||||
puts "=================================="
|
||||
puts "AIS_ViewCube - display custom styled View Cube"
|
||||
puts "=================================="
|
||||
|
||||
set anImage1 $imagedir/${casename}_1.png
|
||||
set anImage2 $imagedir/${casename}_2.png
|
||||
set anImage3 $imagedir/${casename}_3.png
|
||||
set anImage4 $imagedir/${casename}_4.png
|
||||
set anImage5 $imagedir/${casename}_5.png
|
||||
set anImage6 $imagedir/${casename}_6.png
|
||||
set anImage7 $imagedir/${casename}_7.png
|
||||
vclear
|
||||
vclose ALL
|
||||
vinit
|
||||
|
||||
# -------------------------------------
|
||||
# Color
|
||||
# -------------------------------------
|
||||
vviewcube -enable -boxcolor 0.69 0.88 1 -arrowcolor 0 0.4 0.54 -textcolor 0 0.4 0.54
|
||||
if {[vreadpixel 118 273 name] != "LIGHTSLATEGRAY 1" || [vreadpixel 270 260 name] != "GRAY15 0.24705882370471954"} {
|
||||
puts "ERROR: Errors in changing View Cube colors."
|
||||
}
|
||||
vdump $anImage1
|
||||
|
||||
# -------------------------------------
|
||||
# Transparency
|
||||
# -------------------------------------
|
||||
vviewcube -reset
|
||||
vviewcube -transparency 0.5
|
||||
if {[vreadpixel 118 273 name] != "GRAY17 0.37254902720451355" || [vreadpixel 270 260 name] != "GRAY48 0.24705882370471954"} {
|
||||
puts "ERROR: Errors in changing View Cube common transparency."
|
||||
}
|
||||
vdump $anImage2
|
||||
|
||||
vviewcube -reset
|
||||
vviewcube -boxtransparency 0.4 -arrowtransparency 0.2
|
||||
if {[vreadpixel 118 273 name] != "GRAY16 0.5058823823928833" || [vreadpixel 270 260 name] != "GRAY76 0.63921570777893066"} {
|
||||
puts "ERROR: Errors in changing View Cube separate transparency."
|
||||
}
|
||||
vdump $anImage3
|
||||
|
||||
# -------------------------------------
|
||||
# Arrows
|
||||
# -------------------------------------
|
||||
vviewcube -reset
|
||||
vviewcube -arrowangle 30 -arrowlength 30
|
||||
if {[vreadpixel 270 268 name] != "BLACK 0" || [vreadpixel 291 259 name] != "GRAY48 0.24705882370471954"} {
|
||||
puts "ERROR: Errors in changing View Cube arrow style."
|
||||
}
|
||||
vdump $anImage4
|
||||
|
||||
# -------------------------------------
|
||||
# Font
|
||||
# -------------------------------------
|
||||
vviewcube -reset
|
||||
vviewcube -font "Impact" -fontheight 16
|
||||
if {[vreadpixel 150 200 name] != "BLACK 0.729411780834198" || [vreadpixel 168 391 name] != "RED 1"} {
|
||||
puts "ERROR: Errors in changing View Cube font."
|
||||
}
|
||||
vdump $anImage5
|
||||
# -------------------------------------
|
||||
# Padding
|
||||
# -------------------------------------
|
||||
vviewcube -reset
|
||||
vviewcube -boxpadding 10 -axispadding 20 -arrowpadding 10
|
||||
if {[vreadpixel 71 263 name] != "BLACK 0" || [vreadpixel 37 266 name] != "BLUE2 1"} {
|
||||
puts "ERROR: Errors in changing View Cube padding."
|
||||
}
|
||||
vdump $anImage6
|
||||
# -------------------------------------
|
||||
# Corner radius
|
||||
# -------------------------------------
|
||||
vviewcube -reset
|
||||
vviewcube -cornerradius 0.2
|
||||
vdump $anImage7
|
||||
|
||||
vviewcube -remove
|
||||
vclear
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
28
tests/v3d/viewcube/view
Normal file
28
tests/v3d/viewcube/view
Normal file
@@ -0,0 +1,28 @@
|
||||
puts "=================================="
|
||||
puts "AIS_ViewCube - check view affinity"
|
||||
puts "=================================="
|
||||
|
||||
set anImage1 $imagedir/${casename}_1.png
|
||||
set anImage2 $imagedir/${casename}_2.png
|
||||
|
||||
vclear
|
||||
vclose ALL
|
||||
vinit view1
|
||||
vinit view2
|
||||
|
||||
vviewcube -enable
|
||||
|
||||
if {[vreadpixel 150 220 name] != "GRAY68 1"} {
|
||||
puts "ERROR: display of View Cube in view2 fails."
|
||||
}
|
||||
vdump $anImage1
|
||||
|
||||
vactivate view1
|
||||
|
||||
if {[vreadpixel 150 220 name] != "BLACK 0"} {
|
||||
puts "ERROR: View Cube should not be displayed in view1."
|
||||
}
|
||||
vdump $anImage2
|
||||
|
||||
vactivate view2
|
||||
vviewcube -remove
|
25
tests/v3d/viewcube/view2
Normal file
25
tests/v3d/viewcube/view2
Normal file
@@ -0,0 +1,25 @@
|
||||
puts "=================================="
|
||||
puts "AIS_ViewCube - check view affinity"
|
||||
puts "=================================="
|
||||
|
||||
set anImage1 $imagedir/${casename}_1.png
|
||||
set anImage2 $imagedir/${casename}_2.png
|
||||
|
||||
vclear
|
||||
vclose ALL
|
||||
vinit view1
|
||||
|
||||
vviewcube -enable
|
||||
if {[vreadpixel 150 220 name] != "GRAY68 1"} {
|
||||
puts "ERROR: display of View Cube in view1 fails."
|
||||
}
|
||||
vdump $anImage1
|
||||
vviewcube -remove
|
||||
|
||||
vinit view2
|
||||
vviewcube -enable
|
||||
if {[vreadpixel 150 220 name] != "GRAY68 1"} {
|
||||
puts "ERROR: View Cube should not be displayed in view1."
|
||||
}
|
||||
vdump $anImage2
|
||||
vviewcube -remove
|
Reference in New Issue
Block a user