Beispiel #1
0
void wavePlotter::draw (VectorXf &data)
{
	int temp_index = -1;
	startStyle();		
			ofBeginShape();
			for (int i=0; i<width; i++)
			{
				int index = (int) ofMap(i, 0, width, data_start_index, data_end_index);
				if (temp_index == index) {continue;}
				float ty =  ofMap(data(index), lowRange, highRange, height, 0, false);
				
				temp_index = index;
				//cout << "Index is: " << index << ", ty is: " << endl;
				ofVertex(i, ty);
			}
			/*
			for (int i = 0; i < DATA_SIZE; i++)
			{
				float tx =  ofMap(i, 0, DATA_SIZE, 0, width, true);
				float ty =  ofMap(data[i], lowRange, highRange, height, 0, false);
				
				ofVertex(tx, ty);
			}
			*/
			ofEndShape(false);
	endStyle();
}
Beispiel #2
0
// <?> how to overload method to avoid code duplication in this particular case when dealing with pointer - casting would not work
void wavePlotter::draw (short * data)
{
	int temp_index;
	startStyle();		
			ofBeginShape();
			for (int i=0; i<width; i++)
			{
				int index = (int) ofMap(i, 0, width, data_start_index, data_end_index);
				if (temp_index == index) {continue;}
				temp_index = index;
				float ty =  ofMap(data[index], lowRange, highRange, height, 0, false);
				ofVertex(i, ty);
			}
			/*
			for (int i = 0; i < DATA_SIZE; i++)
			{
				float tx =  ofMap(i, 0, DATA_SIZE, 0, width, true);
				float ty =  ofMap(data[i], lowRange, highRange, height, 0, false);
				
				ofVertex(tx, ty);
			}
			*/
			ofEndShape(false);
	endStyle();
}
 void KmlGenerator::putStationStyle() {
     startStyle("StationStyle");
     putLabelStyle(ColorRGBA(0x00,0x00,0x00,0x00), NORMAL, 0.0f); //invisible labels
     putIconStyle(stationIconHref, Offset(), 0.25f, 0.0f);        //custom icon
     endStyle();
     skipLine();
 }
    void KmlGenerator::putIsoLineStyles() {

        std::map<std::string, bool> styles;

        for (const auto &interpIsolines : isolines) {
            for(const auto &temporalIsolines : interpIsolines.second) {
                for(const auto &isoline : temporalIsolines) {
                    std::string styleName = "IsoLine_" + isoline.lines.color.toHexString();
                    if(styles.find(styleName) == styles.end()) {
                        startStyle(styleName);
                        putLineStyle(isoline.lines.color, NORMAL, 2u);
                        endStyle();
                        styles.emplace(styleName, true);
                    }
                }
            }
        }
        skipLine();
    }
    void KmlGenerator::putIsoContourStyles() {

        std::map<std::string, bool> styles;

        for (const auto &interpIsocontours : isocontours) {
            for(const auto &temporalIsocontours : interpIsocontours.second) {
                for(const auto &isocontour : temporalIsocontours) {
                    std::string styleName = "IsoContour_" + isocontour.color.toHexString();
                    if(styles.find(styleName) == styles.end()) {
                        startStyle(styleName);
                        putPolyStyle(isocontour.color, NORMAL, true, true);
                        putLineStyle(ColorRGBA::black, NORMAL, 1u);
                        endStyle();
                        styles.emplace(styleName, true);
                    }
                }
            }
        }

        skipLine();
    }
