#include <QADraw.hxx>
#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
-#include <Draw_Window.hxx>
-#include <Draw_Viewer.hxx>
-#include <Image_AlienPixMap.hxx>
-#include <V3d_View.hxx>
#include <ViewerTest.hxx>
#include <ViewerTest_EventManager.hxx>
-#include <TColStd_StackOfInteger.hxx>
-#include <TColStd_ListOfInteger.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-#include <TColStd_HSequenceOfReal.hxx>
#include <TopoDS_Shape.hxx>
#include <AIS_InteractiveContext.hxx>
-#include <Aspect_Window.hxx>
-#include <Aspect_WindowDriver.hxx>
-#include <Aspect_DisplayConnection.hxx>
-#include <Graphic3d.hxx>
#include <DBRep.hxx>
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
#include <Draw_PluginMacro.hxx>
-Handle(TColStd_HSequenceOfReal) GetColorOfPixel (const Image_PixMap& theImage,
- const Standard_Integer theCoordinateX,
- const Standard_Integer theCoordinateY,
- const Standard_Integer theRadius)
-{
- Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal();
- if (theImage.IsEmpty()) {
- std::cerr << "The image is null.\n";
- return aSeq;
- }
- Standard_Integer aWidth = (Standard_Integer )theImage.SizeX();
- Standard_Integer anHeight = (Standard_Integer )theImage.SizeY();
-
- Quantity_Color aColorTmp;
- for (Standard_Integer anXIter = theCoordinateX - theRadius;
- anXIter <= theCoordinateX + theRadius; ++anXIter)
- {
- if (anXIter < 0 || anXIter >= aWidth)
- {
- continue;
- }
- for (Standard_Integer anYIter = theCoordinateY - theRadius;
- anYIter <= theCoordinateY + theRadius; ++anYIter)
- {
- if (anYIter < 0 || anYIter >= anHeight)
- {
- continue;
- }
- // Image_PixMap stores image upside-down in memory!
- aColorTmp = theImage.PixelColor (anXIter, anYIter);
- aSeq->Append (aColorTmp.Red());
- aSeq->Append (aColorTmp.Green());
- aSeq->Append (aColorTmp.Blue());
- }
- }
- return aSeq;
-}
-
-static Standard_Integer QAAISGetPixelColor (Draw_Interpretor& theDi,
- Standard_Integer theArgsNb,
- const char** theArgs)
-{
- if (theArgsNb != 3 && theArgsNb != 6)
- {
- theDi << "Usage : " << theArgs[0] << " coordinate_X coordinate_Y [color_R color_G color_B]" << "\n";
- return 1; // TCL_ERROR
- }
-
- Handle(V3d_View) aView3d = ViewerTest::CurrentView();
- if (aView3d.IsNull())
- {
- theDi << "You must initialize AISViewer before this command.\n";
- return 1; // TCL_ERROR
- }
-
- const Handle(Aspect_Window) anAISWindow = aView3d->Window();
- Standard_Integer aWindowSizeX = 0;
- Standard_Integer aWindowSizeY = 0;
- anAISWindow->Size (aWindowSizeX, aWindowSizeY);
-
- Standard_Integer anArgIter = 1;
- const Standard_Integer aPickCoordX = Draw::Atoi (theArgs[anArgIter++]);
- const Standard_Integer aPickCoordY = Draw::Atoi (theArgs[anArgIter++]);
- const Standard_Integer aRadius = (theArgsNb == 3) ? 0 : 1;
-
- Image_ColorRGBF aColorInput = {{ 0.0f, 0.0f, 0.0f }};
- if (theArgsNb == 6)
- {
- aColorInput.r() = (Standard_ShortReal )Draw::Atof (theArgs[anArgIter++]);
- aColorInput.g() = (Standard_ShortReal )Draw::Atof (theArgs[anArgIter++]);
- aColorInput.b() = (Standard_ShortReal )Draw::Atof (theArgs[anArgIter++]);
- }
-
- Image_PixMap anImage;
- aView3d->ToPixMap (anImage, aWindowSizeX, aWindowSizeY);
- const Handle(TColStd_HSequenceOfReal) aSeq = GetColorOfPixel (anImage, aPickCoordX, aPickCoordY, aRadius);
- cout << "Length = " << aSeq->Length() << endl;
-
- Image_ColorRGBF aColorPicked = {{ 0.0f, 0.0f, 0.0f }};
- Standard_Boolean isNotEqual = Standard_True;
- for (Standard_Integer i = 1; i <= aSeq->Length(); i += 3)
- {
- aColorPicked.r() = (Standard_ShortReal )aSeq->Value (i + 0);
- aColorPicked.g() = (Standard_ShortReal )aSeq->Value (i + 1);
- aColorPicked.b() = (Standard_ShortReal )aSeq->Value (i + 2);
-
- if (theArgsNb == 3 ||
- ((Abs (aColorPicked.r() - aColorInput.r()) <= Precision::Confusion())
- && (Abs (aColorPicked.g() - aColorInput.g()) <= Precision::Confusion())
- && (Abs (aColorPicked.b() - aColorInput.b()) <= Precision::Confusion())))
- {
- isNotEqual = Standard_False;
- break;
- }
- }
-
- theDi << "RED : " << aColorPicked.r() << " "
- << "GREEN : " << aColorPicked.g() << " "
- << "BLUE : " << aColorPicked.b() << "\n";
-
- if (theArgsNb == 6)
- {
- theDi << "User color: \n"
- << "RED : " << aColorInput.r() << " "
- << "GREEN : " << aColorInput.g() << " "
- << "BLUE : " << aColorInput.b() << "\n";
- }
-
- if (isNotEqual)
- {
- theDi << "Faulty : colors are not equal.\n";
- return 1; // TCL_ERROR
- }
- return 0;
-}
-
//=======================================================================
-#if ! defined(WNT)
-extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
-extern Handle(AIS_InteractiveContext)& TheAISContext();
-#else
-Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
-Standard_EXPORT Handle(AIS_InteractiveContext)& TheAISContext();
-#endif
+
#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
#include <AIS_Trihedron.hxx>
#include <AIS_Axis.hxx>
#include <Geom_Line.hxx>
#include <AIS_Line.hxx>
+Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
+Standard_EXPORT Handle(AIS_InteractiveContext)& TheAISContext();
+
//==============================================================================
// function : VTrihedronOrigins
// author : ota
const char ** argv)
{
if(argc != 2){
- di <<"Usage : vtri_orig tri_name"<<"\n";
+ di <<"Usage : vtri_orig tri_name\n";
return 1;
}
if(TheAISContext().IsNull()){
- di<<"Make 'vinit' before this method call"<<"\n";
+ di<<"Make 'vinit' before this method call\n";
return 1;
}
//get trihedron from AIS map.
TCollection_AsciiString aName(argv[1]);
if(!GetMapOfAIS().IsBound2(aName)){
- di<<"No object named '"<<argv[1]<<"'"<<"\n";
+ di<<"No object named '"<<argv[1]<<"'\n";
return 1;
}
Handle(AIS_Trihedron) aTrih =
Handle(AIS_Trihedron)::DownCast(GetMapOfAIS().Find2(aName));
if(aTrih.IsNull()){
- di<<"Trihedron is not found, try another name"<<"\n";
+ di<<"Trihedron is not found, try another name\n";
return 1;
}
GetMapOfAIS().Bind(YLine,aName+"_Y");
GetMapOfAIS().Bind(ZLine,aName+"_Z");
//print names of created objects:
- di<<argv[1]<<"_X "<<argv[1]<<"_Y "<<argv[1]<<"_Z"<<"\n";
+ di<<argv[1]<<"_X "<<argv[1]<<"_Y "<<argv[1]<<"_Z\n";
//try to draw them:
TheAISContext()->Display(XLine);
{
const char* group = "QA_Commands";
- theCommands.Add ("QAGetPixelColor",
- "QAGetPixelColor coordinate_X coordinate_Y [color_R color_G color_B]",
- __FILE__,
- QAAISGetPixelColor,
- group);
-
theCommands.Add ("vtri_orig",
"vtri_orig : vtri_orig trihedron_name - draws axis origin lines",
__FILE__,