예제 #1
0
Project::Item Project::Item::addNewSubGroup (const String& name, int insertIndex)
{
    Item group (createGroup (project, name, createGUID (getID() + name + String (getNumChildren()))));

    jassert (canContain (group));
    addChild (group, insertIndex);
    return group;
}
예제 #2
0
City::Building* Data::OsgNode::getBuilding()
{
	auto at = getChild( INDEX_RESIDENCE )->asTransform()->asPositionAttitudeTransform();
	if ( at->getNumChildren() > 0 ) {
		return dynamic_cast<City::Building*>( at->getChild( 0 )->asTransform()->asPositionAttitudeTransform() );
	}
	return nullptr;
}
예제 #3
0
void Project::Item::sortAlphabetically (bool keepGroupsAtStart, bool recursive)
{
    sortGroup (state, keepGroupsAtStart, getUndoManager());

    if (recursive)
        for (int i = getNumChildren(); --i >= 0;)
            getChild(i).sortAlphabetically (keepGroupsAtStart, true);
}
예제 #4
0
void DivNode::connectDisplay()
{
    AreaNode::connectDisplay();
    for (unsigned i = 0; i < getNumChildren(); ++i) {
        getChild(i)->connectDisplay();
    }
    m_pClipVertexes = VertexArrayPtr(new VertexArray());
}
예제 #5
0
파일: halGenome.cpp 프로젝트: dayin1989/hal
void Genome::fixParseInfo()
{
  if (getParent() == NULL || getNumChildren() == 0)
  {
    return;
  }
  
  // copied from CactusHalConverter::updateRootParseInfo() in
  // cactus2hal/src/cactusHalConverter.cpp 
  BottomSegmentIteratorPtr bottomIterator = 
    getBottomSegmentIterator();
  TopSegmentIteratorPtr topIterator = getTopSegmentIterator();
  BottomSegmentIteratorConstPtr bend = getBottomSegmentEndIterator();
  TopSegmentIteratorConstPtr tend = getTopSegmentEndIterator();
  int top = 0, bot = 0;
  while (bottomIterator != bend && topIterator != tend)
  {
    bool bright = false;
    bool tright = false;
    BottomSegment* bseg = bottomIterator->getBottomSegment();
    TopSegment* tseg = topIterator->getTopSegment();
    hal_index_t bstart = bseg->getStartPosition();
    hal_index_t bendidx = bstart + (hal_index_t)bseg->getLength();
    hal_index_t tstart = tseg->getStartPosition();
    hal_index_t tendidx = tstart + (hal_index_t)tseg->getLength();

    if (bstart >= tstart && bstart < tendidx)
    {
      bseg->setTopParseIndex(tseg->getArrayIndex());
    }
    if (bendidx <= tendidx || bstart == bendidx)
    {
      bright = true;
    }
        
    if (tstart >= bstart && tstart < bendidx)
    {
      tseg->setBottomParseIndex(bseg->getArrayIndex());
    }
    if (tendidx <= bendidx || tstart == tendidx)
    {
      tright = true;
    }

    assert(bright || tright);
    if (bright == true)
    {
      bot += 1;
      bottomIterator->toRight();
    }
    if (tright == true)
    {
      top += 1;
      topIterator->toRight();
    }
  }
}
예제 #6
0
bool AudioDataSet<T>::load(const std::string & absoluteFilePath, std::string & errorString)
{
	File file(absoluteFilePath);
	
	if(!file.exists())
	{
		errorString = "No such file exists.";
		return false;
	}

	FileInputStream is(file);

	if (is.getStatus().failed())
	{
		errorString = "Error opening file";
		return false;
	}

	auto vt = ValueTree::readFromStream(is);

	numSounds = vt.getProperty("NumSounds");
	instancesPerSound = vt.getProperty("InstancesPerSound");
	bufferSize = vt.getProperty("BufferSize");
	stftFramesPerBuffer = vt.getProperty("STFTFramesPerBuffer");
	numDelayedBuffers = vt.getProperty("NumDelayedBuffers");

	auto featuresUsedLoaded = vt.getChildWithName("FeaturesUsed");

	//Going to reset features used
	featuresUsed.resize(0);

	for(auto i = 0; i < featuresUsedLoaded.getNumChildren(); ++i)
	{
		auto featureFramePair = featuresUsedLoaded.getChild(i);
		auto frame = int(featureFramePair.getProperty("Frame"));
		auto feature = static_cast<AudioClassifyOptions::AudioFeature>(int(featureFramePair.getProperty("Feature")));

		featuresUsed.push_back(std::make_pair(frame, feature));
	}
	
	auto dataBlock = vt.getProperty("Data").getBinaryData();
	arma::Mat<T> dataLoaded(static_cast<T*>(dataBlock->getData()), featuresUsed.size(), getTotalNumInstances());

	auto soundLabelsBlock = vt.getProperty("SoundLabels").getBinaryData();
	arma::Row<int> soundLabelsLoaded(static_cast<int*>(soundLabelsBlock->getData()), getTotalNumInstances());

	setData(dataLoaded);
	setSoundLabels(soundLabelsLoaded);

	//Assume sounds ready if loaded as required by save
	for (auto& v : soundsReady)
	{
		v = true;
	}

	return true;
}
예제 #7
0
string DivNode::dump(int indent)
{
    string dumpStr = AreaNode::dump () + "\n";
    vector<NodePtr>::iterator it;
    for(unsigned i = 0; i < getNumChildren(); ++i) {
        getChild(i)->dump(indent+2)+"\n";
    }
    return dumpStr;
}
예제 #8
0
void TOutlineViewer::expandAll(TNode *node) {
   int i, n;

   if (hasChildren(node)) {
      adjust(node, True);
      n = getNumChildren(node) - 1;
      for (i = 0; i <= n; i++)
         expandAll(getChild(node, i));
   }
}
예제 #9
0
void DivNode::disconnect(bool bKill)
{
    for (unsigned i = 0; i < getNumChildren(); ++i) {
        getChild(i)->disconnect(bKill);
    }
    if (m_pClipVertexes) {
        m_pClipVertexes = VertexArrayPtr();
    }
    AreaNode::disconnect(bKill);
}
예제 #10
0
void LFSCProof::calcL( std::vector< int >& lget, std::vector< int >& lgetu ){
  for( int a=0; a<getNumChildren(); a++ ){
    getChild( a )->calcL( lget, lgetu );
  }
  if( assumeVar!=-1 && std::find( lget.begin(), lget.end(), assumeVar )==lget.end() ){
    lget.push_back( assumeVar );
  }
  if( assumeVarUsed!=-1 && std::find( lgetu.begin(), lgetu.end(), assumeVarUsed )==lgetu.end() ){
    lgetu.push_back( assumeVarUsed );
  }
}
예제 #11
0
파일: KeyItem.cpp 프로젝트: kushview/ksp1
 void KeyItem::clearLayers()
 {
     for (int32 i = getNumChildren(); --i >= 0;)
     {
         ValueTree vt = objectData.getChild (i);
         if (vt.hasType (Tags::layer))
         {
             objectData.removeChild (vt, nullptr);
         }
     }
 }
