Example #1
0
void ThemeMenu::SetupMainButtons()
{
	ThemeList.clear();

	DirList ThemeDir(Settings.theme_path, ".them", DirList::Files);
	if (ThemeDir.GetFilecount() == 0)
	{
		WindowPrompt(tr( "No themes found." ), 0, "OK");
	}

	for(int i = 0; i < ThemeDir.GetFilecount(); ++i)
	{
		u8 *buffer = NULL;
		u32 filesize;
		debughelper_printf("%i %s\n", i, ThemeDir.GetFilepath(i));
		LoadFileToMem(ThemeDir.GetFilepath(i), &buffer, &filesize);

		if(!buffer) continue;

		buffer[filesize-1] = '\0';

		int size = ThemeList.size();
		ThemeList.resize(size+1);

		ThemeList[size].Filepath = ThemeDir.GetFilepath(i);
		GetNodeText(buffer, "Theme-Title:", ThemeList[size].Title);
		GetNodeText(buffer, "Theme-Team:", ThemeList[size].Team);
		GetNodeText(buffer, "Theme-Version:", ThemeList[size].Version);
		GetNodeText(buffer, "Image-Folder:", ThemeList[size].ImageFolder);

		if(ThemeList[size].Title.size() == 0 && ThemeDir.GetFilename(i))
		{
			ThemeList[size].Title = ThemeDir.GetFilename(i);
			size_t pos = ThemeList[size].Title.rfind('.');
			if(pos != std::string::npos)
				ThemeList[size].Title.erase(pos);
		}

		if(ThemeList[size].ImageFolder.size() == 0)
		{
			ThemeList[size].ImageFolder = ThemeDir.GetFilepath(i);
			size_t pos = ThemeList[size].ImageFolder.rfind('.');
			if(pos != std::string::npos)
				ThemeList[size].ImageFolder.erase(pos);
			ThemeList[size].ImageFolder += '/';
		}
		else
		{
			std::string tempString = ThemeList[size].ImageFolder;
			ThemeList[size].ImageFolder = Settings.theme_path;
			ThemeList[size].ImageFolder += tempString;
			ThemeList[size].ImageFolder += '/';
		}

		SetMainButton(size, ThemeList[size].Title.c_str(), MainButtonImgData, NULL);

		free(buffer);
	}
}
Example #2
0
wxObject *wxCheckListBoxXmlHandler::DoCreateResource()
{
    if (m_class == wxT("wxCheckListBox"))
    {
        // need to build the list of strings from children
        m_insideBox = true;
        CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));

        XRC_MAKE_INSTANCE(control, wxCheckListBox)

        control->Create(m_parentAsWindow,
                        GetID(),
                        GetPosition(), GetSize(),
                        strList,
                        GetStyle(),
                        wxDefaultValidator,
                        GetName());

        // step through children myself (again.)
        wxXmlNode *n = GetParamNode(wxT("content"));
        if (n)
            n = n->GetChildren();
        int i = 0;
        while (n)
        {
            if (n->GetType() != wxXML_ELEMENT_NODE ||
                n->GetName() != wxT("item"))
               { n = n->GetNext(); continue; }

            // checking boolean is a bit ugly here (see GetBool() )
            wxString v = n->GetAttribute(wxT("checked"), wxEmptyString);
            v.MakeLower();
            if (v == wxT("1"))
                control->Check( i, true );

            i++;
            n = n->GetNext();
        }

        SetupWindow(control);

        strList.Clear();    // dump the strings

        return control;
    }
    else
    {
        // on the inside now.
        // handle <item checked="boolean">Label</item>

        // add to the list
        strList.Add(GetNodeText(m_node, wxXRC_TEXT_NO_ESCAPE));
        return NULL;
    }
}
Example #3
0
wxObject *wxComboBoxXmlHandler::DoCreateResource()
{
    if( m_class == wxT("wxComboBox"))
    {
        // find the selection
        long selection = GetLong( wxT("selection"), -1 );

        // need to build the list of strings from children
        m_insideBox = true;
        CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));

        XRC_MAKE_INSTANCE(control, wxComboBox)

        control->Create(m_parentAsWindow,
                        GetID(),
                        GetText(wxT("value")),
                        GetPosition(), GetSize(),
                        strList,
                        GetStyle(),
                        wxDefaultValidator,
                        GetName());

        if (selection != -1)
            control->SetSelection(selection);

        SetupWindow(control);

        const wxString hint = GetText(wxS("hint"));
        if ( !hint.empty() )
            control->SetHint(hint);

        strList.Clear();    // dump the strings

        return control;
    }
    else
    {
        // on the inside now.
        // handle <item>Label</item>

        // add to the list
        strList.Add(GetNodeText(m_node, wxXRC_TEXT_NO_ESCAPE));

        return NULL;
    }
}
Example #4
0
HRESULT CSkin::Create(CHAR* szXmlFile)
{
	if (CXmlDocument::Load(szXmlFile)<0)
	{
		OutputDebugString("\nUnable to load xml file.\n");
		return E_FAIL;
	}

	XmlNode xnNode = GetNextNode(XML_ROOT_NODE);
	while (xnNode>0)
	{
		CHAR* szCurrentTag = GetNodeTag(xnNode);

		if ( !strcmpi(szCurrentTag,"mode") )
		{
			CMode* pNewMode = new CMode;
			if (SUCCEEDED(pNewMode->Create(this,xnNode)))
			{
				OutputDebugString("Enumerated mode: ");
				OutputDebugString(pNewMode->ToString().c_str());
				OutputDebugString("\n");

				m_modes[pNewMode->ToString()] = pNewMode;

				XmlNode xnDefaultMode;
				if (xnDefaultMode = GetChildNode(xnNode,"default"))
				{
					if ( !strcmpi(GetNodeText(xnDefaultMode),"true") )
						m_pDefaultMode = pNewMode;
				}

			}
			else
			{
				delete pNewMode;
			}
		}

		xnNode = GetNextNode(xnNode);
	}

	return S_OK;
}
/**
 * Check if there's a DOM word separator before aBeforeOffset in this node.
 * Always returns PR_TRUE if it's a BR element.
 * aSeparatorOffset is set to the index of the last separator if any is found
 * (0 for BR elements).
 */
