-
-//=======================================================================
-// function : MakePointAndDisplay
-// purpose :
-//=======================================================================
-void BasicGUI::MakePointAndDisplay(const double x, const double y, const double z)
-{
- try {
- GEOM::GEOM_Shape_var P = myGeom->MakeVertex(x, y, z);
- P->NameType(tr("GEOM_VERTEX"));
- if (myGeomBase->Display(P))
- QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
- }
- catch(const SALOME::SALOME_Exception& S_ex) {
- QtCatchCorbaException(S_ex);
- }
- return;
-}
-
-
-//=====================================================================================
-// function : MakeLineAndDisplay()
-// purpose : Create an infinite oriented line (linear edge in fact)
-//=====================================================================================
-void BasicGUI::MakeLineAndDisplay(const gp_Pnt InitPoint, const gp_Pnt LastPoint)
-{
- gp_Pnt P1, P2;
- double dx, dy, dz;
- myGeomBase->GetBipointDxDyDz(InitPoint, LastPoint, dx, dy, dz);
- Standard_Real length = InitPoint.Distance(LastPoint);
- if(length <= Precision::Confusion()) {
- QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
- return;
- }
-
- Standard_Real coeff = 1E6 / length;
-
- /* To create a line with length = 1E6 */
- /* Precision::Infinite() is 1E100 in OCC */
- P1.SetX(InitPoint.X() - (coeff * dx));
- P1.SetY(InitPoint.Y() - (coeff * dy));
- P1.SetZ(InitPoint.Z() - (coeff * dz));
-
- P2.SetX(LastPoint.X() + (coeff * dx));
- P2.SetY(LastPoint.Y() + (coeff * dy));
- P2.SetZ(LastPoint.Z() + (coeff * dz));
-
- try {
- GEOM::PointStruct pstruct = myGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z());
- GEOM::PointStruct d = myGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z());
- GEOM::DirStruct dstruct = myGeom->MakeDirection(d);
-
- GEOM::GEOM_Shape_ptr result = myGeom->MakeLine(pstruct, dstruct);
- if(result->_is_nil()) {
- QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
- return;
- }
- result->NameType(tr("GEOM_LINE"));
-
- if(myGeomBase->Display(result))
- QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_READY"));
- }
- catch(const SALOME::SALOME_Exception& S_ex) {
- QtCatchCorbaException(S_ex);
- }
- return;
-}
-
-
-//=====================================================================================
-// function : MakeCircleAndDisplay()
-// purpose :
-//=====================================================================================
-void BasicGUI::MakeCircleAndDisplay(const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Radius)
-{
- try {
- GEOM::PointStruct pstruct = myGeom->MakePointStruct(CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z());
- GEOM::PointStruct d = myGeom->MakePointStruct(dir.X(), dir.Y(), dir.Z());
- GEOM::DirStruct dstruct = myGeom->MakeDirection(d);
-
- GEOM::GEOM_Shape_var result = myGeom->MakeCircle(pstruct, dstruct, Radius);
- if(result->_is_nil()) {
- QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
- return;
- }
- result->NameType(tr("GEOM_CIRCLE"));
- if(myGeomBase->Display(result))
- QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
- }
- catch(const SALOME::SALOME_Exception& S_ex) {
- QtCatchCorbaException(S_ex);
- }
- return;
-}
-
-
-//=====================================================================================
-// function : MakeEllipseAndDisplay()
-// purpose :
-//=====================================================================================
-void BasicGUI::MakeEllipseAndDisplay(const gp_Pnt CenterPoint, const gp_Dir dir,
- const Standard_Real Major_Radius, const Standard_Real Minor_Radius)
-{
- try {
- GEOM::PointStruct pstruct = myGeom->MakePointStruct(CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z());
- GEOM::PointStruct d = myGeom->MakePointStruct(dir.X(), dir.Y(), dir.Z());
- GEOM::DirStruct dstruct = myGeom->MakeDirection(d) ;
-
- GEOM::GEOM_Shape_var result = myGeom->MakeEllipse(pstruct, dstruct, Major_Radius, Minor_Radius);
- if(result->_is_nil()) {
- QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
- return;
- }
- result->NameType(tr("GEOM_ELLIPSE"));
- if(myGeomBase->Display(result))
- QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
- }
- catch(const SALOME::SALOME_Exception& S_ex) {
- QtCatchCorbaException(S_ex);
- }
- return;
-}
-
-
-//=======================================================================================
-// function : MakeArcAndDisplay()
-// purpose : Make an arc of circle from InitPoint to CirclePoint and passing on EndPoint
-//=======================================================================================
-void BasicGUI::MakeArcAndDisplay(gp_Pnt InitPoint, gp_Pnt CirclePoint, gp_Pnt EndPoint)
-{
- gp_Vec v1(CirclePoint, InitPoint);
- gp_Vec v2(CirclePoint, EndPoint);
- if(v1.IsParallel(v2, Precision::Angular()))
- return;
-
- try {
- GEOM::PointStruct pI = myGeom->MakePointStruct(InitPoint.X(), InitPoint.Y(), InitPoint.Z());
- GEOM::PointStruct pC = myGeom->MakePointStruct(CirclePoint.X(), CirclePoint.Y(), CirclePoint.Z());
- GEOM::PointStruct pE = myGeom->MakePointStruct(EndPoint.X(), EndPoint.Y(), EndPoint.Z());
- GEOM::GEOM_Shape_var result = myGeom->MakeArc(pI, pC, pE);
- if(result->_is_nil()) {
- QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
- return;
- }
- result->NameType(tr("GEOM_ARC"));
- if (myGeomBase->Display(result))
- QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
- }
- catch(const SALOME::SALOME_Exception& S_ex) {
- QtCatchCorbaException(S_ex);
- }
- return;
-}
-
-
-//=======================================================================
-// function : MakeVectorAndDisplay()
-// purpose :
-//=======================================================================
-void BasicGUI::MakeVectorAndDisplay(const gp_Pnt P1, const gp_Pnt P2)
-{
- try {
- GEOM::PointStruct pstruct1 = myGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z());
- GEOM::PointStruct pstruct2 = myGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z());
- GEOM::GEOM_Shape_var Vector = myGeom->MakeVector(pstruct1, pstruct2);
- Vector->NameType(tr("GEOM_VECTOR"));
- if(myGeomBase->Display(Vector))
- QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
- }
- catch(const SALOME::SALOME_Exception& S_ex) {
- QtCatchCorbaException(S_ex);
- }
- return;
-}
-
-
-//=======================================================================
-// function : MakePlaneAndDisplay()
-// purpose : Plane point is P1 and dx, dy, dz define a normal vector
-//=======================================================================
-void BasicGUI::MakePlaneAndDisplay(const gp_Pnt P1, const Standard_Real dx, const Standard_Real dy,
- const Standard_Real dz, const Standard_Real TrimSize)
-{
- try {
- gp_Dir aDirection;
- aDirection.SetCoord(dx, dy, dz);
- gp_Ax2 Axis(P1, aDirection);
-
- GEOM::PointStruct pstruct = myGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z());
- GEOM::PointStruct d = myGeom->MakePointStruct(aDirection.X(), aDirection.Y(), aDirection.Z());
- GEOM::DirStruct dstruct = myGeom->MakeDirection(d);
- GEOM::GEOM_Shape_ptr plane = myGeom->MakePlane(pstruct, dstruct, TrimSize);
- plane->NameType(tr("GEOM_PLANE"));
- if(myGeomBase->Display(plane))
- QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
- }
- catch(const SALOME::SALOME_Exception& S_ex) {
- QtCatchCorbaException(S_ex);
- }
- return;
-}
-
-
-//=======================================================================
-// function : MakeWorkingPlane()
-// purpose : Change the point of view3d
-//=======================================================================
-void BasicGUI::MakeWorkingPlane(const gp_Pnt P, const gp_Dir D)
-{
- if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC) {
- QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NOT_FOR_VTK_VIEWER"));
- return;
- }
-
- OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort();
- Handle(V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView();
- view3d->SetAt(P.X(), P.Y(), P.Z());
- view3d->SetProj(D.X(), D.Y(), D.Z());
- QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
- return;
-}
-
-