mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0031990: Coding, Draw Harness - Replace C-like pointers to function in Draw_SaveAndRestore class to virtual function
Save/Restore interface has been moved to Draw_Drawable3D base class. Create a singleton Draw_Params class for DRAW parameters
This commit is contained in:
@@ -10,7 +10,6 @@ HLRTest_OutLiner.hxx
|
||||
HLRTest_OutLiner.lxx
|
||||
HLRTest_Projector.cxx
|
||||
HLRTest_Projector.hxx
|
||||
HLRTest_Projector.lxx
|
||||
HLRTest_ShapeData.cxx
|
||||
HLRTest_ShapeData.hxx
|
||||
HLRTest_ShapeData.lxx
|
||||
|
@@ -563,6 +563,9 @@ static Standard_Integer hlrin2d(Draw_Interpretor& , Standard_Integer n, const ch
|
||||
|
||||
void HLRTest::Commands (Draw_Interpretor& theCommands)
|
||||
{
|
||||
// Register save/restore tool
|
||||
HLRTest_Projector::RegisterFactory();
|
||||
|
||||
const char* g = "ADVALGOS HLR Commands";
|
||||
|
||||
theCommands.Add("hprj" ,"hprj name [view-id = 1]" ,__FILE__,hprj,g);
|
||||
@@ -594,93 +597,3 @@ void HLRTest::Commands (Draw_Interpretor& theCommands)
|
||||
|
||||
hider = new HLRBRep_Algo();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : save and restore projector
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Boolean stest(const Handle(Draw_Drawable3D)& d)
|
||||
{
|
||||
return d->IsInstance(STANDARD_TYPE(HLRTest_Projector));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ssave
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void ssave (const Handle(Draw_Drawable3D)&d, std::ostream& OS)
|
||||
{
|
||||
Handle(HLRTest_Projector) HP =
|
||||
Handle(HLRTest_Projector)::DownCast(d);
|
||||
|
||||
const HLRAlgo_Projector& P = HP->Projector();
|
||||
OS << (P.Perspective() ? "1" : "0") << "\n";
|
||||
if (P.Perspective())
|
||||
OS << P.Focus() << "\n";
|
||||
|
||||
gp_Trsf T = P.Transformation();
|
||||
gp_XYZ V = T.TranslationPart();
|
||||
gp_Mat M = T.VectorialPart();
|
||||
|
||||
OS << M(1,1) << " ";
|
||||
OS << M(1,2) << " ";
|
||||
OS << M(1,3) << " ";
|
||||
OS << V.Coord(1) << " ";
|
||||
OS << "\n";
|
||||
OS << M(2,1) << " ";
|
||||
OS << M(2,2) << " ";
|
||||
OS << M(2,3) << " ";
|
||||
OS << V.Coord(2) << " ";
|
||||
OS << "\n";
|
||||
OS << M(3,1) << " ";
|
||||
OS << M(3,2) << " ";
|
||||
OS << M(3,3) << " ";
|
||||
OS << V.Coord(3) << " ";
|
||||
OS << "\n";
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : srestore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Handle(Draw_Drawable3D) srestore (std::istream& IS)
|
||||
{
|
||||
Standard_Boolean pers;
|
||||
IS >> pers;
|
||||
Standard_Real focus = 1;
|
||||
if (pers) IS >> focus;
|
||||
|
||||
gp_Trsf T;
|
||||
Standard_Real V1[3],V2[3],V3[3];
|
||||
Standard_Real V[3];
|
||||
|
||||
IS >> V1[0] >> V1[1] >> V1[2] >> V[0];
|
||||
IS >> V2[0] >> V2[1] >> V2[2] >> V[1];
|
||||
IS >> V3[0] >> V3[1] >> V3[2] >> V[2];
|
||||
|
||||
gp_Dir D1(V1[0],V1[1],V1[2]);
|
||||
gp_Dir D2(V2[0],V2[1],V2[2]);
|
||||
gp_Dir D3(V3[0],V3[1],V3[2]);
|
||||
gp_Ax3 axes(gp_Pnt(0,0,0),D3,D1);
|
||||
D3.Cross(D1);
|
||||
if (D3.Dot(D2) < 0) axes.YReverse();
|
||||
T.SetTransformation(axes);
|
||||
|
||||
T.SetTranslationPart(gp_Vec(V[0],V[1],V[2]));
|
||||
|
||||
HLRAlgo_Projector P(T,pers,focus);
|
||||
Handle(HLRTest_Projector) HP = new HLRTest_Projector(P);
|
||||
return HP;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ssr
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Draw_SaveAndRestore ssr("HLRTest_Projector",stest,ssave,srestore);
|
||||
|
||||
|
@@ -14,50 +14,47 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <HLRTest_Projector.hxx>
|
||||
|
||||
#include <Draw_Display.hxx>
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <HLRAlgo_Projector.hxx>
|
||||
#include <HLRTest_Projector.hxx>
|
||||
#include <Standard_Stream.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(HLRTest_Projector,Draw_Drawable3D)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(HLRTest_Projector, Draw_Drawable3D)
|
||||
|
||||
//=======================================================================
|
||||
//function : HLRTest_Projector
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
HLRTest_Projector::HLRTest_Projector (const HLRAlgo_Projector& P) :
|
||||
myProjector(P)
|
||||
HLRTest_Projector::HLRTest_Projector (const HLRAlgo_Projector& P)
|
||||
: myProjector(P)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void HLRTest_Projector::DrawOn (Draw_Display&) const
|
||||
void HLRTest_Projector::DrawOn (Draw_Display&) const
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) HLRTest_Projector::Copy () const
|
||||
Handle(Draw_Drawable3D) HLRTest_Projector::Copy() const
|
||||
{
|
||||
return new HLRTest_Projector(myProjector);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void HLRTest_Projector::Dump (Standard_OStream& S) const
|
||||
void HLRTest_Projector::Dump (Standard_OStream& S) const
|
||||
{
|
||||
S << "Projector : \n";
|
||||
if (myProjector.Perspective())
|
||||
@@ -74,12 +71,80 @@ void HLRTest_Projector::Dump (Standard_OStream& S) const
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
//function : Save
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void HLRTest_Projector::Save (Standard_OStream& theStream) const
|
||||
{
|
||||
theStream << (myProjector.Perspective() ? "1" : "0") << "\n";
|
||||
if (myProjector.Perspective())
|
||||
{
|
||||
theStream << myProjector.Focus() << "\n";
|
||||
}
|
||||
|
||||
void HLRTest_Projector::Whatis (Draw_Interpretor& I) const
|
||||
const gp_Trsf aTransformation = myProjector.Transformation();
|
||||
const gp_XYZ aTranslationVector = aTransformation.TranslationPart();
|
||||
const gp_Mat aMatrix = aTransformation.VectorialPart();
|
||||
|
||||
theStream << aMatrix(1, 1) << " ";
|
||||
theStream << aMatrix(1, 2) << " ";
|
||||
theStream << aMatrix(1, 3) << " ";
|
||||
theStream << aTranslationVector.Coord (1) << " ";
|
||||
theStream << "\n";
|
||||
theStream << aMatrix(2, 1) << " ";
|
||||
theStream << aMatrix(2, 2) << " ";
|
||||
theStream << aMatrix(2, 3) << " ";
|
||||
theStream << aTranslationVector.Coord (2) << " ";
|
||||
theStream << "\n";
|
||||
theStream << aMatrix(3, 1) << " ";
|
||||
theStream << aMatrix(3, 2) << " ";
|
||||
theStream << aMatrix(3, 3) << " ";
|
||||
theStream << aTranslationVector.Coord (3) << " ";
|
||||
theStream << "\n";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Draw_Drawable3D) HLRTest_Projector::Restore (Standard_IStream& theStream)
|
||||
{
|
||||
Standard_Boolean aPerspective = false;
|
||||
Standard_Real aFocus = 1.0;
|
||||
Standard_Real aDirVect1[3], aDirVect2[3], aDirVect3[3];
|
||||
Standard_Real aTranslationVector[3];
|
||||
theStream >> aPerspective;
|
||||
if (aPerspective)
|
||||
{
|
||||
theStream >> aFocus;
|
||||
}
|
||||
theStream >> aDirVect1[0] >> aDirVect1[1] >> aDirVect1[2] >> aTranslationVector[0];
|
||||
theStream >> aDirVect2[0] >> aDirVect2[1] >> aDirVect2[2] >> aTranslationVector[1];
|
||||
theStream >> aDirVect3[0] >> aDirVect3[1] >> aDirVect3[2] >> aTranslationVector[2];
|
||||
|
||||
gp_Dir aDir1 (aDirVect1[0], aDirVect1[1], aDirVect1[2]);
|
||||
gp_Dir aDir2 (aDirVect2[0], aDirVect2[1], aDirVect2[2]);
|
||||
gp_Dir aDir3 (aDirVect3[0], aDirVect3[1], aDirVect3[2]);
|
||||
gp_Ax3 anAxis (gp_Pnt (0, 0, 0), aDir3, aDir1);
|
||||
aDir3.Cross (aDir1);
|
||||
if (aDir3.Dot (aDir2) < 0.0)
|
||||
{
|
||||
anAxis.YReverse();
|
||||
}
|
||||
gp_Trsf aTransformation;
|
||||
aTransformation.SetTransformation (anAxis);
|
||||
aTransformation.SetTranslationPart (gp_Vec (aTranslationVector[0], aTranslationVector[1], aTranslationVector[2]));
|
||||
|
||||
HLRAlgo_Projector anAlgoProtector (aTransformation, aPerspective, aFocus);
|
||||
Handle(HLRTest_Projector) aTestProjector = new HLRTest_Projector (anAlgoProtector);
|
||||
return aTestProjector;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void HLRTest_Projector::Whatis (Draw_Interpretor& I) const
|
||||
{
|
||||
I << "projector";
|
||||
}
|
||||
|
||||
|
@@ -17,68 +17,43 @@
|
||||
#ifndef _HLRTest_Projector_HeaderFile
|
||||
#define _HLRTest_Projector_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
#include <HLRAlgo_Projector.hxx>
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
class HLRAlgo_Projector;
|
||||
class Draw_Display;
|
||||
class Draw_Drawable3D;
|
||||
|
||||
|
||||
class HLRTest_Projector;
|
||||
DEFINE_STANDARD_HANDLE(HLRTest_Projector, Draw_Drawable3D)
|
||||
|
||||
//! Draw Variable Projector to test.
|
||||
class HLRTest_Projector : public Draw_Drawable3D
|
||||
{
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(HLRTest_Projector, Draw_Drawable3D)
|
||||
Draw_Drawable3D_FACTORY
|
||||
public:
|
||||
|
||||
|
||||
Standard_EXPORT HLRTest_Projector(const HLRAlgo_Projector& P);
|
||||
|
||||
const HLRAlgo_Projector& Projector() const;
|
||||
|
||||
//! Does nothhing,
|
||||
Standard_EXPORT void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
|
||||
|
||||
|
||||
const HLRAlgo_Projector& Projector() const { return myProjector; }
|
||||
|
||||
//! Does nothing,
|
||||
Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
|
||||
|
||||
//! For variable copy.
|
||||
Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
|
||||
|
||||
|
||||
//! For variable dump.
|
||||
Standard_EXPORT virtual void Dump (Standard_OStream& S) const Standard_OVERRIDE;
|
||||
|
||||
|
||||
//! Save drawable into stream.
|
||||
Standard_EXPORT virtual void Save (Standard_OStream& theStream) const Standard_OVERRIDE;
|
||||
|
||||
//! For variable whatis command. Set as a result the
|
||||
//! type of the variable.
|
||||
Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
|
||||
|
||||
|
||||
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(HLRTest_Projector,Draw_Drawable3D)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
HLRAlgo_Projector myProjector;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <HLRTest_Projector.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _HLRTest_Projector_HeaderFile
|
||||
|
@@ -1,26 +0,0 @@
|
||||
// Created on: 1995-04-05
|
||||
// Created by: Christophe MARION
|
||||
// Copyright (c) 1995-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
//=======================================================================
|
||||
//function : Projector
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline const HLRAlgo_Projector & HLRTest_Projector::Projector () const
|
||||
{
|
||||
return myProjector;
|
||||
}
|
||||
|
Reference in New Issue
Block a user