| Line | Branch | Exec | Source | 
    
      | 1 |  |  | // | 
    
      | 2 |  |  | //  leaf-node-cone.cpp | 
    
      | 3 |  |  | //  gepetto-viewer | 
    
      | 4 |  |  | // | 
    
      | 5 |  |  | //  Created by Justin Carpentier, Mathieu Geisert in November 2014. | 
    
      | 6 |  |  | //  Copyright (c) 2014 LAAS-CNRS. All rights reserved. | 
    
      | 7 |  |  | // | 
    
      | 8 |  |  |  | 
    
      | 9 |  |  | #include <gepetto/viewer/leaf-node-cone.h> | 
    
      | 10 |  |  |  | 
    
      | 11 |  |  | namespace gepetto { | 
    
      | 12 |  |  | namespace viewer { | 
    
      | 13 |  |  |  | 
    
      | 14 |  |  | /* Declaration of private function members */ | 
    
      | 15 |  |  |  | 
    
      | 16 |  | ✗ | void LeafNodeCone::init() { | 
    
      | 17 |  |  | /* Create cone object */ | 
    
      | 18 |  | ✗ | cone_ptr_ = new osg::Cone(); | 
    
      | 19 |  |  |  | 
    
      | 20 |  |  | /* Set ShapeDrawable */ | 
    
      | 21 |  | ✗ | shape_drawable_ptr_ = new osg::ShapeDrawable(cone_ptr_); | 
    
      | 22 |  |  |  | 
    
      | 23 |  |  | /* Create Geode for adding ShapeDrawable */ | 
    
      | 24 |  | ✗ | geode_ptr_ = new osg::Geode(); | 
    
      | 25 |  | ✗ | geode_ptr_->addDrawable(shape_drawable_ptr_); | 
    
      | 26 |  |  |  | 
    
      | 27 |  |  | /* Create PositionAttitudeTransform */ | 
    
      | 28 |  | ✗ | this->asQueue()->addChild(geode_ptr_); | 
    
      | 29 |  |  |  | 
    
      | 30 |  |  | /* Allow transparency */ | 
    
      | 31 |  | ✗ | geode_ptr_->getOrCreateStateSet()->setMode(GL_BLEND, | 
    
      | 32 |  |  | ::osg::StateAttribute::ON); | 
    
      | 33 |  |  | } | 
    
      | 34 |  |  |  | 
    
      | 35 |  | ✗ | LeafNodeCone::LeafNodeCone(const std::string& name, const float& radius, | 
    
      | 36 |  | ✗ | const float& height) | 
    
      | 37 |  | ✗ | : NodeDrawable(name) { | 
    
      | 38 |  | ✗ | init(); | 
    
      | 39 |  | ✗ | setRadius(radius); | 
    
      | 40 |  | ✗ | setHeight(height); | 
    
      | 41 |  | ✗ | setColor(osgVector4(1., 1., 1., 1.)); | 
    
      | 42 |  |  | } | 
    
      | 43 |  |  |  | 
    
      | 44 |  | ✗ | LeafNodeCone::LeafNodeCone(const std::string& name, const float& radius, | 
    
      | 45 |  | ✗ | const float& height, const osgVector4& color) | 
    
      | 46 |  | ✗ | : NodeDrawable(name) { | 
    
      | 47 |  | ✗ | init(); | 
    
      | 48 |  | ✗ | setRadius(radius); | 
    
      | 49 |  | ✗ | setHeight(height); | 
    
      | 50 |  | ✗ | setColor(color); | 
    
      | 51 |  |  | } | 
    
      | 52 |  | ✗ | LeafNodeCone::LeafNodeCone(const LeafNodeCone& other) : NodeDrawable(other) { | 
    
      | 53 |  | ✗ | init(); | 
    
      | 54 |  | ✗ | setRadius(other.getRadius()); | 
    
      | 55 |  | ✗ | setHeight(other.getHeight()); | 
    
      | 56 |  | ✗ | setColor(other.getColor()); | 
    
      | 57 |  |  | } | 
    
      | 58 |  |  |  | 
    
      | 59 |  | ✗ | void LeafNodeCone::initWeakPtr(LeafNodeConeWeakPtr other_weak_ptr) { | 
    
      | 60 |  | ✗ | weak_ptr_ = other_weak_ptr; | 
    
      | 61 |  |  | } | 
    
      | 62 |  |  |  | 
    
      | 63 |  |  | /* End of declaration of private function members */ | 
    
      | 64 |  |  |  | 
    
      | 65 |  |  | /* Declaration of protected function members */ | 
    
      | 66 |  |  |  | 
    
      | 67 |  | ✗ | LeafNodeConePtr_t LeafNodeCone::create(const std::string& name, | 
    
      | 68 |  |  | const float& radius, | 
    
      | 69 |  |  | const float& height) { | 
    
      | 70 |  | ✗ | LeafNodeConePtr_t shared_ptr(new LeafNodeCone(name, radius, height)); | 
    
      | 71 |  |  |  | 
    
      | 72 |  |  | // Add reference to itself | 
    
      | 73 |  | ✗ | shared_ptr->initWeakPtr(shared_ptr); | 
    
      | 74 |  |  |  | 
    
      | 75 |  | ✗ | return shared_ptr; | 
    
      | 76 |  |  | } | 
    
      | 77 |  |  |  | 
    
      | 78 |  | ✗ | LeafNodeConePtr_t LeafNodeCone::create(const std::string& name, | 
    
      | 79 |  |  | const float& radius, const float& height, | 
    
      | 80 |  |  | const osgVector4& color) { | 
    
      | 81 |  | ✗ | LeafNodeConePtr_t shared_ptr(new LeafNodeCone(name, radius, height, color)); | 
    
      | 82 |  |  |  | 
    
      | 83 |  |  | // Add reference to itself | 
    
      | 84 |  | ✗ | shared_ptr->initWeakPtr(shared_ptr); | 
    
      | 85 |  |  |  | 
    
      | 86 |  | ✗ | return shared_ptr; | 
    
      | 87 |  |  | } | 
    
      | 88 |  |  |  | 
    
      | 89 |  | ✗ | LeafNodeConePtr_t LeafNodeCone::createCopy(LeafNodeConePtr_t other) { | 
    
      | 90 |  | ✗ | LeafNodeConePtr_t shared_ptr(new LeafNodeCone(*other)); | 
    
      | 91 |  |  |  | 
    
      | 92 |  |  | // Add reference to itself | 
    
      | 93 |  | ✗ | shared_ptr->initWeakPtr(shared_ptr); | 
    
      | 94 |  |  |  | 
    
      | 95 |  | ✗ | return shared_ptr; | 
    
      | 96 |  |  | } | 
    
      | 97 |  |  |  | 
    
      | 98 |  |  | /* End of declaration of protected function members */ | 
    
      | 99 |  |  |  | 
    
      | 100 |  |  | /* Declaration of public function members */ | 
    
      | 101 |  |  |  | 
    
      | 102 |  | ✗ | LeafNodeConePtr_t LeafNodeCone::clone(void) const { | 
    
      | 103 |  | ✗ | return LeafNodeCone::createCopy(weak_ptr_.lock()); | 
    
      | 104 |  |  | } | 
    
      | 105 |  |  |  | 
    
      | 106 |  | ✗ | LeafNodeConePtr_t LeafNodeCone::self(void) const { return weak_ptr_.lock(); } | 
    
      | 107 |  |  |  | 
    
      | 108 |  | ✗ | void LeafNodeCone::setRadius(const float& radius) { | 
    
      | 109 |  | ✗ | cone_ptr_->setRadius(radius); | 
    
      | 110 |  | ✗ | redrawShape(); | 
    
      | 111 |  |  | } | 
    
      | 112 |  |  |  | 
    
      | 113 |  | ✗ | void LeafNodeCone::setHeight(const float& height) { | 
    
      | 114 |  | ✗ | cone_ptr_->setHeight(height); | 
    
      | 115 |  | ✗ | redrawShape(); | 
    
      | 116 |  |  | } | 
    
      | 117 |  |  |  | 
    
      | 118 |  | ✗ | LeafNodeCone::~LeafNodeCone() { | 
    
      | 119 |  |  | /* Proper deletion of all tree scene */ | 
    
      | 120 |  | ✗ | geode_ptr_->removeDrawable(shape_drawable_ptr_); | 
    
      | 121 |  | ✗ | shape_drawable_ptr_ = NULL; | 
    
      | 122 |  |  |  | 
    
      | 123 |  | ✗ | this->asQueue()->removeChild(geode_ptr_); | 
    
      | 124 |  | ✗ | geode_ptr_ = NULL; | 
    
      | 125 |  |  |  | 
    
      | 126 |  | ✗ | weak_ptr_.reset(); | 
    
      | 127 |  |  | } | 
    
      | 128 |  |  |  | 
    
      | 129 |  |  | /* End of declaration of public function members */ | 
    
      | 130 |  |  |  | 
    
      | 131 |  |  | } /* namespace viewer */ | 
    
      | 132 |  |  |  | 
    
      | 133 |  |  | } /* namespace gepetto */ | 
    
      | 134 |  |  |  |