//添加元素
void FilterParameter::addQDomElement(FilterParameterSet &par, QDomElement &np)
{
		QString name=np.attribute("name");
		QString type=np.attribute("type");

		qDebug("    Reading Param with name %s : %s",qPrintable(name),qPrintable(type));

		if(type=="Bool")    { par.addBool(name,np.attribute("value")!=QString("false")); return; }
		if(type=="Int")     { par.addInt(name,np.attribute("value").toInt()); return; }
		if(type=="Float")   { par.addFloat(name,np.attribute("value").toDouble()); return; }
		if(type=="String")  { par.addString(name,np.attribute("value")); return; }
		if(type=="AbsPerc") { par.addAbsPerc(name,np.attribute("value").toFloat(),np.attribute("min").toFloat(),np.attribute("max").toFloat()); return; }
		if(type=="Color")		{ par.addColor(name,QColor::QColor(np.attribute("rgb").toUInt())); return; }
		if(type=="Matrix44")
		{
		  Matrix44f mm;
			for(int i=0;i<16;++i)
					mm.V()[i]=np.attribute(QString("val")+QString::number(i)).toDouble();
			par.addMatrix44(name,mm);    
			return;                    
		}
		if(type=="Enum")
		{
			QStringList list = QStringList::QStringList();
			for(QDomElement ns = np.firstChildElement("EnumString"); !ns.isNull(); ns = ns.nextSiblingElement("EnumString")){
				list<<ns.attribute("value");
			}
			par.addEnum(name,np.attribute("value").toInt(),list);
			return;
		}
		
		if(type == MeshPointerName())  { par.addMesh(name, np.attribute(ValueName()).toInt()); return; }
		if(type == FloatListName())
		{
			QList<float> values;
			for(QDomElement listItem = np.firstChildElement(ItemName());
					!listItem.isNull();
					listItem = listItem.nextSiblingElement(ItemName()))
			{
					values.append(listItem.attribute(ValueName()).toFloat()); 
				}
			par.addFloatList(name,values);
			return;
		}
			
		if(type == DynamicFloatName())  { par.addDynamicFloat(name, np.attribute(ValueName()).toFloat(), np.attribute(MinName()).toFloat(), np.attribute(MaxName()).toFloat(), np.attribute(MaskName()).toInt()); return; }
		if(type == OpenFileNameName())  { par.addOpenFileName(name, np.attribute(ValueName())); return; }
		if(type == SaveFileNameName())  { par.addSaveFileName(name, np.attribute(ValueName())); return; }
		if(type=="Point3f") 
		{
			Point3f val;
			val[0]=np.attribute("x").toFloat();
			val[1]=np.attribute("y").toFloat();
			val[2]=np.attribute("z").toFloat();
			par.addPoint3f(name, val);  
			return; 
		}

		assert(0); // we are trying to parse an unknown xml element
}
Ejemplo n.º 2
0
// This function define the needed parameters for each filter. 
void RangeMapPlugin::initParameterSet(QAction *action, MeshDocument &m, FilterParameterSet & parlst) 
{
	 switch(ID(action))	 
	 {
		case FP_SELECTBYANGLE :
			{
				parlst.addDynamicFloat("anglelimit",
															 75.0f, 0.0f, 180.0f, MeshModel::MM_FACEFLAGSELECT,
												"angle threshold (deg)",
												"faces with normal at higher angle w.r.t. the view direction are selected");
	 		  parlst.addBool ("usecamera",
												false,
												"Use ViewPoint from Mesh Camera",
												"Uses the ViewPoint from the camera associated to the current mesh\n if there is no camera, an error occurs");
				parlst.addPoint3f("viewpoint",
												Point3f(0.0f, 0.0f, 0.0f),
												"ViewPoint",
												"if UseCamera is true, this value is ignored");
			}
			break;
											
		default : assert(0); 
	}
}