mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Compare commits
3 Commits
V7_8_1
...
CR0_robins
Author | SHA1 | Date | |
---|---|---|---|
|
645bff3aca | ||
|
886850930b | ||
|
f4e250cd5c |
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
@@ -172,3 +172,5 @@ AIS_TypeOfAxis.hxx
|
||||
AIS_TypeOfDist.hxx
|
||||
AIS_TypeOfIso.hxx
|
||||
AIS_TypeOfPlane.hxx
|
||||
AIS_ViewCube.hxx
|
||||
AIS_ViewCube.cxx
|
||||
|
@@ -77,7 +77,7 @@ void PrsMgr_PresentableObject::Fill (const Handle(PrsMgr_PresentationManager)& t
|
||||
{
|
||||
Handle(Prs3d_Presentation) aStruct3d = thePrs->Presentation();
|
||||
Compute (thePrsMgr, aStruct3d, theMode);
|
||||
UpdateTransformation (aStruct3d);
|
||||
aStruct3d->SetTransformation (myTransformation);
|
||||
aStruct3d->SetClipPlanes (myClipPlanes);
|
||||
aStruct3d->SetTransformPersistence (TransformPersistence());
|
||||
}
|
||||
@@ -296,15 +296,6 @@ void PrsMgr_PresentableObject::UpdateTransformation()
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UpdateTransformation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void PrsMgr_PresentableObject::UpdateTransformation(const Handle(Prs3d_Presentation)& P)
|
||||
{
|
||||
P->SetTransformation (myTransformation);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetTransformPersistence
|
||||
//purpose :
|
||||
|
@@ -157,14 +157,13 @@ public:
|
||||
: getIdentityTrsf(); }
|
||||
|
||||
const gp_GTrsf& InversedTransformation() const { return myInvTransformation; }
|
||||
|
||||
|
||||
//! resets local transformation to identity.
|
||||
Standard_EXPORT virtual void ResetTransformation();
|
||||
|
||||
|
||||
//! Updates final transformation (parent + local) of presentable object and its presentations.
|
||||
Standard_EXPORT virtual void UpdateTransformation();
|
||||
|
||||
Standard_EXPORT virtual void UpdateTransformation (const Handle(Prs3d_Presentation)& P);
|
||||
|
||||
|
||||
//! Set Z layer ID and update all presentations of the presentable object.
|
||||
//! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower layers.
|
||||
Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId);
|
||||
|
@@ -256,6 +256,14 @@ void SelectMgr_SelectableObject::UpdateTransformation()
|
||||
}
|
||||
|
||||
PrsMgr_PresentableObject::UpdateTransformation();
|
||||
if (!mySelectionPrs.IsNull())
|
||||
{
|
||||
mySelectionPrs->SetTransformation (TransformationGeom());
|
||||
}
|
||||
if (!myHilightPrs.IsNull())
|
||||
{
|
||||
myHilightPrs->SetTransformation (TransformationGeom());
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -349,6 +357,7 @@ Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation (c
|
||||
myHilightPrs = new Prs3d_Presentation (theMgr->StructureManager());
|
||||
myHilightPrs->SetTransformPersistence (TransformPersistence());
|
||||
myHilightPrs->SetClipPlanes (myClipPlanes);
|
||||
myHilightPrs->SetTransformation (TransformationGeom());
|
||||
}
|
||||
|
||||
return myHilightPrs;
|
||||
@@ -366,6 +375,7 @@ Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetSelectPresentation (co
|
||||
mySelectionPrs = new Prs3d_Presentation (theMgr->StructureManager());
|
||||
mySelectionPrs->SetTransformPersistence (TransformPersistence());
|
||||
mySelectionPrs->SetClipPlanes (myClipPlanes);
|
||||
mySelectionPrs->SetTransformation (TransformationGeom());
|
||||
}
|
||||
|
||||
return mySelectionPrs;
|
||||
|
@@ -6248,6 +6248,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 :
|
||||
@@ -6605,4 +6769,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);
|
||||
}
|
||||
|
@@ -26,6 +26,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>
|
||||
@@ -286,6 +287,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
|
||||
@@ -11859,6 +11879,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 :
|
||||
@@ -12557,4 +12786,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);
|
||||
|
||||
}
|
||||
|
22
tests/bugs/vis/bug30218
Normal file
22
tests/bugs/vis/bug30218
Normal file
@@ -0,0 +1,22 @@
|
||||
puts "============="
|
||||
puts "0030218: Visualization - custom selection presentation is not updated within SelectMgr_SelectableObject::UpdateTransformation()"
|
||||
puts "============="
|
||||
|
||||
pload XDE VISUALIZATION
|
||||
|
||||
vclear
|
||||
vinit View1
|
||||
meshfromstl m [locate_data_file OCC6652.stl]
|
||||
vfit
|
||||
vzoom 0.75
|
||||
|
||||
vsetdispmode m 3
|
||||
vselmode m 8 1
|
||||
|
||||
vselect 5 5 200 200
|
||||
vlocation m -setLocation 500 0 0
|
||||
vmoveto 370 370
|
||||
if { [vreadpixel 145 145 rgb name] != "BLACK" } { puts "Error: MeshVS highlighting has wrong location" }
|
||||
if { [vreadpixel 300 215 rgb name] != "GRAY80" } { puts "Error: MeshVS highlighting has wrong location" }
|
||||
|
||||
vdump ${imagedir}/${casename}.png
|
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