0027670: Visualization - avoid duplication of structures defining primitive array...
[occt.git] / src / QABugs / QABugs_MyText.cxx
1 // Created on: 2002-04-10
2 // Created by: QA Admin
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16
17 #include <Font_NameOfFont.hxx>
18 #include <gp_Pnt.hxx>
19 #include <Prs3d_Drawer.hxx>
20 #include <Prs3d_Presentation.hxx>
21 #include <Prs3d_Text.hxx>
22 #include <Prs3d_TextAspect.hxx>
23 #include <QABugs_MyText.hxx>
24 #include <Select3D_SensitiveBox.hxx>
25 #include <SelectMgr_EntityOwner.hxx>
26 #include <SelectMgr_Selection.hxx>
27 #include <Standard_Type.hxx>
28 #include <TCollection_ExtendedString.hxx>
29
30 IMPLEMENT_STANDARD_RTTIEXT(QABugs_MyText,AIS_InteractiveObject)
31
32 /*************************************************************************
33 *
34 * CONSTRUCTION/DESTRUCTION
35 *
36 **************************************************************************/
37 QABugs_MyText::QABugs_MyText(const TCollection_ExtendedString& aText, const gp_Pnt& aPosition, 
38                                const Standard_CString aFont, const Quantity_NameOfColor aColor, const Standard_Real aHeight)
39 {
40   myPosition = aPosition;
41   myText = TCollection_ExtendedString(aText);
42   myNameOfFont = aFont;
43   myNameOfColor = aColor;
44   myHeight = aHeight;
45 }
46
47
48 /*************************************************************************
49 *
50 * QUERY METHODS
51 *
52 **************************************************************************/
53
54 void QABugs_MyText::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
55                              const Handle(Prs3d_Presentation)& aPresentation,
56                              const Standard_Integer /*aMode*/ ) 
57 {
58   aPresentation->Clear();
59   Handle(Prs3d_TextAspect) asp = myDrawer->TextAspect();
60
61   asp->SetFont(myNameOfFont);
62   asp->SetColor(myNameOfColor);
63   asp->SetHeight(myHeight); // I am changing the myHeight value
64   Prs3d_Text::Draw(aPresentation, asp, myText, myPosition);
65 }
66
67 void QABugs_MyText::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
68                                       const Standard_Integer /*aMode*/)
69 {
70   // This code is here to compute the selection, erase this code if you don't what selection.
71
72   Handle( SelectMgr_EntityOwner ) own = new SelectMgr_EntityOwner(this, 7);
73
74   Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox(own,
75     myPosition.X(), 
76     myPosition.Y(),
77     myPosition.Z(), 
78     myPosition.X() + 20,
79     myPosition.Y() + 20,
80     myPosition.Z() + 20);
81   aSelection->Add(box);
82 }