Example #1
0
void Marker::read(XmlReader* r)
      {
      MarkerType mt;
      while (r->readElement()) {
            QString s;
            if (r->readString("label", &s)) {
                  setLabel(s);
                  mt = markerType(s);
                  }
            else if (!Text::readProperties(r))
                  r->unknown();
            }
      switch(mt) {
            case MARKER_SEGNO:
            case MARKER_CODA:
            case MARKER_VARCODA:
            case MARKER_CODETTA:
                  setTextStyle(TEXT_STYLE_REPEAT_LEFT);
                  break;

            case MARKER_FINE:
            case MARKER_TOCODA:
                  setTextStyle(TEXT_STYLE_REPEAT_RIGHT);
                  break;

            case MARKER_USER:
                  setTextStyle(TEXT_STYLE_REPEAT);
                  break;
            }
      setMarkerType(mt);
      }
Example #2
0
void Marker::read(XmlReader& e)
      {
      MarkerType mt = MarkerType::SEGNO;

      while (e.readNextStartElement()) {
            const QStringRef& tag(e.name());
            if (tag == "label") {
                  QString s(e.readElementText());
                  setLabel(s);
                  mt = markerType(s);
                  }
            else if (!Text::readProperties(e))
                  e.unknown();
            }
      switch (mt) {
            case MarkerType::SEGNO:
            case MarkerType::VARSEGNO:
            case MarkerType::CODA:
            case MarkerType::VARCODA:
            case MarkerType::CODETTA:
                  setTextStyleType(TEXT_STYLE_REPEAT_LEFT);
                  break;

            case MarkerType::FINE:
            case MarkerType::TOCODA:
                  setTextStyleType(TEXT_STYLE_REPEAT_RIGHT);
                  break;

            case MarkerType::USER:
                  setTextStyleType(TEXT_STYLE_REPEAT);
                  break;
            }
      setMarkerType(mt);
      }
Example #3
0
void Marker::read(const QDomElement& de)
      {
      MarkerType mt = MARKER_SEGNO;
      for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {
            const QString& tag(e.tagName());
            if (tag == "label") {
                  setLabel(e.text());
                  mt = markerType(e.text());
                  }
            else if (!Text::readProperties(e))
                  domError(e);
            }
      switch (mt) {
            case MARKER_SEGNO:
            case MARKER_VARSEGNO:
            case MARKER_CODA:
            case MARKER_VARCODA:
            case MARKER_CODETTA:
                  setTextStyleType(TEXT_STYLE_REPEAT_LEFT);
                  break;

            case MARKER_FINE:
            case MARKER_TOCODA:
                  setTextStyleType(TEXT_STYLE_REPEAT_RIGHT);
                  break;

            case MARKER_USER:
                  setTextStyleType(TEXT_STYLE_REPEAT);
                  break;
            }
      setMarkerType(mt);
      }
Example #4
0
QVariant Marker::getProperty(P_ID propertyId) const
      {
      switch (propertyId) {
            case P_ID::LABEL:
                  return label();
            case P_ID::MARKER_TYPE:
                  return int(markerType());
            default:
                  break;
            }
      return Text::getProperty(propertyId);
      }
Example #5
0
Element* Marker::nextSegmentElement()
      {
      Segment* seg;
      if (markerType() == Marker::Type::FINE) {
            seg = measure()->last();
            return seg->firstElement(staffIdx());
            }
      Measure* prevMeasure = measure()->prevMeasureMM();
      if (prevMeasure) {
            seg = prevMeasure->last();
            return seg->firstElement(staffIdx());
            }
      return Element::nextSegmentElement();
      }
Example #6
0
void Marker::read(XmlReader& e)
      {
      Type mt = Type::SEGNO;

      while (e.readNextStartElement()) {
            const QStringRef& tag(e.name());
            if (tag == "label") {
                  QString s(e.readElementText());
                  setLabel(s);
                  mt = markerType(s);
                  }
            else if (!Text::readProperties(e))
                  e.unknown();
            }
      setMarkerType(mt);
      }
