示例#1
0
vector< Geom* > GeomScreen::s_get_geom(deque< Stringc > selectVec)
{
	vector< Geom * > geomVec;
	for (int i = 0; i < (int)selectVec.size(); i++)
	{	// select geoms
		Stringc name = selectVec[i];
		name.trim('\"');
		vector<Geom *> gVec;

		if (name.get_length() > 0 && name[0] == '+')
		{	// + indicates children selection
			name.remove_leading('+');
			gVec = aircraftPtr->getGeomByName(name, 1);
		}
		else
		{
			gVec = aircraftPtr->getGeomByName(name, 0);
		}

		for (int j = 0; j < (int)gVec.size(); j++)
		{	// add all geoms that are not already in the list
			vector< Geom* >::iterator giter = find(geomVec.begin(), geomVec.end(), gVec[j]);
			if (giter == geomVec.end())
				geomVec.push_back(gVec[j]);
		}
	}
	return geomVec;
}
void PHolderListMgr::ReadPHolderListDES( char *newfile )
{
	FILE *fp;
	fp = fopen( newfile, "r" );
	char temp[255];

	fgets( temp, 255, fp );
	Stringc line = temp;
	int nparm = line.convert_to_integer();

	if( nparm > 0 )
	{
		pHolderListMgrPtr->DelAllPHolders();

		vector< Geom* > gVec = aircraftPtr->getGeomVec();
		gVec.push_back( aircraftPtr->getUserGeom() );


		for ( int i = 0 ; i < nparm ; i++ )
		{
			fgets( temp, 255, fp );
			line = temp;

			int istart = 0;
			int iend = line.search_for_substring(':');
			int id = line.get_range( istart, iend-1 ).convert_to_integer();

			istart = iend + 1;
			iend = line.search_for_substring( istart, ':' );
			istart = iend + 1;
			iend = line.search_for_substring( istart, ':' );
			Stringc group = line.get_range( istart, iend-1 );

			istart = iend + 1;
			iend = line.search_for_substring( istart, ':' );
			Stringc parm = line.get_range( istart, iend-1 );

			istart = iend + 1;
			iend = line.get_length();
			double val = line.get_range( istart, iend-1 ).convert_to_double();

			Parm* p = parmMgrPtr->FindParm( gVec, id, group, parm );

			if ( p )
			{
				p->set_from_link( val );
				p->get_geom()->parm_changed( p );

				ParmHolder* ph = new ParmHolder();
				ph->setParm( p );

				m_PHolderVec.push_back( ph );
				m_CurrPHolderIndex = (int)m_PHolderVec.size() - 1;
			}
		}
	}
	fclose( fp );
}
示例#3
0
vec2d TextLabel::drawString(GLFont * glfont, float scale, Stringc str, float x0, float y0, float xoffset, float yoffset) 
{

	double w = 0; 
	double h = 0;
	if (str.get_length() > 0) {

		//alignment 
		pair< int, int > dimension;
		glfont->GetStringSize(str.get_char_star(), &dimension);
		w = ((float) dimension.first) * FONT_BASE_SCALE * scale;		
		h = ((float) dimension.second) * FONT_BASE_SCALE * scale;
		double x = x0 - w/2  + w*xoffset;
		double y = y0 + h/2 + h*yoffset;

		glfont->Begin();
		glfont->DrawString(str.get_char_star(), (float)(FONT_BASE_SCALE * scale), (float)x, (float)y);
	}
	return vec2d(w,h);
}
示例#4
0
void GeomScreen::s_add_geom(int src, int type, Stringc name)
{
	Geom* addGeom = 0;
	lastSelectedGeom = NULL;

	if ( type == POD_GEOM_TYPE )
	{
		addGeom = aircraftPtr->createGeom(POD_GEOM_TYPE);
	}
	else if ( type == WING_GEOM_TYPE )
	{
		addGeom = aircraftPtr->createGeom(WING_GEOM_TYPE);
	}
	else if ( type == FUSE_GEOM_TYPE )
	{
		addGeom = aircraftPtr->createGeom(FUSE_GEOM_TYPE);
	}
	else if ( type == HAVOC_GEOM_TYPE )
	{
		addGeom = aircraftPtr->createGeom(HAVOC_GEOM_TYPE);
	}
	else if ( type == EXT_GEOM_TYPE )
	{
		addGeom = aircraftPtr->createGeom(EXT_GEOM_TYPE);
	}
	else if ( type == MS_WING_GEOM_TYPE )
	{
		addGeom = aircraftPtr->createGeom(MS_WING_GEOM_TYPE);
	}
	else if ( type == BLANK_GEOM_TYPE )
	{
		addGeom = aircraftPtr->createGeom(BLANK_GEOM_TYPE);
	}
	else if ( type == DUCT_GEOM_TYPE )
	{
		addGeom = aircraftPtr->createGeom(DUCT_GEOM_TYPE);
	}
	else if ( type == PROP_GEOM_TYPE )
	{
		addGeom = aircraftPtr->createGeom(PROP_GEOM_TYPE);
	}
	else if ( type == ENGINE_GEOM_TYPE )
	{
		addGeom = aircraftPtr->createGeom(ENGINE_GEOM_TYPE);
	}
	else if ( type == HWB_GEOM_TYPE )
	{
		addGeom = aircraftPtr->createGeom(HWB_GEOM_TYPE);
	}
	else if ( type == FUSELAGE_GEOM_TYPE )
	{
		addGeom = aircraftPtr->createGeom(FUSELAGE_GEOM_TYPE);
	}
	else if ( type == CABIN_LAYOUT_GEOM_TYPE )
	{
		addGeom = aircraftPtr->createGeom(CABIN_LAYOUT_GEOM_TYPE);
	}

	if (addGeom && name.get_length() > 0)
	{
		addGeom->setName(name);
	}

	if (src != ScriptMgr::SCRIPT)
	{
		loadGeomBrowser();
		deselectGeomBrowser();

		if ( addGeom )
			selectGeomBrowser(addGeom);

		loadActiveGeomOutput();
		screenMgrPtr->updateGeomScreens();
		aircraftPtr->flagActiveGeom();
		loadGeomBrowser();

		if ( addGeom )
		{
			if (src == ScriptMgr::GUI) scriptMgr->addLine("add", addGeom->getTypeStr(), addGeom->getName());
		}
	}
}
void PHolderListMgr::ReadPHolderListXDDM( char *newfile )
{
	pHolderListMgrPtr->DelAllPHolders();

	//==== Read Xml File ====//
	xmlDocPtr doc;
	xmlNodePtr node;

	LIBXML_TEST_VERSION
	xmlKeepBlanksDefault(0);

	//==== Build an XML tree from a the file ====//
	doc = xmlParseFile(newfile);
//			if (doc == NULL) return 0;

	xmlNodePtr root = xmlDocGetRootElement(doc);
	if (root == NULL)
	{
		fprintf(stderr,"empty document\n");
		xmlFreeDoc(doc);
//				return 0;
	}

	vector< Geom* > gVec = aircraftPtr->getGeomVec();
	gVec.push_back( aircraftPtr->getUserGeom() );

	vector< xmlNodePtr > vlist;

	int num_v = xmlGetNumNames( root, "Variable" );
	for ( int i = 0 ; i < num_v ; i++ )
	{
		xmlNodePtr var_node = xmlGetNode( root, "Variable", i );
		vlist.push_back( var_node );
	}

	int num_c = xmlGetNumNames( root, "Constant" );
	for ( int i = 0 ; i < num_c ; i++ )
	{
		xmlNodePtr cst_node = xmlGetNode( root, "Constant", i );
		vlist.push_back( cst_node );
	}

	int num_tot = num_v + num_c;

	for ( int i = 0 ; i < num_tot ; i++ )
	{
		xmlNodePtr var_node = vlist[i];

		if ( var_node )
		{
			Stringc varname = Stringc( xmlFindPropString( var_node, "VSPVarName", " " ) );

			int istart = 0;
			int iend = varname.search_for_substring(':');
			int id = varname.get_range( istart, iend-1 ).convert_to_integer();

			istart = iend + 1;
			iend = varname.search_for_substring( istart, ':' );
			istart = iend + 1;
			iend = varname.search_for_substring( istart, ':' );
			Stringc group = varname.get_range( istart, iend-1 );

			istart = iend + 1;
			iend = varname.get_length();
			Stringc parm = varname.get_range( istart, iend-1 );

			Parm* p = parmMgrPtr->FindParm( gVec, id, group, parm );

			if ( p )
			{
				double val = xmlFindPropDouble( var_node, "Value", p->get() );

				p->set_from_link( val );
				p->get_geom()->parm_changed( p );

				ParmHolder* ph = new ParmHolder();
				ph->setParm( p );

				const xmlChar* varstr = (xmlChar*) "Variable";

				if( !xmlStrcmp(var_node->name, varstr ) )
					ph->setDesType( XDDM_VAR );
				else
					ph->setDesType( XDDM_CONST );

				m_PHolderVec.push_back( ph );
				m_CurrPHolderIndex = (int)m_PHolderVec.size() - 1;
			}
		}
	}

	//===== Free Doc =====//
	xmlFreeDoc( doc );

//			return 1;
}