Beispiel #6
0
int CDVDOverlayCodecTX3G::Decode(DemuxPacket *pPacket)
{
  if (m_pOverlay)
    SAFE_RELEASE(m_pOverlay);

  m_pOverlay = new CDVDOverlayText();
  CDVDOverlayCodec::GetAbsoluteTimes(m_pOverlay->iPTSStartTime, m_pOverlay->iPTSStopTime, pPacket, m_pOverlay->replace);

  // do not move this. READ_XXXX macros modify pos.
  uint8_t  *pos = pPacket->pData;
  uint8_t  *end = pPacket->pData + pPacket->iSize;

  // Parse the packet as a TX3G TextSample.
  // Look for a single StyleBox ('styl') and 
  // read all contained StyleRecords.
  // Ignore all other box types.
  // NOTE: Buffer overflows on read are not checked.
  // ALSO: READ_XXXX/SKIP_XXXX macros will modify pos.
  LEN_CHECK(2);
  uint16_t textLength = READ_U16();
  LEN_CHECK(textLength);
  uint8_t *text = READ_ARRAY(textLength);

  int numStyleRecords = 0;
  // reserve one more style slot for broken encoders

  XUTILS::auto_buffer bgnStyle(textLength+1);
  XUTILS::auto_buffer endStyle(textLength+1);

  memset(bgnStyle.get(), 0, textLength+1);
  memset(endStyle.get(), 0, textLength+1);

  int bgnColorIndex = 0, endColorIndex = 0;
  uint32_t textColorRGBA = m_textColor;
  while (pos < end)
  {
    // Read TextSampleModifierBox
    LEN_CHECK(4);
    uint32_t size = READ_U32();
    if (size == 0)
      size = pos - end;   // extends to end of packet
    if (size == 1)
    {
      CLog::Log(LOGDEBUG, "CDVDOverlayCodecTX3G: TextSampleModifierBox has unsupported large size" );
      break;
    }
    LEN_CHECK(4);
    uint32_t type = READ_U32();
    if (type == FOURCC("uuid"))
    {
      CLog::Log(LOGDEBUG, "CDVDOverlayCodecTX3G: TextSampleModifierBox has unsupported extended type" );
      break;
    }

    if (type == FOURCC("styl"))
    {
      // Found a StyleBox. Parse the contained StyleRecords
      if ( numStyleRecords != 0 )
      {
        CLog::Log(LOGDEBUG, "CDVDOverlayCodecTX3G: found additional StyleBoxes on subtitle; skipping" );
        LEN_CHECK(size);
        SKIP_ARRAY(size);
        continue;
      }

      LEN_CHECK(2);
      numStyleRecords = READ_U16();
      for (int i = 0; i < numStyleRecords; i++)
      {
        StyleRecord curRecord;
        LEN_CHECK(12);
        curRecord.bgnChar         = READ_U16();
        curRecord.endChar         = READ_U16();
        curRecord.fontID          = READ_U16();
        curRecord.faceStyleFlags  = READ_U8();
        curRecord.fontSize        = READ_U8();
        curRecord.textColorRGBA   = READ_U32();
        // clamp bgnChar/bgnChar to textLength,
        // we alloc enough space above and this
        // fixes borken encoders that do not handle
        // endChar correctly.
        if (curRecord.bgnChar > textLength)
          curRecord.bgnChar = textLength;
        if (curRecord.endChar > textLength)
          curRecord.endChar = textLength;

        bgnStyle.get()[curRecord.bgnChar] |= curRecord.faceStyleFlags;
        endStyle.get()[curRecord.endChar] |= curRecord.faceStyleFlags;
        bgnColorIndex = curRecord.bgnChar;
        endColorIndex = curRecord.endChar;
        textColorRGBA = curRecord.textColorRGBA;
      }
    }
    else
    {
      // Found some other kind of TextSampleModifierBox. Skip it.
      LEN_CHECK(size);
      SKIP_ARRAY(size);
    }
  }

  // Copy text to out and add HTML markup for the style records
  int charIndex = 0;
  std::string strUTF8;
  // index over textLength chars to include broken encoders,
  // so we pickup closing styles on broken encoders
  for (pos = text, end = text + textLength; pos <= end; pos++)
  {
    if ((*pos & 0xC0) == 0x80)
    {
      // Is a non-first byte of a multi-byte UTF-8 character
      strUTF8.append((const char*)pos, 1);
      continue;   // ...without incrementing 'charIndex'
    }

    uint8_t bgnStyles = bgnStyle.get()[charIndex];
    uint8_t endStyles = endStyle.get()[charIndex];

    // [B] or [/B] -> toggle bold on and off
    // [I] or [/I] -> toggle italics on and off
    // [COLOR ffab007f] or [/COLOR] -> toggle color on and off
    // [CAPS <option>]  or [/CAPS]  -> toggle capatilization on and off

    if (endStyles & BOLD)
      strUTF8.append("[/B]");
    if (endStyles & ITALIC)
      strUTF8.append("[/I]");
    // we do not support underline
    //if (endStyles & UNDERLINE)
    //  strUTF8.append("[/U]");
    if (endColorIndex == charIndex && textColorRGBA != m_textColor)
      strUTF8.append("[/COLOR]");

    // invert the order from above so we bracket the text correctly.
    if (bgnColorIndex == charIndex && textColorRGBA != m_textColor)
      strUTF8 += StringUtils::Format("[COLOR %8x]", textColorRGBA);
    // we do not support underline
    //if (bgnStyles & UNDERLINE)
    //  strUTF8.append("[U]");
    if (bgnStyles & ITALIC)
      strUTF8.append("[I]");
    if (bgnStyles & BOLD)
      strUTF8.append("[B]");

    // stuff the UTF8 char
    strUTF8.append((const char*)pos, 1);

    // this is a char index, not a byte index.
    charIndex++;
  }
  
  if (strUTF8.empty())
    return OC_BUFFER;

  if (strUTF8[strUTF8.size()-1] == '\n')
    strUTF8.erase(strUTF8.size()-1);

  // add a new text element to our container
  m_pOverlay->AddElement(new CDVDOverlayText::CElementText(strUTF8.c_str()));

  return OC_OVERLAY;
}