Ejemplo n.º 1
0
//---------------------------------------------------------------------------
// Read from xml
//---------------------------------------------------------------------------
bool VisusBorderAxis::fromXML(XMLNode& node)
{
  if (strcmp(XML_TAG, node.getName())) 
  {
    std::stringstream ss;
    ss << "VisusBorderAxis did not receive its top level node. received (" << node.getName() << ")\n";
    vwarning(ss.str().c_str());
    vverbose(ss.str().c_str(), VISUS_XML_VERBOSE);
    return false;
  }

  XMLNode child = node.getChildNode("label");
  XMLNode text  = child.getChildNode(0);
  if (! mLabel.fromXML(text)) {
    vwarning("Failed to retrieve label text for VisusBorderAxis");
    return false;
  }

  mDrawLabels = xmltobool(node.getAttribute("drawLabel"), mDrawLabels);
  mLabelPosition = (AXISSide) xmltoi(node.getAttribute("labelPosition"), mLabelPosition);
  mLabelAlignment = (AXISAlignment) xmltoi(node.getAttribute("labelAlignment"), mLabelAlignment);
  mLabelOffset = xmltof(node.getAttribute("labelOffset"), mLabelOffset);

  child = node.getChildNode("legend");
  text  = child.getChildNode(0);
  if (! mLegend.fromXML(text)) {
    vwarning("Failed to retrieve label text for VisusBorderAxis");
    return false;
  }

  mDrawLegend = xmltobool(node.getAttribute("drawLegend"), mDrawLegend);
  mLegendPosition = (AXISSide) xmltoi(node.getAttribute("legendPosition"), mLegendPosition);
  mLegendAlignment= (AXISAlignment) xmltoi(node.getAttribute("legendAlignment"), mLegendAlignment);
  mLegendOffset = xmltof(node.getAttribute("legendOffset"), mLegendOffset);

  mDrawTicks = xmltobool(node.getAttribute("drawTicks"), mDrawTicks);
  mMajorTickLength = xmltof(node.getAttribute("majorTickLength"), mMajorTickLength);
  mMajorTickThickness = xmltof(node.getAttribute("majorTickThickness"), mMajorTickThickness);
  mMinorTickLength = xmltof(node.getAttribute("minorTickLength"), mMinorTickLength);
  mMinorTickThickness = xmltof(node.getAttribute("minorTickThickness"), mMinorTickThickness);
  mTickPosition = (AXISSide) xmltoi(node.getAttribute("tickPosition"), mTickPosition);

  mMinValue = xmltof(node.getAttribute("min"), mMinValue);
  mMaxValue = xmltof(node.getAttribute("max"), mMaxValue);
 
  mMajorTicks = xmltoi(node.getAttribute("majorTicks"), mMajorTicks);
  mMinorTicks = xmltoi(node.getAttribute("minorTicks"), mMinorTicks);
 
  XMLNode tickColor = node.getChildNode("TickColor");
  XMLNode color = tickColor.getChildNode(0);
  if (! mTickColor.fromXML(color)) {
    vwarning("Failed to retrieve tick color for VisusBorderAxis");
    return false;
  }

  return true;
}
Ejemplo n.º 2
0
bool WalkingSpeed::LoadJPSfireInfo(const std::string & projectFilename )
{
   fs::path p(projectFilename);
   std::string projectRootDir = p.parent_path().string();

     TiXmlDocument doc(projectFilename);
   if (!doc.LoadFile()) {
        Log->Write("ERROR: \t%s", doc.ErrorDesc());
        Log->Write("ERROR: \t could not parse the project file");
        return false;
   }

   TiXmlNode* JPSfireNode = doc.RootElement()->FirstChild("JPSfire");
   if( ! JPSfireNode ) {
        Log->Write("INFO:\tcould not find any JPSfire information");
        return true;
   }

   TiXmlElement* JPSfireCompElem = JPSfireNode->FirstChildElement("B_walking_speed");
   if(JPSfireCompElem) {
       if(JPSfireCompElem->FirstAttribute()){
           std::string study = xmltoa(JPSfireCompElem->Attribute("study"), "");
           std::string irritant = xmltoa(JPSfireCompElem->Attribute("irritant"), "");
           std::string extinction_grids = xmltoa(JPSfireCompElem->Attribute("extinction_grids"), "");
                   fs::path extinction_grids_path(extinction_grids);
                   fs::path file_path(projectRootDir);
                   file_path /= extinction_grids_path;
                   std::string filepath = file_path.string();  // projectRootDir + "/" + extinction_grids; //TODO: check compatibility
           //if (projectRootDir.empty()  ) // directory is "."
            //    filepath =  extinction_grids;

           double updateIntervall = xmltof(JPSfireCompElem->Attribute("update_time"), 0.);
           double finalTime = xmltof(JPSfireCompElem->Attribute("final_time"), 0.);
           Log->Write("INFO:\tJPSfire Module B_walking_speed: \n \tstudy: %s \n\tdata: %s \n\tupdate time: %.1f s | final time: %.1f s | irritant: %s",
                      study.c_str(), filepath.c_str(), updateIntervall, finalTime, irritant.c_str());
           _FMStorage = std::make_shared<FDSMeshStorage>(filepath, finalTime, updateIntervall, study, irritant);
           return true;
       }
   }
   return false;
}
Ejemplo n.º 3
0
bool VisusMeshDisplay::fromXMLLocalVariables(XMLNode& node)
{
  if (strcmp(XML_TAG, node.getName())) {
    vwarning("VisusMeshDisplay did not receive expected top node");
    return false;
  }

  mNormalIndex = xmltoi(node.getAttribute("normalIndex"), mNormalIndex);
  mColorIndex = xmltoi(node.getAttribute("colorIndex"), mColorIndex);
  mPolygonMode = xmltoi(node.getAttribute("polygonMode"), mPolygonMode);
  if (mColorIndex >= 0) 
  {
    mMinValue=xmltof(node.getAttribute("min"), mMinValue);
    mMaxValue=xmltof(node.getAttribute("max"), mMaxValue);
    mValueRange=xmltof(node.getAttribute("range"), mValueRange);
  }

  // Connect as consumer
  if (! visusXML::connectConsumer(node, "meshProducer", this, 0, &mMesh)) {
    vwarning("failed to connect as consumer while loading xml");
    return false;
  }
  return true;
}
Ejemplo n.º 4
0
bool VisusTickMarks::fromXMLLocalVariables(XMLNode& node)
{
  if (! VisusGroup::fromXMLLocalVariables(node))
    return false;

  mTMAxis = (TMAxis) xmltoi(node.getAttribute("axis"), mTMAxis);
  mLength = xmltof(node.getAttribute("length"), mLength);

  XMLNode child = node.getChildNode(VisusBorderAxis::XML_TAG);
  if (! mAxis.fromXML(child)) {
    vwarning("Failed to retrieve border axis for VisusTickMarks");
    return false;
  }

  return true;
}
Ejemplo n.º 5
0
bool VisusDoubleTime::fromXML(XMLNode& node)
{
  this->mTime = xmltof(node.getAttribute("value"), this->mTime);
  return true;
}