0024623: Visualization - improve selection mechanism
[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 #include <QABugs_MyText.ixx>
17 #include <QABugs_MyText.hxx>
18 #include <Prs3d_Presentation.hxx>
19 #include <Prs3d_TextAspect.hxx>
20 #include <Prs3d_Drawer.hxx>
21 #include <SelectMgr_EntityOwner.hxx>
22 #include <Prs3d_Text.hxx>
23 #include <Select3D_SensitiveBox.hxx>
24 #include <SelectMgr_Selection.hxx>
25 #include <Font_NameOfFont.hxx>
26
27 /*************************************************************************
28 *
29 * CONSTRUCTION/DESTRUCTION
30 *
31 **************************************************************************/
32
33
34 QABugs_MyText::QABugs_MyText(const TCollection_ExtendedString& aText, const gp_Pnt& aPosition, 
35                                const Standard_CString aFont, const Quantity_NameOfColor aColor, const Standard_Real aHeight)
36 {
37   myPosition = aPosition;
38   myText = TCollection_ExtendedString(aText);
39   myNameOfFont = aFont;
40   myNameOfColor = aColor;
41   myHeight = aHeight;
42 }
43
44
45 /*************************************************************************
46 *
47 * QUERY METHODS
48 *
49 **************************************************************************/
50
51 void QABugs_MyText::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
52                              const Handle(Prs3d_Presentation)& aPresentation,
53                              const Standard_Integer /*aMode*/ ) 
54 {
55   aPresentation->Clear();
56   Handle(Prs3d_TextAspect) asp = myDrawer->TextAspect();
57
58   asp->SetFont(myNameOfFont);
59   asp->SetColor(myNameOfColor);
60   asp->SetHeight(myHeight); // I am changing the myHeight value
61   Prs3d_Text::Draw(aPresentation, asp, myText, myPosition);
62 }
63
64 void QABugs_MyText::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
65                                       const Standard_Integer /*aMode*/)
66 {
67   // This code is here to compute the selection, erase this code if you don't what selection.
68
69   Handle( SelectMgr_EntityOwner ) own = new SelectMgr_EntityOwner(this, 7);
70
71   Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox(own,
72     myPosition.X(), 
73     myPosition.Y(),
74     myPosition.Z(), 
75     myPosition.X() + 20,
76     myPosition.Y() + 20,
77     myPosition.Z() + 20);
78   aSelection->Add(box);
79 }