Ignition Rendering

API Reference

5.1.0
BaseArrowVisual.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 #ifndef IGNITION_RENDERING_BASE_BASEARROWVISUAL_HH_
18 #define IGNITION_RENDERING_BASE_BASEARROWVISUAL_HH_
19 
22 
23 namespace ignition
24 {
25  namespace rendering
26  {
27  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
28  //
29  template <class T>
31  public virtual ArrowVisual,
32  public virtual T
33  {
35  protected: BaseArrowVisual();
36 
38  public: virtual ~BaseArrowVisual();
39 
40  // Documentation inherited.
41  public: virtual VisualPtr Head() const override;
42 
43  // Documentation inherited.
44  public: virtual VisualPtr Shaft() const override;
45 
46  // Documentation inherited
47  public: virtual void ShowArrowHead(bool _b) override;
48 
49  // Documentation inherited.
50  protected: virtual void Init() override;
51  };
52 
54  template <class T>
56  {
57  }
58 
60  template <class T>
62  {
63  }
64 
66  template <class T>
68  {
69  return std::dynamic_pointer_cast<Visual>(this->ChildByIndex(1));
70  }
71 
73  template <class T>
75  {
76  return std::dynamic_pointer_cast<Visual>(this->ChildByIndex(0));
77  }
78 
80  template <class T>
82  {
83  NodePtr child = this->ChildByIndex(1);
85  if (visual)
86  {
87  visual->SetVisible(_b);
88  }
89  }
90 
92  template <class T>
94  {
95  T::Init();
96 
97  VisualPtr cone = this->Scene()->CreateVisual();
98  cone->AddGeometry(this->Scene()->CreateCone());
99  cone->SetOrigin(0, 0, -0.5);
100  cone->SetLocalPosition(0, 0, 0);
101  cone->SetLocalScale(0.1, 0.1, 0.25);
102  this->AddChild(cone);
103 
104  VisualPtr cylinder = this->Scene()->CreateVisual();
105  cylinder->AddGeometry(this->Scene()->CreateCylinder());
106  cylinder->SetOrigin(0, 0, 0.5);
107  cylinder->SetLocalPosition(0, 0, 0);
108  cylinder->SetLocalScale(0.05, 0.05, 0.5);
109  this->AddChild(cylinder);
110 
111  this->SetOrigin(0, 0, -0.5);
112  }
113  }
114  }
115 }
116 #endif
Represents a arrow composite visual.
Definition: ArrowVisual.hh:31
virtual void ShowArrowHead(bool _b) override
set true to show the arrow head, false otherwise
Definition: BaseArrowVisual.hh:81
virtual VisualPtr Head() const override
Get arrow-head visual.
Definition: BaseArrowVisual.hh:67
BaseArrowVisual()
Constructor.
Definition: BaseArrowVisual.hh:55
virtual void Init() override
Definition: BaseArrowVisual.hh:93
Manages a single scene-graph. This class updates scene-wide properties and holds the root scene node...
Definition: Scene.hh:49
T dynamic_pointer_cast(T... args)
virtual VisualPtr Shaft() const override
Get arrow-shaft visual.
Definition: BaseArrowVisual.hh:74
Represents a visual node in a scene graph. A Visual is the only node that can have Geometry and other...
Definition: Visual.hh:37
virtual ~BaseArrowVisual()
Destructor.
Definition: BaseArrowVisual.hh:61
virtual VisualPtr CreateVisual()=0
Create new visual. A unique ID and name will automatically be assigned to the visual.
Definition: BaseArrowVisual.hh:30