<commit_before>//
//  node.cpp
//  gepetto-viewer
//
//  Created by <NAME>, <NAME> in November 2014.
//  Copyright (c) 2014 LAAS-CNRS. All rights reserved.
//

#include <gepetto/viewer/node.h>

#include <climits>

#include <osg/Material>
#include <osg/LineWidth>
#include <osgFX/Outline>
#include <osgFX/Scribe>

#include <gepetto/viewer/window-manager.h>
#include <gepetto/viewer/node-visitor.h>

namespace graphics {
  using ::osg::Matrix;

  /* Declaration of private function members */
  void Node::init ()
  {
    /* Build local conformation
       <- wireframe_node_ptr_
       connected to the parent <- switch_node_ptr_                           <- auto_transform_ptr_ <- connection of children here
       <- normal_node_ptr_
    */

    switch_node_ptr_ = new ::osg::Group;
    hl_switch_node_ptr_ = new ::osg::Group;
    auto_transform_ptr_ = new ::osg::AutoTransform;
    static_auto_transform_ptr_ = new ::osg::MatrixTransform;

    switch_node_ptr_->setNodeMask(~NodeBit);
    switch_node_ptr_->getOrCreateStateSet()->setDataVariance(::osg::Object::DYNAMIC);
    switch_node_ptr_->setName (id_name_);
    wireframe_modes_.resize(2);
    wireframe_modes_[FILL]      = new ::osg::Group;
    wireframe_modes_[WIREFRAME] = new ::osg::Group;

    /* Building hierarchie */
    selected_wireframe_ = FILL;
    switch_node_ptr_->addChild(wireframe_modes_[selected_wireframe_]);
    wireframe_modes_[selected_wireframe_]->addChild(hl_switch_node_ptr_);

    // Setup highlight states
    highlight_nodes_.resize(9);
    selected_highlight_ = 0;
    for (unsigned int i = 0; i < 9; ++i) {
      ::osg::GroupRefPtr g = setupHighlightState (i);
      highlight_nodes_[i] = g;
    }
    // setHighlightState(0);
    hl_switch_node_ptr_->addChild(highlight_nodes_[selected_highlight_]);
    highlight_nodes_[selected_highlight_]->addChild(auto_transform_ptr_);

    auto_transform_ptr_->addChild(static_auto_transform_ptr_);

    /* Allowing wireframe mode */
    osg::PolygonModeRefPtr polygon_mode_ptr = new ::osg::PolygonMode;
    polygon_mode_ptr->setMode( ::osg::PolygonMode::FRONT_AND_BACK, ::osg::PolygonMode::LINE );

    ::osg::MaterialRefPtr material_wireframe_ptr = new osg::Material;
    material_wireframe_ptr->setColorMode(osg::Material::DIFFUSE);
    material_wireframe_ptr->setDiffuse(osg::Material::FRONT_AND_BACK, osgVector4(1.,1.,1.,1.));

    wireframe_modes_[WIREFRAME]->getOrCreateStateSet()->setAttributeAndModes(polygon_mode_ptr, ::osg::StateAttribute::PROTECTED | ::osg::StateAttribute::ON );
    wireframe_modes_[WIREFRAME]->getOrCreateStateSet()->setMode(GL_BLEND, ::osg::StateAttribute::OFF | ::osg::StateAttribute::PROTECTED ); // PROTECTED attribut allows wireframe node to not be influenced by alpha
    wireframe_modes_[WIREFRAME]->getOrCreateStateSet()->setAttributeAndModes(material_wireframe_ptr, ::osg::StateAttribute::ON | ::osg::StateAttribute::PROTECTED );
    geode_ptr_ = NULL;
    alpha_ = 0;

    visibilityMode_ = VISIBILITY_ON;
  }

  Node::Node (const std::string& name) :
    id_name_(name)
  {
    init();
  }

  Node::Node (const Node &other) :
    id_name_(other.getID())
  {
    init();
  }