예제 #12
0
int LFSCProof::checkOp() {
  if( chOp!=-1 )
    return chOp;
  if( getNumChildren()==1 )
    return getChild( 0 )->checkOp();
  else{
    int ret = -1;
    for( int a=0; a<getNumChildren(); a++ ){
      int o = getChild( a )->checkOp();
      if( a!=-1 ){
        if( ret==-1 )
          ret = a;
        else
          return -1;
      }
    }
    //cout << "fail case " << getNumChildren() << std::endl;
    return ret;
  }
}
예제 #13
0
void DivNode::render(GLContext* pContext, const glm::mat4& transform)
{
    if (getCrop() && getSize() != glm::vec2(0,0)) {
        getCanvas()->pushClipRect(pContext, transform, m_ClipVA);
    }
    for (unsigned i = 0; i < getNumChildren(); i++) {
        getChild(i)->maybeRender(pContext, transform);
    }
    if (getCrop() && getSize() != glm::vec2(0,0)) {
        getCanvas()->popClipRect(pContext, transform, m_ClipVA);
    }
}
예제 #14
0
IWidget * ILayoutBox::getChild(int pos) const
{
    if (pos < 0 || pos > getNumChildren())
    {
        return nullptr;
    }

    std::list<TLayoutItem>::const_iterator it = m_children.begin();
    std::advance(it, pos);

    return (it == m_children.end() ? nullptr : it->widget);
}
예제 #15
0
void FromFileNode::createGeode(void) {
    removeChildren(0, getNumChildren());

    // Get the fromFile
    FromFile* fromFile = static_cast<FromFile*>(_lego);

    // Get file name
    QString fileName = fromFile->getFileName();

    // Read osg file
    addChild(osgDB::readNodeFile(fileName.toStdString()));
}
예제 #16
0
void
IntersectActor::setupChildrenPriorities(void)
{
    UInt32 numChildren      = getNumChildren     ();
    UInt32 numExtraChildren = getNumExtraChildren();

    Real32 scaleFactor      = getScaleFactor();
    Real32 hitDist          = getHitDistance();
    Real32 bvEnter;
    Real32 bvExit;

    setChildrenListEnabled(true);

    for(UInt32 i = 0; i < numChildren; ++i)
    {
#ifndef OSG_2_PREP
        const DynamicVolume &vol = getChild(i)->editVolume(true);
#else
        const BoxVolume     &vol = getChild(i)->editVolume(true);
#endif

        if((vol.intersect(getRay(), bvEnter, bvExit) == true   ) &&
           (bvEnter * scaleFactor                    <  hitDist)   )
        {
            setChildPriority(i, -bvEnter * scaleFactor);
        }
        else
        {
            setChildActive  (i, false);
        }
    }

    for(UInt32 i = 0; i < numExtraChildren; ++i)
    {
#ifndef OSG_2_PREP
        const DynamicVolume &vol = getChild(i)->editVolume(true);
#else
        const BoxVolume     &vol = getChild(i)->editVolume(true);
#endif

        if((vol.intersect(getRay(), bvEnter, bvExit) == true   ) &&
           (bvEnter * scaleFactor                    <  hitDist)   )
        {
            setExtraChildPriority(i, -bvEnter * scaleFactor);
        }
        else
        {
            setExtraChildActive  (i, false);
        }
    }
}
예제 #17
0
Project::Item Project::Item::addNewSubGroup (const String& name, int insertIndex)
{
    String newID (createGUID (getID() + name + String (getNumChildren())));

    int n = 0;
    while (findItemWithID (newID).isValid())
        newID = createGUID (newID + String (++n));

    Item group (createGroup (project, name, newID));

    jassert (canContain (group));
    addChild (group, insertIndex);
    return group;
}
/*! \fn SoXipTransparentGeometryGroup::getChildByType(const SoType &type) const
*  Returns a child node of the given type if any, otherwise return null.
*  \param action - the current state action
*  \return void
*/
SoNode *SoXipTransparentGeometryGroup::getChildByType(const SoType &type) const
{
	for (int i = 0; i < getNumChildren(); i++)
	{
		SoNode *child = getChild(i);
		
		if (child->isOfType(type))
		{
			return child;
		}
	}

	return 0;
}
예제 #19
0
void Project::Item::initialiseMissingProperties()
{
    if (! state.hasProperty (Ids::ID))
        setID (createAlphaNumericUID());

    if (isFile())
    {
        state.setProperty (Ids::name, getFile().getFileName(), nullptr);
    }
    else if (isGroup())
    {
        for (int i = getNumChildren(); --i >= 0;)
            getChild(i).initialiseMissingProperties();
    }
}
예제 #20
0
void TOutline::writeNode(TNode *node, opstream &op) {
   uchar more = (node->next != 0) ? 1 : 0;
   uchar expand = (node->expanded) ? 1 : 0;

   op << more;
   op << expand;
   op << getNumChildren(node);
   op.writeString(node->text);

   if (node->childList != 0)
      writeNode(node->childList, op);

   if (node->next != 0)
      writeNode(node->next, op);
}
예제 #21
0
AssetTree::Item
AssetTree::Item::addNewSubGroup (const String& name, int insertIndex)
{
    String newID (Utility::createGUID (getId() + name + String (getNumChildren())));
    
    int n = 0;
    while (tree.root().findItemForId (newID).isValid())
        newID = Utility::createGUID (newID + String (++n));
    
    Item group (createGroup (tree, name, newID));
    
    jassert (canContain (group));
    addChild (group, insertIndex);
    return group;
}
예제 #22
0
void Project::Item::initialiseNodeValues()
{
    if (! node.hasProperty (Ids::id_))
        node.setProperty (Ids::id_, createAlphaNumericUID(), 0);

    if (isFile())
    {
        node.setProperty (Ids::name, getFile().getFileName(), 0);
    }
    else if (isGroup())
    {
        for (int i = getNumChildren(); --i >= 0;)
            getChild(i).initialiseNodeValues();
    }
}
예제 #23
0
std::string TreeNode::to_string() {
  if (m_children.empty()) {
    return m_node->to_string();
  }

  stringstream ss;
  ss << m_node->to_string() << "(";
  for (unsigned int i = 0; i < getNumChildren(); i++) {
    ss <<getChild(i)->to_string();
    if (i < m_children.size()-1) {
      ss << ", ";
    }
  }
  ss << ")";
  return ss.str();
}
예제 #24
0
Project::Item Project::Item::findItemWithID (const String& targetId) const
{
    if (state [Ids::ID] == targetId)
        return *this;

    if (isGroup())
    {
        for (int i = getNumChildren(); --i >= 0;)
        {
            Item found (getChild(i).findItemWithID (targetId));
            if (found.isValid())
                return found;
        }
    }

    return Item (project, ValueTree::invalid);
}
예제 #25
0
void DivNode::preRender(const VertexArrayPtr& pVA, bool bIsParentActive, 
        float parentEffectiveOpacity)
{
    Node::preRender(pVA, bIsParentActive, parentEffectiveOpacity);
    if (getCrop() && getSize() != glm::vec2(0,0)) {
        pVA->startSubVA(m_ClipVA);
        glm::vec2 viewport = getSize();
        m_ClipVA.appendPos(glm::vec2(0,0), glm::vec2(0,0), Pixel32(0,0,0,0));
        m_ClipVA.appendPos(glm::vec2(0,viewport.y), glm::vec2(0,0), Pixel32(0,0,0,0));
        m_ClipVA.appendPos(glm::vec2(viewport.x,0), glm::vec2(0,0), Pixel32(0,0,0,0));
        m_ClipVA.appendPos(viewport, glm::vec2(0,0), Pixel32(0,0,0,0));
        m_ClipVA.appendQuadIndexes(0, 1, 2, 3);
    }
    for (unsigned i = 0; i < getNumChildren(); i++) {
        getChild(i)->preRender(pVA, bIsParentActive, getEffectiveOpacity());
    }
}
예제 #26
0
Project::Item Project::Item::findItemForFile (const File& file) const
{
    if (getFile() == file)
        return *this;

    if (isGroup())
    {
        for (int i = getNumChildren(); --i >= 0;)
        {
            Item found (getChild(i).findItemForFile (file));

            if (found.isValid())
                return found;
        }
    }

    return Item (project, ValueTree::invalid);
}
예제 #27
0
void ILayoutBox::removeChild(int pos)
{
    if (pos < 0 || pos >= getNumChildren())
    {
        return;
    }

    std::list<TLayoutItem>::iterator it = m_children.begin();
    std::advance(it, pos);

    if (it != m_children.end())
    {
        it->widget->setParent(nullptr);
        m_children.erase(it);

        computeSize();
    }
}
예제 #28
0
void Data::OsgNode::setScale( float val )
{
	VizNode::setScale( val );
	const osg::Vec3 scale( val, val, val );
	for ( uint i = 0; i < getNumChildren(); ++i ) {
		auto childTransform = getChild( i )->asTransform();
		if ( childTransform ) {
			auto at = dynamic_cast<osg::AutoTransform*>( childTransform );
			auto pat = dynamic_cast<osg::PositionAttitudeTransform*>( childTransform );
			if ( at ) {
				at->setScale( scale );
			}
			if ( pat ) {
				pat->setScale( scale );
			}
		}
	}
}
예제 #29
0
void CLayoutVertical::addChild(IWidget * widget, TAlignment align, int pos, int stretch)
{
    if (widget && !isChild(widget))
    {
        widget->setParent(this);

        int i = 0;
        int y = 0;

        TLayoutItem tmp;
        tmp.widget  = widget;
        tmp.align   = align;
        tmp.stretch = stretch;
        tmp.size    = widget->getHeight() + m_padding.getTop() + m_padding.getBottom();

        // On insère l'objet à la fin de la liste
        if (pos < 0 || pos >= getNumChildren())
        {
            m_children.push_back(tmp);
        }
        else
        {
            for (std::list<TLayoutItem>::iterator it = m_children.begin(); it != m_children.end(); ++it, ++i)
            {
                if (i == pos)
                {
                    it = m_children.insert(it, tmp);
                    y += tmp.size;
                }

                y += it->widget->getHeight();
            }
        }

        if (y > m_height)
        {
            setHeight(y);
        }
        else
        {
            computeSize();
        }
    }
}
예제 #30
0
	Movable *Camera::clone (std::string newName, Movable *parent)
	{
		RadXML *ogrGame = RadXML::getSingletonPtr ();
		Camera *clone = new Camera (*this);

		clone->setName (newName);
		clone->create (0, parent);
		clone->removeAllChildren ();

		for (unsigned int iIdx = 0; iIdx < getNumChildren (); iIdx++)
		{
			Movable *mChild = getChild (iIdx);
			Movable *mSubClone = mChild->clone (clone->getName () + "_sub", clone);
		}

		ogrGame->getCurrentXMLFile ()->addMovable (clone);

		return (clone);
	}