Example #7
0
void Marker::read(XmlReader& e)
      {
      Type mt = Type::SEGNO;

      while (e.readNextStartElement()) {
            const QStringRef& tag(e.name());
            if (tag == "label") {
                  QString s(e.readElementText());
                  setLabel(s);
                  mt = markerType(s);
                  }
            else if (!Text::readProperties(e))
                  e.unknown();
            }
      // REPEAT is obsolete, but was previously used for both left and right aligned text
      if (textStyleType() == TextStyleType::REPEAT)
            setTextStyleType(TextStyleType::REPEAT_LEFT);
      setMarkerType(mt);
      }
Example #8
0
XMLInputReader::XMLInputReader(std::string filename)
{
  XMLdoc = new tinyxml2::XMLDocument();
  targetView = -1;
  targetWidth = 0.0;
  targetHeight = 0.0;
  createImages = false;
  inputXMLFile = filename;
  if (XMLdoc->LoadFile(filename.c_str()) == tinyxml2::XML_SUCCESS)
    {
      tinyxml2::XMLElement *pRoot, *pParm;
      pRoot = XMLdoc->FirstChildElement("SEGMENTATION");
      if (pRoot == NULL)
        {
          std::cout << "The input xml file does not have element SEGMENTATION " << filename << std::endl;
          throw -1;
        }
      if (pRoot)
        {
          outputDirectory = std::string("NOT FOUND");
          modelName = std::string("NOT_FOUND");
          pParm = pRoot->FirstChildElement("OUTPUTDIRECTORY");
          if (pParm)
            {
              outputDirectory = std::string(pParm->GetText());
              const char* attr = pParm->Attribute("JPEGS");
              if (attr != NULL)
                {
                  if (std::string(attr) == "TRUE" || std::string(attr) == "true")
                    {
                      createImages = true;
                    }
                }
            }

          pParm = pRoot->FirstChildElement("MODELNAME");
          if (pParm)
            {
              modelName = std::string(pParm->GetText());
            }

          pParm = pRoot->FirstChildElement("NUMBEROFFRAMES");
          numberOfFrames = maxcapframes;
          if (pParm)
            {
              numberOfFrames = atoi(pParm->GetText());
            }
          pParm = pRoot->FirstChildElement("TARGETHEIGHT");
          if (pParm)
            {
              targetHeight = atof(pParm->GetText());
            }
          pParm = pRoot->FirstChildElement("TARGETWIDTH");
          if (pParm)
            {
              targetWidth = atof(pParm->GetText());
            }
          pParm = pRoot->FirstChildElement("TARGETVIEW");
          if (pParm)
            {
              targetView = std::string(pParm->GetText());
            }

          pParm = pRoot->FirstChildElement("BASE");
          if (pParm)
            {
              double * b = getPointData(pParm);
              base[0] = b[0];
              base[1] = b[1];
              base[2] = b[2];
              delete[] b;
            }
          pParm = pRoot->FirstChildElement("APEX");
          if (pParm)
            {
              double * a = getPointData(pParm);
              apex[0] = a[0];
              apex[1] = a[1];
              apex[2] = a[2];
              delete[] a;
            }
          pParm = pRoot->FirstChildElement("RVINSERTS");
          if (pParm)
            {
              tinyxml2::XMLNode* child = pParm->FirstChild();
              while (child != 0)
                {
                  double* rvInsert = getPointData(child->ToElement());
                  rvInserts.push_back(rvInsert);
                  child = child->NextSibling();
                }
            }
          pParm = pRoot->FirstChildElement("MARKERS"); //Returns all xml elements from the first element names MARKERS
          for (; pParm; pParm = pParm->NextSiblingElement())
            {
              if (std::string(pParm->Name()) != "MARKERS")
                {
                  continue; //Only process if the tag is of type "MARKERS"
                }

              try
                {
                  bool edset = false;
                  bool ecset = false;

                  std::string viewType = boost::to_upper_copy(std::string(pParm->Attribute("VIEW")));
                  std::string markerType("ENDO");
                  if (pParm->Attribute("TYPE"))
                    {
                      markerType = boost::to_upper_copy(std::string(pParm->Attribute("TYPE")));
                    }
                  std::string recordType = viewType + markerType;
                  this->viewType[recordType] = viewType;
                  this->markerType[recordType] = markerType;
                  if (pParm->Attribute("ED"))
                    {
                      ed[recordType] = atoi(pParm->Attribute("ED"));
                      edset = true;
                    }
                  if (pParm->Attribute("EC"))
                    {
                      ec[recordType] = atoi(pParm->Attribute("EC"));
                      ecset = true;
                    }

                  if (pParm->Attribute("BPM"))
                    {
                      bpm[recordType] = (double) atof(pParm->Attribute("BPM"));
                      ecset = true;
                    }

                  if (edset)
                    {
                      if (!ecset)
                        std::cout << " EC has not been set for " << recordType << " program may fail" << std::endl;
                    }
                  if (ecset)
                    {
                      if (!edset)
                        std::cout << " ED has not been set for " << recordType << " program may fail" << std::endl;
                    }

                  tinyxml2::XMLElement* uri = pParm->FirstChildElement("URI");
                  if (uri)
                    {
                      fileuri[recordType] = std::string(uri->GetText());
                    }
                  else
                    {
                      std::ostringstream ss;
                      ss << "FATAL: No URI associated with view " << viewType << " marker type " << markerType;
                      throw SegmentationAndFittingException(ss.str());
                    }

                  std::vector<double*> fmarkers(100); //Resize to correct no of markers
                  tinyxml2::XMLElement* child = pParm->FirstChildElement("MARKS");
                  int ctr = 0;
                  while (child != 0)
                    {
                	  if (std::string(child->Name()) == "MARKS"){
						  int myID = -1; //marker ids start from 1
						  child->QueryIntAttribute("ID", &myID);
						  if (myID > -1)
							{
							  double* point = getPointData(child);
							  fmarkers[myID] = point;
							  ctr++;
							}
						  else
							{
							  std::cout << "Failed to load the node "<< std::cout;
							  fflush(stdout);
							}
                	  }
					  child = child->NextSiblingElement();
                    }
                  fmarkers.resize(ctr + 1);
                  markers[recordType] = fmarkers;
                  //Check if ESframe information is available and if so load it
                  child = pParm->FirstChildElement("ESFRAME");
                  if(child!=0){
                	  int esframe = -1;
                	  child->QueryIntAttribute("ESFRAMENO", &esframe);
                	  std::vector<double*> baseplane(2);
                	  tinyxml2::XMLElement* fchild = child->FirstChildElement("MARKS");
                      while (fchild != 0)
                        {
                    	  if (std::string(fchild->Name()) == "MARKS"){
    						  int myID = -1; //marker ids start from 1
    						  fchild->QueryIntAttribute("ID", &myID);
    						  if (myID > -1)
    							{
    							  double* point = getPointData(fchild);
    							  baseplane[myID-1] = point;
    							}
    						  else
    							{
    							  std::cout << "Failed to load the node " << std::cout;
    							  fflush(stdout);
    							}
                    	  }
						  fchild = fchild->NextSiblingElement();
                        }
                      es[recordType] = esframe;
                      esbaseplane[recordType] = baseplane;
                  }

#ifdef debug
                  std::cout<<"Markers for "<<viewType<<"\t";
                  for(int i=1;i<ctr;i++)
                    {
                      std::cout<<fmarkers[i][0]<<" ,"<<fmarkers[i][1]<<" ";
                    }
                  std::cout<<std::endl;
#endif
                }
              catch (std::exception& ex)
                {
                  std::cout << " The input xml file does not seem to be in the appropriate format ";
                  std::cout << ex.what();
                  throw ex;
                }
            }
        }

    }
  else
    {
      std::cout << "Unable to load the input file " << filename << std::endl;
      throw -1;
    }
}