Example #1
0
   void OrbAlm::dumpHeader(std::ostream& s) const
         throw( gpstk::InvalidRequest )
   {
     if (!dataLoaded())
      {
         InvalidRequest exc("Required data not stored.");
         GPSTK_THROW(exc);
      }

      s << "**************************************************************" << std::endl
        << " ORB/CLK ALMANAC PARAMETERS FOR " << subjectSV
        << std::endl;

      std::string tform("test");
      
         // To do, generalize for all systems
      if (subjectSV.system==SatID::systemIRNSS)
	 tform = "%02m/%02d/%Y %03j %02H:%02M:%02S  %7.0s  %4O %6.0g  %P";
      else 
	 tform = "%02m/%02d/%Y %03j %02H:%02M:%02S  %7.0s  %4F %6.0g  %P";
      
      s << std::endl
        << "              MM/DD/YYYY DOY HH:MM:SS      SOD  WWWW    SOW\n";
      s << "Transmit   :  "
        << printTime(beginValid,tform) << std::endl;
      s << "Orbit Epoch:  "
        << printTime(ctToe,tform) << std::endl;
      s << std::endl; 
   }
Example #2
0
bool AudioDataSet<T>::load(const std::string & absoluteFilePath, std::string & errorString)
{
	File file(absoluteFilePath);
	
	if(!file.exists())
	{
		errorString = "No such file exists.";
		return false;
	}

	FileInputStream is(file);

	if (is.getStatus().failed())
	{
		errorString = "Error opening file";
		return false;
	}

	auto vt = ValueTree::readFromStream(is);

	numSounds = vt.getProperty("NumSounds");
	instancesPerSound = vt.getProperty("InstancesPerSound");
	bufferSize = vt.getProperty("BufferSize");
	stftFramesPerBuffer = vt.getProperty("STFTFramesPerBuffer");
	numDelayedBuffers = vt.getProperty("NumDelayedBuffers");

	auto featuresUsedLoaded = vt.getChildWithName("FeaturesUsed");

	//Going to reset features used
	featuresUsed.resize(0);

	for(auto i = 0; i < featuresUsedLoaded.getNumChildren(); ++i)
	{
		auto featureFramePair = featuresUsedLoaded.getChild(i);
		auto frame = int(featureFramePair.getProperty("Frame"));
		auto feature = static_cast<AudioClassifyOptions::AudioFeature>(int(featureFramePair.getProperty("Feature")));

		featuresUsed.push_back(std::make_pair(frame, feature));
	}
	
	auto dataBlock = vt.getProperty("Data").getBinaryData();
	arma::Mat<T> dataLoaded(static_cast<T*>(dataBlock->getData()), featuresUsed.size(), getTotalNumInstances());

	auto soundLabelsBlock = vt.getProperty("SoundLabels").getBinaryData();
	arma::Row<int> soundLabelsLoaded(static_cast<int*>(soundLabelsBlock->getData()), getTotalNumInstances());

	setData(dataLoaded);
	setSoundLabels(soundLabelsLoaded);

	//Assume sounds ready if loaded as required by save
	for (auto& v : soundsReady)
	{
		v = true;
	}

	return true;
}
Example #3
0
void ViewWindow::onLoadFinished ( bool )
{
	if ( m_storedScrollbarPosition > 0 )
	{
		page()->currentFrame()->setScrollBarValue( Qt::Vertical, m_storedScrollbarPosition );
		m_storedScrollbarPosition = 0;
	}

	updateHistoryIcons();

    emit dataLoaded( this );
}
Example #4
0
void PrivateStorage::stanzaRequestResult(const Jid &AStreamJid, const Stanza &AStanza)
{
	if (FSaveRequests.contains(AStanza.id()))
	{
		QDomElement dataElem = FSaveRequests.take(AStanza.id());
		if (AStanza.isResult())
		{
			LOG_STRM_INFO(AStreamJid,QString("Private data saved on server, ns=%1, id=%2").arg(dataElem.namespaceURI(),AStanza.id()));
			notifyDataChanged(AStreamJid,dataElem.tagName(),dataElem.namespaceURI());
		}
		else
		{
			LOG_STRM_WARNING(AStreamJid,QString("Private data saved in local storage, ns=%1, id=%2: %3").arg(dataElem.namespaceURI(),AStanza.id(),XmppStanzaError(AStanza).condition()));
		}
		saveOptionsElement(AStreamJid,dataElem);
		emit dataSaved(AStanza.id(),AStreamJid,dataElem);
	}
	else if (FLoadRequests.contains(AStanza.id()))
	{
		QDomElement dataElem; 
		QDomElement loadElem = FLoadRequests.take(AStanza.id());
		if (AStanza.isResult())
		{
			dataElem = AStanza.firstElement("query",NS_JABBER_PRIVATE).firstChildElement(loadElem.tagName());
			LOG_STRM_INFO(AStreamJid,QString("Private data loaded from server, ns=%1, id=%2").arg(loadElem.namespaceURI(),AStanza.id()));
		}
		else
		{
			LOG_STRM_WARNING(AStreamJid,QString("Private data loaded from local storage, ns=%1, id=%2: %3").arg(loadElem.namespaceURI(),AStanza.id(),XmppStanzaError(AStanza).condition()));
		}
		if (dataElem.isNull())
			dataElem = loadOptionsElement(AStreamJid,loadElem.tagName(),loadElem.namespaceURI());
		emit dataLoaded(AStanza.id(),AStreamJid,insertElement(AStreamJid,dataElem));
	}
	else if (FRemoveRequests.contains(AStanza.id()))
	{
		QDomElement dataElem = FRemoveRequests.take(AStanza.id());
		if (AStanza.isResult())
		{
			LOG_STRM_INFO(AStreamJid,QString("Private data removed from server, ns=%1, id=%2").arg(dataElem.namespaceURI(),AStanza.id()));
			notifyDataChanged(AStreamJid,dataElem.tagName(),dataElem.namespaceURI());
		}
		else
		{
			LOG_STRM_WARNING(AStreamJid,QString("Private data removed from local storage, ns=%1, id=%2: %3").arg(dataElem.namespaceURI(),AStanza.id(),XmppStanzaError(AStanza).condition()));
		}
		removeElement(AStreamJid,dataElem.tagName(),dataElem.namespaceURI());
		removeOptionsElement(AStreamJid,dataElem.tagName(),dataElem.namespaceURI());
		emit dataRemoved(AStanza.id(),AStreamJid,dataElem);
	}
}
Example #5
0
template<typename T> TplModelNode *TplModelNode::addChild(T key, QString childname, NodeType childtype, QVariant childextra) {
	dataLoaded();

	TplModelNode *foundChild = findChild(key);
	if (foundChild != NULL) return foundChild;

	//TODO: handle deletion

	TplModelNode *newnode = new TplModelNode(childname, key, childtype, this, model, srv);
	if (childextra.isValid()) newnode->extra = childextra;
	addChild(newnode);

	return newnode;
}
Example #6
0
void DataFileLoader::loadChemStationFileSingle(const QString &path)
{
  ChemStationFileLoader::Data chData = ChemStationFileLoader::loadFile(path, true);

  if (!chData.isValid())
    return;

  QDir d(path);
  d.cdUp();
  m_lastChemStationPath = d.path();

  emit dataLoaded(std::shared_ptr<Data>(new Data(chData.data, "Time", "minute", chemStationTypeToString(chData.type), chData.yUnits)),
                  path, QFileInfo(path).fileName());
}
void MainMenuScene::startBtnCallFunc(CCObject* pSender)
{	
	CCPoint mainMenuPosition = mainMenu->getPosition();

	CCParticleSystem *meteor=CCParticleSystemQuad::create("pictures/qwe.plist");
	meteor->setScale(0.4);
	meteor->setPosition(ccp(mainMenuPosition.x,mainMenuPosition.y -50)); 
	menuLayer->addChild(meteor,2); 

	CCSprite * activity = CCSprite::create("pictures/loading.png");
	activity->setPosition(ccp(mainMenuPosition.x,mainMenuPosition.y-50));
	menuLayer->addChild(activity,2);

	CCRotateBy * rotateAction = CCRotateBy::create(0.5f,180.0f);
	activity->runAction(CCRepeatForever::create(rotateAction));

	loadingCount = 0;
	dataLoaded(loadingCount);
}
Example #8
0
PaintWidget::PaintWidget(QWidget *parent) :
	QWidget( parent ),
	m_ui( new Ui::PaintWidget )
{
	m_ui->setupUi( this );
	if ( MapData::instance()->loaded() ) {
		setAttribute( Qt::WA_OpaquePaintEvent, true );
		setAttribute( Qt::WA_NoSystemBackground, true );
	}
#else
PaintWidget::PaintWidget() {
#endif
	m_lastMouseX = 0;
	m_lastMouseY = 0;
	m_wheelDelta = 0;
	m_fixed = false;
	setKeepPositionVisible( false );
	m_mouseDown = false;
	m_drag = false;
	m_request.zoom = 0;
	m_request.center = RoutingLogic::instance()->source().ToProjectedCoordinate();

	dataLoaded();
	sourceChanged();
	waypointsChanged();
	trackChanged();
	routeChanged();

	connect( MapData::instance(), SIGNAL(dataLoaded()), this, SLOT(dataLoaded()) );
	connect( RoutingLogic::instance(), SIGNAL(sourceChanged()), this, SLOT(sourceChanged()) );
	connect( RoutingLogic::instance(), SIGNAL(routeChanged()), this, SLOT(routeChanged()) );
	connect( RoutingLogic::instance(), SIGNAL(waypointsChanged()), this, SLOT(waypointsChanged()) );
	connect( Logger::instance(), SIGNAL(trackChanged()), this, SLOT(trackChanged()) );
}

PaintWidget::~PaintWidget()
{
#ifndef SAILFISH
	delete m_ui;
#endif
}

void PaintWidget::paint(QPainter *painter) {
	if ( !isVisible() )
		return;

	IRenderer* renderer = MapData::instance()->renderer();
	if ( renderer == NULL )
		return;

	if ( m_fixed ){
		m_request.center = m_request.position.ToProjectedCoordinate();

		if ( GlobalSettings::autoRotation() )
		{
			//gradually change the screen rotation to match the heading
			double diff = m_request.rotation + m_request.heading;
			while ( diff <= -180 )
				diff += 360;
			while ( diff >= 180 )
				diff -=360;
			//to filter out noise stop when close enough
			if ( diff > 0 )
				diff = std::max( 0.0, diff - 15 );
			if ( diff < 0 )
				diff = std::min( 0.0, diff + 15 );
			m_request.rotation -= diff / 2;

			//normalize
			while ( m_request.rotation < 0 )
				m_request.rotation += 360;
			while ( m_request.rotation >= 360 )
				m_request.rotation -= 360;

			int radius = height() * 0.25;
			m_request.center = renderer->PointToCoordinate( 0, -radius, m_request );
		} else {
			m_request.rotation = 0;
		}
	} else {
		m_request.rotation = 0;
	}

	if (m_keepPositionVisible)
		m_request.center = m_request.position.ToProjectedCoordinate();

	Timer time;
	renderer->Paint( painter, m_request );
	qDebug() << "Rendering:" << time.elapsed() << "ms";
}

void PaintWidget::dataLoaded()
{
	IRenderer* renderer = MapData::instance()->renderer();
	if ( renderer == NULL )
		return;

#ifndef SAILFISH
	setAttribute( Qt::WA_OpaquePaintEvent, true );
	setAttribute( Qt::WA_NoSystemBackground, true );
#endif
	renderer->SetUpdateSlot( this, SLOT(update()) );
	update();
}
Example #9
0
void DataFileLoader::loadCsvFile(const bool readFromClipboard)
{
  LoadCsvFileDialog::Parameters p;
  QStringList filePaths;
  QFileDialog openDlg(nullptr, tr("Pick a text data file"), m_lastCsvPath);

  if (!readFromClipboard) {
    openDlg.setAcceptMode(QFileDialog::AcceptOpen);
    openDlg.setFileMode(QFileDialog::ExistingFiles);

    if (openDlg.exec() != QDialog::Accepted)
      return;

    filePaths = openDlg.selectedFiles();
    if (filePaths.length() < 1)
      return;
  }

  while (true) {
    if (m_loadCsvFileDlg->exec() != QDialog::Accepted)
      return;

    p = m_loadCsvFileDlg->parameters();
    if (p.delimiter.length() != 1 && (p.delimiter.compare("\\t") != 0)) {
      QMessageBox::warning(nullptr, QObject::tr("Invalid input"), QObject::tr("Delimiter must be a single character or '\\t' to represent TAB."));
      continue;
    }
    if (p.decimalSeparator == p.delimiter) {
      QMessageBox::warning(nullptr, QObject::tr("Invalid input"), QObject::tr("Delimiter and decimal separator cannot be the same character."));
      continue;
    }

    if (p.xColumn == p.yColumn) {
      QMessageBox::warning(nullptr, QObject::tr("Invalid input"), QObject::tr("X and Y columns cannot be the same"));
      continue;
    }

    break;
  }

  QChar delimiter;
  if (p.delimiter.compare("\\t") == 0)
    delimiter = '\t';
  else
    delimiter = p.delimiter.at(0);

  const QByteArray &bom = p.readBom == true ? CsvFileLoader::SUPPORTED_ENCODINGS[p.encodingId].bom : QByteArray();

  auto doLoad = [this, &p](const CsvFileLoader::Data &csvData, const QString &path) {
    QString xType;
    QString yType;
    QString xUnit;
    QString yUnit;
    QString fileName = "";

    switch (p.header) {
    case LoadCsvFileDialog::HeaderHandling::NO_HEADER:
      xType = p.xType;
      yType = p.yType;
      xUnit = p.xUnit;
      yUnit = p.yUnit;
      break;
    case LoadCsvFileDialog::HeaderHandling::HEADER_WITH_UNITS:
      xType = csvData.xType;
      yType = csvData.yType;
      break;
    case LoadCsvFileDialog::HeaderHandling::HEADER_WITHOUT_UNITS:
      xType = csvData.xType;
      yType = csvData.yType;
      xUnit = p.xUnit;
      yUnit = p.yUnit;
      break;
    }

    if (yUnit.length() > 0) {
      if (yUnit.at(yUnit.length() - 1) == '\n')
        yUnit.chop(1);
    }

    std::shared_ptr<Data> data = std::shared_ptr<Data>(new Data(csvData.data,
                                                       xType, xUnit,
                                                       yType, yUnit));

    if (path != "")
      fileName = QFileInfo(path).fileName();
    emit dataLoaded(data, path, fileName);
  };

  if (readFromClipboard) {
    CsvFileLoader::Data csvData = CsvFileLoader::readClipboard(delimiter, p.decimalSeparator, p.xColumn, p.yColumn,
                                                               p.header != LoadCsvFileDialog::HeaderHandling::NO_HEADER,
                                                               p.linesToSkip, p.encodingId);

    if (!csvData.isValid())
      return;

    doLoad(csvData, "");

  } else {
    for (const QString &path : filePaths) {
      CsvFileLoader::Data csvData = CsvFileLoader::readFile(path, delimiter, p.decimalSeparator,
                                                            p.xColumn, p.yColumn,
                                                            p.header != LoadCsvFileDialog::HeaderHandling::NO_HEADER, p.linesToSkip,
                                                            p.encodingId, bom);

      if (!csvData.isValid())
        continue;

      m_lastCsvPath = path;
      doLoad(csvData, path);
    }
  }

}