static PRBool
ContainsDOMWordSeparator(nsIDOMNode* aNode, PRInt32 aBeforeOffset,
                         PRInt32* aSeparatorOffset)
{
  if (IsBRElement(aNode)) {
    *aSeparatorOffset = 0;
    return PR_TRUE;
  }
  
  if (!IsTextNode(aNode))
    return PR_FALSE;

  nsAutoString str;
  GetNodeText(aNode, str);
  for (PRInt32 i = PR_MIN(aBeforeOffset, PRInt32(str.Length())) - 1; i >= 0; --i) {
    if (IsDOMWordSeparator(str.CharAt(i))) {
      *aSeparatorOffset = i;
      return PR_TRUE;
    }
  }
  return PR_FALSE;
}
Example #6
0
/* boolean IsLinkNotInCal (in nsIDOMNode node); */
NS_IMETHODIMP nsDomAttUtil::IsLinkNotInCal(nsIDOMNode *node, PRBool *_retval )
{
     PRBool bisLink=false;
     IsLink(node, &bisLink);
     if(bisLink)
     {
	  nsCString content;
	  GetNodeText(node, content);

	  int date=atoi(content.get());

	  if(content.Length()<3&&date>0&&date<31)
	       *_retval=PR_FALSE;
	  else
	       *_retval=PR_TRUE;
     }else
     {
	  *_retval=PR_FALSE;
     }


     return NS_OK;
}
void
mozInlineSpellWordUtil::BuildSoftText()
{
  // First we have to work backwards from mSoftStart to find a text node
  // containing a DOM word separator, a non-inline-element
  // boundary, or the hard start node. That's where we'll start building the
  // soft string from.
  nsIDOMNode* node = mSoftBegin.mNode;
  PRInt32 firstOffsetInNode = 0;
  PRInt32 checkBeforeOffset = mSoftBegin.mOffset;
  while (node) {
    if (ContainsDOMWordSeparator(node, checkBeforeOffset, &firstOffsetInNode))
      break;
    checkBeforeOffset = PR_INT32_MAX;
    if (IsBreakElement(mCSSView, node)) {
      // Since FindPrevNode follows tree *preorder*, we're about to traverse
      // up out of 'node'. Since node induces breaks (e.g., it's a block),
      // don't bother trying to look outside it, just stop now.
      break;
    }
    node = FindPrevNode(node, mRootNode);
  }

  // Now build up the string moving forward through the DOM until we reach
  // the soft end and *then* see a DOM word separator, a non-inline-element
  // boundary, or the hard end node.
  mSoftText.Truncate();
  mSoftTextDOMMapping.Clear();
  PRBool seenSoftEnd = PR_FALSE;
  // Leave this outside the loop so large heap string allocations can be reused
  // across iterations
  nsAutoString str;
  while (node) {
    if (node == mSoftEnd.mNode) {
      seenSoftEnd = PR_TRUE;
    }

    PRBool exit = PR_FALSE;
    if (IsTextNode(node)) {
      GetNodeText(node, str);
      PRInt32 lastOffsetInNode = str.Length();

      if (seenSoftEnd) {
        // check whether we can stop after this
        for (PRInt32 i = node == mSoftEnd.mNode ? mSoftEnd.mOffset : 0;
             i < PRInt32(str.Length()); ++i) {
          if (IsDOMWordSeparator(str.CharAt(i))) {
            exit = PR_TRUE;
            // stop at the first separator after the soft end point
            lastOffsetInNode = i;
            break;
          }
        }
      }
      
      if (firstOffsetInNode < lastOffsetInNode) {
        PRInt32 len = lastOffsetInNode - firstOffsetInNode;
        mSoftTextDOMMapping.AppendElement(
          DOMTextMapping(NodeOffset(node, firstOffsetInNode), mSoftText.Length(), len));
        mSoftText.Append(Substring(str, firstOffsetInNode, len));
      }
      
      firstOffsetInNode = 0;
    }

    if (exit)
      break;

    CheckLeavingBreakElementClosure closure = { mCSSView, PR_FALSE };
    node = FindNextNode(node, mRootNode, CheckLeavingBreakElement, &closure);
    if (closure.mLeftBreakElement || (node && IsBreakElement(mCSSView, node))) {
      // We left, or are entering, a break element (e.g., block). Maybe we can
      // stop now.
      if (seenSoftEnd)
        break;
      // Record the break
      mSoftText.Append(' ');
    }
  }
  
#ifdef DEBUG_SPELLCHECK
  printf("Got DOM string: %s\n", NS_ConvertUTF16toUTF8(mSoftText).get());
#endif
}
Example #8
0
wxObject *wxRadioBoxXmlHandler::DoCreateResource()
{
    if ( m_class == wxT("wxRadioBox"))
    {
        // find the selection
        long selection = GetLong( wxT("selection"), -1 );

        // need to build the list of strings from children
        m_insideBox = true;
        CreateChildrenPrivately( NULL, GetParamNode(wxT("content")));

        XRC_MAKE_INSTANCE(control, wxRadioBox)

        control->Create(m_parentAsWindow,
                        GetID(),
                        GetText(wxT("label")),
                        GetPosition(), GetSize(),
                        m_labels,
                        GetLong(wxT("dimension"), 1),
                        GetStyle(),
                        wxDefaultValidator,
                        GetName());

        if (selection != -1)
            control->SetSelection(selection);

        SetupWindow(control);

        const unsigned count = m_labels.size();
        for( unsigned i = 0; i < count; i++ )
        {
#if wxUSE_TOOLTIPS
            if ( !m_tooltips[i].empty() )
                control->SetItemToolTip(i, m_tooltips[i]);
#endif // wxUSE_TOOLTIPS
#if wxUSE_HELP
            if ( m_helptextSpecified[i] )
                control->SetItemHelpText(i, m_helptexts[i]);
#endif // wxUSE_HELP

            if ( !m_isShown[i] )
                control->Show(i, false);
            if ( !m_isEnabled[i] )
                control->Enable(i, false);
        }


        // forget information about the items of this radiobox, we should start
        // afresh for the next one
        m_labels.clear();

#if wxUSE_TOOLTIPS
        m_tooltips.clear();
#endif // wxUSE_TOOLTIPS

#if wxUSE_HELP
        m_helptexts.clear();
        m_helptextSpecified.clear();
#endif // wxUSE_HELP

        m_isShown.clear();
        m_isEnabled.clear();

        return control;
    }
    else // inside the radiobox element
    {
        // we handle handle <item>Label</item> constructs here, and the item
        // tag can have tooltip, helptext, enabled and hidden attributes

        // For compatibility, labels are not escaped in XRC by default and
        // label="1" attribute needs to be explicitly specified to handle them
        // consistently with the other labels.
        m_labels.push_back(GetNodeText(m_node,
                                       GetBoolAttr("label", 0)
                                        ? 0
                                        : wxXRC_TEXT_NO_ESCAPE));
#if wxUSE_TOOLTIPS
        m_tooltips.push_back(GetNodeText(GetParamNode(wxT("tooltip")),
                                         wxXRC_TEXT_NO_ESCAPE));
#endif // wxUSE_TOOLTIPS
#if wxUSE_HELP
        const wxXmlNode* const nodeHelp = GetParamNode(wxT("helptext"));
        m_helptexts.push_back(GetNodeText(nodeHelp, wxXRC_TEXT_NO_ESCAPE));
        m_helptextSpecified.push_back(nodeHelp != NULL);
#endif // wxUSE_HELP
        m_isEnabled.push_back(GetBoolAttr("enabled", 1));
        m_isShown.push_back(!GetBoolAttr("hidden", 0));

        return NULL;
    }

}
void CFootBotUN::Init(TConfigurationNode& t_node) {
	/*
	 * Get sensor/actuator handles
	 *
	 * The passed string (ex. "footbot_wheels") corresponds to the XML tag of the device
	 * whose handle we want to have. For a list of allowed values, type at the command
	 * prompt:
	 *
	 * $ launch_argos -q actuators
	 *
	 * to have a list of all the possible actuators, or
	 *
	 * $ launch_argos -q sensors
	 *
	 * to have a list of all the possible sensors.
	 *
	 * NOTE: ARGoS creates and initializes actuators and sensors internally, on the basis of
	 *       the lists provided the XML file at the <controllers><footbot_diffusion><actuators>
	 *       and <controllers><footbot_diffusion><sensors> sections. If you forgot to
	 *       list a device in the XML and then you request it here, an error occurs.
	 */
	m_pcWheels = dynamic_cast<CCI_FootBotWheelsActuator*>(GetRobot().GetActuator("footbot_wheels"));
	m_pcLEDs = dynamic_cast<CCI_FootBotLedsActuator*>(GetRobot().GetActuator("footbot_leds"));
	m_pcProximity = dynamic_cast<CCI_FootBotProximitySensor*>(GetRobot().GetSensor("footbot_proximity"));

	//Min distance to the current position to the target point to determine it this is reached (meters)
	//GetNodeAttributeOrDefault(t_node, "targetMinPointDistance", m_targetMinPointDistance, m_targetMinPointDistance);
	std::string text;

	if (NodeExists(t_node, "targetMinPointDistance")) {
		GetNodeText(GetNode(t_node, "targetMinPointDistance"), text);
		sscanf(text.c_str(), "%f", &m_targetMinPointDistance);
		//m_targetMinPointDistance = fmin(MAX_RESOLUTION, m_targetMinPointDistance);
	}

	printf("Min distance to target point %f in robot %s\n", m_targetMinPointDistance, GetRobot().GetRobotId().c_str());

//////////////////////////////////////////////////////////////
// Initialize things required by the communications
//////////////////////////////////////////////////////////////
	m_pcWifiSensor = dynamic_cast<CCI_WiFiSensor*>(GetRobot().GetSensor("wifi"));
	m_pcWifiActuator = dynamic_cast<CCI_WiFiActuator*>(GetRobot().GetActuator("wifi"));
	str_Me = GetRobot().GetRobotId();
	m_iSendOrNotSend = 0;

	// How many robots are there ?
	CSpace::TAnyEntityMap& tEntityMap = m_cSpace.GetEntitiesByType("wifi_equipped_entity");
	numberOfRobots = tEntityMap.size();
	printf("%s: There are %d robots [RMAGAN]\n", str_Me.c_str(), numberOfRobots);

	// Am I a generator?
	amIaGenerator = false;
	skipFirstSend = true;
	int numGenerators = m_numberOfGenerators * numberOfRobots;
	int myID = atoi(str_Me.c_str() + 3);
	if (myID < numGenerators)
		amIaGenerator = true;
	if (amIaGenerator)
		printf("%s: There are %d generators, I am on of them\n", str_Me.c_str(), numGenerators);
	else
		printf("%s: There are %d generators, but not me :-(\n", str_Me.c_str(), numGenerators);

	if (amIaGenerator) {
		UInt32 id = CSimulator::GetInstance().GetRNG()->Uniform(CRange<UInt32>(numGenerators, numberOfRobots));
		//UInt32 id = myID + numGenerators;
		std::ostringstream str_tmp(ostringstream::out);
		str_tmp << "fb_" << id;
		str_Dest = str_tmp.str();
		printf(" (dest=%s).\n", str_Dest.c_str());
	}

	//////////////////////////////////////////////////////////////
	// end of communications things here
	//////////////////////////////////////////////////////////////

	/** LCM engine */
	// LCM Thread
	lcmThreadCommand.setLCMEngine("udpm://239.255.76.67:7667?ttl=1", "TARGET");
	lcmThreadCommand.startInternalThread();

	lcmThread.setLCMEngine("udpm://239.255.76.67:7667?ttl=1", "TRACK");
	lcmThread.startInternalThread();
	/** NAVIGATION AND AVOIDING COLLISION */
	/* Additional sensors */
	encoderSensor = dynamic_cast<CCI_FootBotEncoderSensor*>(GetRobot().GetSensor("footbot_encoder"));

	/* Init navigation methods */
	initOdometry();
	initLocalNavigation(t_node);

}
Example #10
0
bool RecursiveGladeImport(nuiXMLNode* pFrom, nuiXMLNode* pTo)
{
  bool havechildren = true;
  nglString Name;
  if (! pFrom || !pTo)
    return false;

  Name = pFrom->GetName();
  if (Name == _T("widget"))
  {
    nuiXMLNode* pNode = pFrom->GetChild(nglString(_T("class")));

    if (pNode)
    {
      nuiXMLNode* pTextNode = pNode->GetChild(nglString(_T("##text")));
      if (pTextNode)
      {
        if (pTextNode->GetValue() == nglString(_T("GtkWindow")) )
        {
          pTo->SetName( nglString(_T("nuiWindow")) );
          pTo->SetAttribute( _T("Visible"), _T("true"));
          NodeToAttribute(pFrom, pTo, (nglChar*)_T("Title"));
          havechildren = true;
        }
        else if (pTextNode->GetValue() == nglString(_T("GtkFixed")) )
        {
          pTo->SetName( nglString(_T("nuiFixed")) );
          havechildren = true;
        }
        else if (pTextNode->GetValue() == nglString(_T("GtkList")) )
        {
          pTo->SetName( nglString(_T("nuiList")) );
          havechildren = true;
        }
        else if (pTextNode->GetValue() == nglString(_T("GtkVBox")) )
        {
          pTo->SetName( nglString(_T("nuiVBox")) );
          havechildren = true;
        }
        else if (pTextNode->GetValue() == nglString(_T("GtkHBox")) )
        {
          pTo->SetName( nglString(_T("nuiHBox")) );
          havechildren = true;
        }
        else if (pTextNode->GetValue() == nglString(_T("GtkButton")) )
        {
          pTo->SetName( nglString(_T("nuiButton")) );
          nglString label = GetNodeText(pFrom, (nglChar*)_T("label"));
          if (label!= _T(""))
          {
            nuiXMLNode* pLabel = new nuiXMLNode(nglString(_T("nuiLabel")),pTo);
            nuiXMLNode* pText = new nuiXMLNode(nglString(_T("##text")),pLabel);
            pText->SetValue(label);
          }
          havechildren = false;
        }
        else if (pTextNode->GetValue() == nglString(_T("GtkLabel")) )
        {
          pTo->SetName( nglString(_T("nuiLabel")) );
          nuiXMLNode* pText = new nuiXMLNode(nglString(_T("##text")),pTo);
          pText->SetValue(GetNodeText(pFrom, (nglChar*)_T("label")));

          havechildren = false;
        }
        else if (pTextNode->GetValue() == nglString(_T("GtkText")) )
        {
          if (GetNodeText(pFrom, (nglChar*)_T("editable")) == nglString(_T("True")))
            pTo->SetName( nglString(_T("nuiEditText")) );
          else
            pTo->SetName( nglString(_T("nuiText")) );
          nglString text = GetNodeText(pFrom, (nglChar*)_T("text"));
          if (text!= _T(""))
          {
            nuiXMLNode* pText = new nuiXMLNode(nglString(_T("##text")),pTo);
            pText->SetValue(text);
          }
          havechildren = false;
        }
        else 
          return false;
      }
      else 
        return false;
    }
    else 
      return false;

    if (!NodeToAttribute(pFrom, pTo, (nglChar*)_T("name")))
      return false;

    NodeToAttribute(pFrom, pTo, (nglChar*)_T("x"),(nglChar*) _T("X"));
    NodeToAttribute(pFrom, pTo, (nglChar*)_T("y"), (nglChar*)_T("Y"));
    NodeToAttribute(pFrom, pTo, (nglChar*)_T("width"), (nglChar*)_T("Width"));
    NodeToAttribute(pFrom, pTo, (nglChar*)_T("height"), (nglChar*)_T("Height"));


    if (havechildren)
    {
      uint i, count = pFrom->GetChildrenCount();
      for (i=0; i<count; i++)
      {
        nuiXMLNode* pFromNode = pFrom->GetChild(i);
        if (pFromNode->GetName() == nglString(_T("widget")))
        {
          nuiXMLNode* pToNode = new nuiXMLNode(nglString(_T("importing")), pTo);
          if (!RecursiveGladeImport(pFromNode,pToNode))
          {
            // If there was an error just kill the new node...
            pTo->DelChild(pToNode);
            delete pToNode;
          }
        }
      }
    }

  }

  return true;
}
int CPlaneText::to_mathml__getTag_n_Text( 
        std::vector<QString>& v_tag, std::vector<QString>& v_text, std::vector<QString>& v_attr, long /*level*/ )
{
	if( to_mathml_data.value.length() && to_mathml_data.type.length() )
	{
		v_tag.push_back( to_mathml_data.type );
		v_text.push_back( to_mathml_data.value );
	}
	else
	{
		QString bodytext( GetNodeText() );
		if( isUnicode() )
		{
			if( to_mathml_data.name.length() )
				v_tag.push_back( to_mathml_data.name );
			else
				v_tag.push_back( QString(FBL_TAG_mi) );
			v_text.push_back( bodytext );
		}
		else
		{
			int ret = 0;
			long cb, i;
			LMMLChar mmlsl( getFStyle() == FSTYLE_GREEK, getFStyle() == FSTYLE_NUMBER, getFStyle() == FSTYLE_VARIABLE || getFStyle() == FSTYLE_FUNCTION, getFStyle() == FSTYLE_TEXT );
			for(cb = 0;;)
			{
				ret = mmlsl.Analisys( bodytext.midRef(cb) );
				if( !ret ) break;
				if( mmlsl.GetRead() > 0 && !mmlsl.getTag().isEmpty() && !mmlsl.getText().isEmpty() )
				{
					v_tag.push_back( mmlsl.getTag() );
					v_text.push_back( mmlsl.getText() );
				}
				cb += mmlsl.GetRead();
				mmlsl.reset();
			}
			
			if( getFStyle() == FSTYLE_TEXT )
			{
				QString s_tag = FBL_TAG_mtext, s_text = _T("");
            
				for( i = 0; i < (long) v_text.size(); i++ )
					s_text += v_text[ i ];
            
				v_tag.erase( v_tag.begin(), v_tag.end() );
				v_tag.push_back( s_tag );
				v_text.erase( v_text.begin(), v_text.end() );
				v_text.push_back( s_text );
			}
			else if( getFStyle() == FSTYLE_OP )
			{
				QString s_tag = FBL_TAG_mo, s_text = _T("");
            
				for( i = 0; i < (long) v_text.size(); i++ )
					s_text += v_text[ i ];
            
				v_tag.erase( v_tag.begin(), v_tag.end() );
				v_tag.push_back( s_tag );
				v_text.erase( v_text.begin(), v_text.end() );
				v_text.push_back( s_text );
			}
		}
	}

	int isDefaultMMLChanged = 0, nTmp = 0;
	long j;
	for( long i = 0; i < (long) v_tag.size(); i++ )
	{
		if( v_text[ i ].length() )
		{
			QString& topr = v_text[ i ];
			if( topr[ 0 ] == _T(' ') )
			{
				topr[ 0 ] = _T('&');
				topr.insert(1, _T("nbsp;") );
			}
			if( topr.length() > 1 && topr[ topr.length() - 1 ] == ' ' )
			{
				topr[ topr.length() - 1 ] = _T('&');
				topr.append( _T("nbsp;") );
			}
			for( j = 0; j < (long) topr.length() - 1; j++ )
			{
				if( topr.at(j) == ' ' && topr.at(j + 1) == ' ' )
				{
					topr[ (int) (j + 1) ] = '&';
					topr.insert( j + 2, "nbsp;" );
					j += 6;
				}
			}
		}
		v_attr.push_back( to_mathml__get_attribute_str( v_tag[ i ], v_text[ i ], &nTmp ) );
		isDefaultMMLChanged = isDefaultMMLChanged || nTmp;
	}
	return isDefaultMMLChanged;
}
Example #12
0
void Agent::Init(TConfigurationNode& t_tree) {
	maxSpeed = MAX_SPEED;
	leftWheelSpeed = 0.0;
	rightWheelSpeed = 0.0;
	linearSpeedIsContinuos = DEFAULT_LINEAR_SPEED_CONTINUOUS;
	maxRotationSpeed = DEFAULT_MAX_ANGULAR_SPEED;
	radius = RADIUS;
	optimalSpeed = DEFAULT_OPTIMAL_SPEED;
	rotationTau = DEFAULT_ROTATION_TAU;

	socialRadius[HUMAN] = DEFAULT_HUMAN_SOCIAL_RADIUS;
	socialRadius[FOOTBOT] = DEFAULT_FOOTBOT_SOCIAL_RADIUS;
	socialRadius[OBSTACLE] = DEFAULT_OBSTACLE_SOCIAL_RADIUS;
	safetyMargin = 0.1;
	socialMargin = 0.1;
	ratioOfSocialRadiusForSensing = DEFAULT_SOCIAL_SENSING_RATIO;

	horizon = DEFAULT_HORIZON;

	if (NodeExists(t_tree, "mobility")) {
		TConfigurationNode node = GetNode(t_tree, "mobility");

		if (node.HasAttribute("continuous"))
			GetNodeAttribute(node, "continuous", linearSpeedIsContinuos);
		if (node.HasAttribute("rotation_max_speed"))
			GetNodeAttribute(node, "rotation_max_speed", maxRotationSpeed);

	}

	std::string text;

	if (NodeExists(t_tree, "horizon")) {
		GetNodeText(GetNode(t_tree, "horizon"), text);
		sscanf(text.c_str(), "%f", &horizon);
	}

	if (NodeExists(t_tree, "optimalSpeed")) {
		GetNodeText(GetNode(t_tree, "optimalSpeed"), text);
		sscanf(text.c_str(), "%f", &optimalSpeed);
	}

	if (NodeExists(t_tree, "maxSpeed")) {
		GetNodeText(GetNode(t_tree, "maxSpeed"), text);
		sscanf(text.c_str(), "%f", &maxSpeed);
	}

	if (NodeExists(t_tree, "safetyMargin")) {
		GetNodeText(GetNode(t_tree, "safetyMargin"), text);
		sscanf(text.c_str(), "%f", &safetyMargin);
		safetyMargin = fmax(0.01, safetyMargin);
	}

	if (NodeExists(t_tree, "socialMargin")) {
		GetNodeText(GetNode(t_tree, "socialMargin"), text);
		sscanf(text.c_str(), "%f", &socialMargin);
		//safetyMargin=fmax(safetyMargin,socialMargin);
	}

	if (NodeExists(t_tree, "socialRadius")) {
		TConfigurationNode node = GetNode(t_tree, "socialRadius");
		std::string text = "";
		if (node.HasAttribute("footbot")) {
			GetNodeAttribute(node, "foobot", text);
			Real d;
			scanf(text.c_str(), "%f", &d);
			socialRadius[FOOTBOT] = d;
		}
		if (node.HasAttribute("human")) {
			GetNodeAttribute(node, "human", text);
			Real d;
			scanf(text.c_str(), "%f", &d);
			socialRadius[HUMAN] = d;
		}
		if (node.HasAttribute("obstacle")) {
			GetNodeAttribute(node, "obstacle", text);
			Real d;
			scanf(text.c_str(), "%f", &d);
			socialRadius[OBSTACLE] = d;
		}
	}
	if (NodeExists(t_tree, "rotationTau")) {
		GetNodeText(GetNode(t_tree, "rotationTau"), text);
		sscanf(text.c_str(), "%f", &rotationTau);
		rotationTau = fmax(0.1, rotationTau);
	}

	printf("Agent Init: sM %.2f, SM %.2f, horizon %.2f optimal speed %.2f max speed %.2f rotation tau %.2f max rotation speed %.2f\n",
	       safetyMargin,
	       socialMargin,
	       horizon,
	       optimalSpeed,
	       maxSpeed,
	       rotationTau,
	       maxRotationSpeed);
	//DEBUG_CONTROLLER("Mobility Settings: maxRotationSpeed %.2f, linearSpeedIsContinuos %d \r\n",maxRotationSpeed,linearSpeedIsContinuos);

}