  const PropertyPtr_t& Node::property(const std::string& name) const
  {
    PropertyMap_t::const_iterator _prop = properties_.find(name);
    if (_prop == properties_.end())<commit_msg>Add property visibility to node<commit_after>//
//  node.cpp
//  gepetto-viewer
//
//  Created by <NAME>, <NAME> in November 2014.
//  Copyright (c) 2014 LAAS-CNRS. All rights reserved.
//

#include <gepetto/viewer/node.h>

#include <climits>

#include <osg/Material>
#include <osg/LineWidth>
#include <osgFX/Outline>
#include <osgFX/Scribe>

#include <gepetto/viewer/window-manager.h>
#include <gepetto/viewer/node-visitor.h>

namespace graphics {
  namespace {
    int getNodeVisibilityMode (Node* node) { return node->getVisibilityMode(); }
  }
  using ::osg::Matrix;

  /* Declaration of private function members */
  void Node::init ()
  {
    /* Build local conformation
       <- wireframe_node_ptr_
       connected to the parent <- switch_node_ptr_                           <- auto_transform_ptr_ <- connection of children here
       <- normal_node_ptr_
    */

    switch_node_ptr_ = new ::osg::Group;
    hl_switch_node_ptr_ = new ::osg::Group;
    auto_transform_ptr_ = new ::osg::AutoTransform;
    static_auto_transform_ptr_ = new ::osg::MatrixTransform;

    switch_node_ptr_->setNodeMask(~NodeBit);
    switch_node_ptr_->getOrCreateStateSet()->setDataVariance(::osg::Object::DYNAMIC);
    switch_node_ptr_->setName (id_name_);
    wireframe_modes_.resize(2);
    wireframe_modes_[FILL]      = new ::osg::Group;
    wireframe_modes_[WIREFRAME] = new ::osg::Group;

    /* Building hierarchie */
    selected_wireframe_ = FILL;
    switch_node_ptr_->addChild(wireframe_modes_[selected_wireframe_]);
    wireframe_modes_[selected_wireframe_]->addChild(hl_switch_node_ptr_);

    // Setup highlight states
    highlight_nodes_.resize(9);
    selected_highlight_ = 0;
    for (unsigned int i = 0; i < 9; ++i) {
      ::osg::GroupRefPtr g = setupHighlightState (i);
      highlight_nodes_[i] = g;
    }
    // setHighlightState(0);
    hl_switch_node_ptr_->addChild(highlight_nodes_[selected_highlight_]);
    highlight_nodes_[selected_highlight_]->addChild(auto_transform_ptr_);

    auto_transform_ptr_->addChild(static_auto_transform_ptr_);

    /* Allowing wireframe mode */
    osg::PolygonModeRefPtr polygon_mode_ptr = new ::osg::PolygonMode;
    polygon_mode_ptr->setMode( ::osg::PolygonMode::FRONT_AND_BACK, ::osg::PolygonMode::LINE );

    ::osg::MaterialRefPtr material_wireframe_ptr = new osg::Material;
    material_wireframe_ptr->setColorMode(osg::Material::DIFFUSE);
    material_wireframe_ptr->setDiffuse(osg::Material::FRONT_AND_BACK, osgVector4(1.,1.,1.,1.));

    wireframe_modes_[WIREFRAME]->getOrCreateStateSet()->setAttributeAndModes(polygon_mode_ptr, ::osg::StateAttribute::PROTECTED | ::osg::StateAttribute::ON );
    wireframe_modes_[WIREFRAME]->getOrCreateStateSet()->setMode(GL_BLEND, ::osg::StateAttribute::OFF | ::osg::StateAttribute::PROTECTED ); // PROTECTED attribut allows wireframe node to not be influenced by alpha
    wireframe_modes_[WIREFRAME]->getOrCreateStateSet()->setAttributeAndModes(material_wireframe_ptr, ::osg::StateAttribute::ON | ::osg::StateAttribute::PROTECTED );
    geode_ptr_ = NULL;
    alpha_ = 0;

    visibilityMode_ = VISIBILITY_ON;

    addProperty(
        IntProperty::create("visibility",
          IntProperty::Getter_t(boost::bind(getNodeVisibilityMode, this)),
          IntProperty::Setter_t()
          ));
  }

  Node::Node (const std::string& name) :
    id_name_(name)
  {
    init();
  }

  Node::Node (const Node &other) :
    id_name_(other.getID())
  {
    init();
  }

  const PropertyPtr_t& Node::property(const std::string& name) const
  {
    PropertyMap_t::const_iterator _prop = properties_.find(name);
    if (_prop == properties_.end())
{'fraction_non_alphanumeric': 0.13329503016374605, 'fraction_numerical': 0.005745475438092502, 'mean_word_length': 4.431357254290171, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4957844', 'n_tokens_mistral': 2399, 'n_tokens_neox': 2283, 'n_words': 373}