コード例 #1
0
ファイル: Assets.cpp プロジェクト: richo/SSVOpenHexagon
	void loadAssets()
	{
		log("loading profiles", "LoadAssets"); 	loadProfiles();

		for(string packPath : getScan<Mode::Single, Type::Folder>("Packs/"))
		{
			string packName{packPath.substr(6, packPath.length() - 6)};

			string packLua{""};
			for(const auto& path : getScan<Mode::Recurse, Type::File, Pick::ByExt>(packPath, ".lua")) packLua.append(getFileContents(path));
			string packHash{Online::getMD5Hash(packLua + HG_SKEY1 + HG_SKEY2 + HG_SKEY3)};

			Json::Value packRoot{getRootFromFile(packPath + "/pack.json")};
			PackData packData(packName, packRoot["name"].asString(), packRoot["priority"].asFloat(), packHash);
			packDataMap.insert(make_pair(packName, packData));
		}

		vector<PackData> packDatasToQuery;
		for(pair<string, PackData> packDataPair : packDataMap) packDatasToQuery.push_back(packDataPair.second);
		sort(begin(packDatasToQuery), end(packDatasToQuery), [](PackData a, PackData b) { return a.getPriority() < b.getPriority(); });

		for(PackData packData : packDatasToQuery)
		{
			string packName{packData.getId()}, packPath{"Packs/" + packName + "/"};
			packPaths.push_back("Packs/" + packName + "/");
			log("loading " + packName + " music", "LoadAssets");			loadMusic(packPath);
			log("loading " + packName + " music data", "LoadAssets");		loadMusicData(packPath);
			log("loading " + packName + " style data", "LoadAssets");		loadStyleData(packPath);
			log("loading " + packName + " level data", "LoadAssets");		loadLevelData(packPath);
			log("loading " + packName + " events", "LoadAssets");			loadEvents(packPath);
			log("loading " + packName + " custom sounds", "LoadAssets");	loadCustomSounds(packName, packPath);
		}
	}
コード例 #2
0
void EventsWindow::createLoadButton(QBoxLayout *layout)
{
    m_loadEvents = new QPushButton;
    m_loadEvents->setStyleSheet(QLatin1String("font-weight:bold;"));
    layout->addWidget(m_loadEvents);

    connect(m_loadEvents, SIGNAL(clicked()), this, SLOT(loadEvents()));
}
コード例 #3
0
bool QmlProfilerFileReader::loadQtd(QIODevice *device)
{
    QXmlStreamReader stream(device);

    bool validVersion = true;

    while (validVersion && !stream.atEnd() && !stream.hasError()) {
        if (isCanceled())
            return false;
        QXmlStreamReader::TokenType token = stream.readNext();
        const QStringRef elementName = stream.name();
        switch (token) {
        case QXmlStreamReader::StartDocument :  continue;
        case QXmlStreamReader::StartElement : {
            if (elementName == _("trace")) {
                QXmlStreamAttributes attributes = stream.attributes();
                if (attributes.hasAttribute(_("version")))
                    validVersion = attributes.value(_("version")) == _(PROFILER_FILE_VERSION);
                else
                    validVersion = false;
                if (attributes.hasAttribute(_("traceStart")))
                    m_traceStart = attributes.value(_("traceStart")).toLongLong();
                if (attributes.hasAttribute(_("traceEnd")))
                    m_traceEnd = attributes.value(_("traceEnd")).toLongLong();
            }

            if (elementName == _("eventData")) {
                loadEventTypes(stream);
                emit typesLoaded(m_eventTypes);
                break;
            }

            if (elementName == _("profilerDataModel")) {
                loadEvents(stream);
                break;
            }

            if (elementName == _("noteData")) {
                loadNotes(stream);
                emit notesLoaded(m_notes);
                break;
            }

            break;
        }
        default: break;
        }
    }

    if (stream.hasError()) {
        emit error(tr("Error while parsing trace data file: %1").arg(stream.errorString()));
        return false;
    } else {
        emit success();
        return true;
    }
}
コード例 #4
0
void xmlLoader::loadNode(clamourNode &n, ofxXmlSettings &XML) {

    if(XML.tagExists("ATTACK_SECS"))n.setAttSecs(XML.getValue("ATTACK_SECS", 0.01)); // could be in a param if necessary later
    if(XML.tagExists("DECAY_SECS"))n.setDecSecs(XML.getValue("DECAY_SECS", 0.2));  //
    if(XML.tagExists("ENV_TYPE"))n.setEnvType(XML.getValue("ENV_TYPE", "AR"));

    loadEvents(n, XML);

    if(XML.tagExists("SOUND_TYPE"))n.setSoundType(XML.getValue("SOUND_TYPE","none"));
    if(XML.tagExists("DRAW_TYPE"))n.setDrawType(XML.getValue("DRAW_TYPE", "none"));
    if(XML.tagExists("CAN_SLEEP"))n.setCanSleep(XML.getValue("CAN_SLEEP", true));
    if(XML.tagExists("ROTATE")){n.setIsRotate(XML.getValue("ROTATE", true));}
    if(XML.tagExists("COLLIDES")){n.setIsCollidable(XML.getValue("COLLIDES", false));}
    if(XML.tagExists("DISTRIB")){n.setIsDistributable(XML.getValue("DISTRIB", true));}

    if(XML.tagExists("SHIFT"))n.setShiftAmount(XML.getValue("SHIFT", 0.2));

    if(XML.pushTag("DRAW_PARAMS")) {

        vector<parameter> p;
        xmlLoader::loadParams( p ,XML);
        for(int i = 0; i < p.size(); i++)n.setDrawParameter(p[i]);
        XML.popTag();
    }


    if(n.getDrawData().getName() != "none"){
        //if statement needed here too
        ofPath p;

        pathFactory::createPath(p, n.getDrawData().getShapeType(),
                                XML.getValue("X_DIM",1.0),XML.getValue("Y_DIM", 1.0),
                                n.getDrawData().getParameter("size").abs_val);

        n.setEdgeTemplate(p);
    }




    if(XML.pushTag("SOUND_PARAMS")) {

        if(XML.tagExists("FILE"))n.setSoundFile(XML.getValue("FILE", "default"));
        vector<parameter> p;
        xmlLoader::loadParams( p ,XML);
        for(int i = 0; i < p.size(); i++) {
            n.setSoundParameter(p[i]);
        }
        XML.popTag();
    }

    loadSounds(n, XML);
    loadReactions(n,XML);


}
コード例 #5
0
ファイル: MainWindow.cpp プロジェクト: dst/dontforget
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent) {

    calendar = new CalendarWidget(this);
    setCentralWidget(calendar);

    makeConnections();

    createActions();
    createMenu();
    createToolbar();
    // create status bar (needed for status tips)
    statusBar();
    createTrayIcon();

    readSettings();

    setWindowIcon(getCalendarIcon());
    setWindowTitle(tr("Event manager"));

    // to not block showing GUI
    QTimer::singleShot(0, this, SLOT(loadEvents()));
    QTimer::singleShot(0, this, SLOT(checkCommingEvents()));
}
コード例 #6
0
ファイル: LoadBBY.cpp プロジェクト: dezed/mantid
/**
 * Execute the algorithm.
 */
void LoadBBY::exec() {
  // Delete the output workspace name if it existed
  std::string outName = getPropertyValue("OutputWorkspace");
  if (API::AnalysisDataService::Instance().doesExist(outName))
    API::AnalysisDataService::Instance().remove(outName);

  // Get the name of the data file.
  std::string filename = getPropertyValue(FilenameStr);
  ANSTO::Tar::File tarFile(filename);
  if (!tarFile.good())
    throw std::invalid_argument("invalid BBY file");

  // region of intreset
  std::vector<bool> roi = createRoiVector(getPropertyValue(MaskStr));

  double tofMinBoundary = getProperty(FilterByTofMinStr);
  double tofMaxBoundary = getProperty(FilterByTofMaxStr);

  double timeMinBoundary = getProperty(FilterByTimeStartStr);
  double timeMaxBoundary = getProperty(FilterByTimeStopStr);

  if (isEmpty(tofMaxBoundary))
    tofMaxBoundary = std::numeric_limits<double>::infinity();
  if (isEmpty(timeMaxBoundary))
    timeMaxBoundary = std::numeric_limits<double>::infinity();

  API::Progress prog(this, 0.0, 1.0, Progress_Total);
  prog.doReport("creating instrument");

  // create workspace
  DataObjects::EventWorkspace_sptr eventWS =
      boost::make_shared<DataObjects::EventWorkspace>();

  eventWS->initialize(HISTO_BINS_Y * HISTO_BINS_X,
                      2, // number of TOF bin boundaries
                      1);

  // set the units
  eventWS->getAxis(0)->unit() = Kernel::UnitFactory::Instance().create("TOF");
  eventWS->setYUnit("Counts");

  // set title
  const std::vector<std::string> &subFiles = tarFile.files();
  for (const auto &subFile : subFiles)
    if (subFile.compare(0, 3, "BBY") == 0) {
      std::string title = subFile;

      if (title.rfind(".hdf") == title.length() - 4)
        title.resize(title.length() - 4);

      if (title.rfind(".nx") == title.length() - 3)
        title.resize(title.length() - 3);

      eventWS->setTitle(title);
      break;
    }

  // create instrument
  InstrumentInfo instrumentInfo;

  // Geometry::Instrument_sptr instrument =
  createInstrument(tarFile, /* ref */ instrumentInfo);
  // eventWS->setInstrument(instrument);

  // load events
  size_t numberHistograms = eventWS->getNumberHistograms();

  std::vector<EventVector_pt> eventVectors(numberHistograms, nullptr);
  std::vector<size_t> eventCounts(numberHistograms, 0);

  // phase correction
  Kernel::Property *periodMasterProperty =
      getPointerToProperty(PeriodMasterStr);
  Kernel::Property *periodSlaveProperty = getPointerToProperty(PeriodSlaveStr);
  Kernel::Property *phaseSlaveProperty = getPointerToProperty(PhaseSlaveStr);

  double periodMaster;
  double periodSlave;
  double phaseSlave;

  if (periodMasterProperty->isDefault() || periodSlaveProperty->isDefault() ||
      phaseSlaveProperty->isDefault()) {

    if (!periodMasterProperty->isDefault() ||
        !periodSlaveProperty->isDefault() || !phaseSlaveProperty->isDefault()) {
      throw std::invalid_argument("Please specify PeriodMaster, PeriodSlave "
                                  "and PhaseSlave or none of them.");
    }

    // if values have not been specified in loader then use values from hdf file
    periodMaster = instrumentInfo.period_master;
    periodSlave = instrumentInfo.period_slave;
    phaseSlave = instrumentInfo.phase_slave;
  } else {
    periodMaster = getProperty(PeriodMasterStr);
    periodSlave = getProperty(PeriodSlaveStr);
    phaseSlave = getProperty(PhaseSlaveStr);

    if ((periodMaster < 0.0) || (periodSlave < 0.0))
      throw std::invalid_argument(
          "Please specify a positive value for PeriodMaster and PeriodSlave.");
  }

  double period = periodSlave;
  double shift = -1.0 / 6.0 * periodMaster - periodSlave * phaseSlave / 360.0;

  // count total events per pixel to reserve necessary memory
  ANSTO::EventCounter eventCounter(
      roi, HISTO_BINS_Y, period, shift, tofMinBoundary, tofMaxBoundary,
      timeMinBoundary, timeMaxBoundary, eventCounts);

  loadEvents(prog, "loading neutron counts", tarFile, eventCounter);

  // prepare event storage
  ANSTO::ProgressTracker progTracker(prog, "creating neutron event lists",
                                     numberHistograms, Progress_ReserveMemory);

  for (size_t i = 0; i != numberHistograms; ++i) {
    DataObjects::EventList &eventList = eventWS->getEventList(i);

    eventList.setSortOrder(DataObjects::PULSETIME_SORT);
    eventList.reserve(eventCounts[i]);

    eventList.setDetectorID(static_cast<detid_t>(i));
    eventList.setSpectrumNo(static_cast<detid_t>(i));

    DataObjects::getEventsFrom(eventList, eventVectors[i]);

    progTracker.update(i);
  }
  progTracker.complete();

  ANSTO::EventAssigner eventAssigner(
      roi, HISTO_BINS_Y, period, shift, tofMinBoundary, tofMaxBoundary,
      timeMinBoundary, timeMaxBoundary, eventVectors);

  loadEvents(prog, "loading neutron events", tarFile, eventAssigner);

  Kernel::cow_ptr<MantidVec> axis;
  MantidVec &xRef = axis.access();
  xRef.resize(2, 0.0);
  xRef[0] = std::max(
      0.0,
      floor(eventCounter.tofMin())); // just to make sure the bins hold it all
  xRef[1] = eventCounter.tofMax() + 1;
  eventWS->setAllX(axis);

  // count total number of masked bins
  size_t maskedBins = 0;
  for (size_t i = 0; i != roi.size(); i++)
    if (!roi[i])
      maskedBins++;

  if (maskedBins > 0) {
    // create list of masked bins
    std::vector<size_t> maskIndexList(maskedBins);
    size_t maskIndex = 0;

    for (size_t i = 0; i != roi.size(); i++)
      if (!roi[i])
        maskIndexList[maskIndex++] = i;

    API::IAlgorithm_sptr maskingAlg = createChildAlgorithm("MaskDetectors");
    maskingAlg->setProperty("Workspace", eventWS);
    maskingAlg->setProperty("WorkspaceIndexList", maskIndexList);
    maskingAlg->executeAsChildAlg();
  }

  // set log values
  API::LogManager &logManager = eventWS->mutableRun();

  logManager.addProperty("filename", filename);
  logManager.addProperty("att_pos", static_cast<int>(instrumentInfo.att_pos));
  logManager.addProperty("frame_count",
                         static_cast<int>(eventCounter.numFrames()));
  logManager.addProperty("period", period);

  // currently beam monitor counts are not available, instead number of frames
  // times period is used
  logManager.addProperty(
      "bm_counts", static_cast<double>(eventCounter.numFrames()) * period /
                       1.0e6); // static_cast<double>(instrumentInfo.bm_counts)

  // currently
  Kernel::time_duration duration =
      boost::posix_time::microseconds(static_cast<boost::int64_t>(
          static_cast<double>(eventCounter.numFrames()) * period));

  Kernel::DateAndTime start_time("2000-01-01T00:00:00");
  Kernel::DateAndTime end_time(start_time + duration);

  logManager.addProperty("start_time", start_time.toISO8601String());
  logManager.addProperty("end_time", end_time.toISO8601String());

  std::string time_str = start_time.toISO8601String();
  AddSinglePointTimeSeriesProperty(logManager, time_str, "L1_chopper_value",
                                   instrumentInfo.L1_chopper_value);
  AddSinglePointTimeSeriesProperty(logManager, time_str, "L2_det_value",
                                   instrumentInfo.L2_det_value);
  AddSinglePointTimeSeriesProperty(logManager, time_str, "L2_curtainl_value",
                                   instrumentInfo.L2_curtainl_value);
  AddSinglePointTimeSeriesProperty(logManager, time_str, "L2_curtainr_value",
                                   instrumentInfo.L2_curtainr_value);
  AddSinglePointTimeSeriesProperty(logManager, time_str, "L2_curtainu_value",
                                   instrumentInfo.L2_curtainu_value);
  AddSinglePointTimeSeriesProperty(logManager, time_str, "L2_curtaind_value",
                                   instrumentInfo.L2_curtaind_value);
  AddSinglePointTimeSeriesProperty(logManager, time_str, "D_det_value",
                                   instrumentInfo.D_det_value);
  AddSinglePointTimeSeriesProperty(logManager, time_str, "D_curtainl_value",
                                   instrumentInfo.D_curtainl_value);
  AddSinglePointTimeSeriesProperty(logManager, time_str, "D_curtainr_value",
                                   instrumentInfo.D_curtainr_value);
  AddSinglePointTimeSeriesProperty(logManager, time_str, "D_curtainu_value",
                                   instrumentInfo.D_curtainu_value);
  AddSinglePointTimeSeriesProperty(logManager, time_str, "D_curtaind_value",
                                   instrumentInfo.D_curtaind_value);
  AddSinglePointTimeSeriesProperty(logManager, time_str, "curtain_rotation",
                                   10.0);

  API::IAlgorithm_sptr loadInstrumentAlg =
      createChildAlgorithm("LoadInstrument");
  loadInstrumentAlg->setProperty("Workspace", eventWS);
  loadInstrumentAlg->setPropertyValue("InstrumentName", "BILBY");
  loadInstrumentAlg->setProperty("RewriteSpectraMap",
                                 Mantid::Kernel::OptionalBool(false));
  loadInstrumentAlg->executeAsChildAlg();

  setProperty("OutputWorkspace", eventWS);
}
コード例 #7
0
ファイル: calendar.cpp プロジェクト: togetherCoding/Calendar
Calendar::Calendar()
{
    eventListCounter = 0;
    loadEvents();

    actualDate = new QDate;
    *actualDate = QDate::currentDate();                      //get's information about current date and sets proper label
    int actualDay, actualMonth, actualYear;
    actualDate->getDate(&actualDay, &actualMonth, &actualYear);

    // essential variables initialization

    actualDate->getDate(&year,&month,&day);
    QDate dayOfWeek(year,month,1);      //gets information about first day of selected month and year
    whatDay = dayOfWeek.dayOfWeek();

    // end of essential variables initialization

    actualWeek = actualDate->weekNumber();

    // future note: array are better than days[0], days[1], days[2]... :P

    days = new Day*[7];

    days[0] = new Day("Monday");
    days[1] = new Day("Tuesday");
    days[2] = new Day("Wednesday");
    days[3] = new Day("Thursday");
    days[4] = new Day("Friday");
    days[5] = new Day("Saturday");
    days[6] = new Day("Sunday");


    daysLayout = new QHBoxLayout;

    navigationLayout = new QHBoxLayout;            // horizontal layout for navigation elements

    // creating elements for navigation box
    navigationLeft = new QPushButton("<<");
    navigationRight = new QPushButton(">>");
    dateLabel = new QLabel();                       // QLabel initialization

    navigationLayout->addWidget(navigationLeft);
    navigationLayout->addWidget(dateLabel);
    navigationLayout->addWidget(navigationRight);

    mainLayout = new QVBoxLayout;                  // vertical layout for navigation and days boxes
    mainLayout->addLayout(navigationLayout);
    mainLayout->addLayout(daysLayout);
    this->setLayout(mainLayout);

    QString initialDateLabel = dateToString(actualYear, actualMonth, actualDay);
    dateLabel->setText("<center>" + initialDateLabel + "</center>");
    sortButtons();
    connect(navigationLeft,SIGNAL(pressed()),this,SLOT(navigationLeftClicked()));   //connects navigation buttons with action (changing day's range or month)
    connect(navigationRight,SIGNAL(pressed()),this,SLOT(navigationRightClicked()));


/* Signal mapper is used to send parameter to slot method. The parameter here is
 * integer which reprenets offset of certain days of week. */

    QSignalMapper* signalMapper = new QSignalMapper(this);              // signal mapping is needed to parametrize slot :(

    connect(days[0], SIGNAL(pressed()), signalMapper, SLOT(map()));
    connect(days[1], SIGNAL(pressed()), signalMapper, SLOT(map()));
    connect(days[2], SIGNAL(pressed()), signalMapper, SLOT(map()));
    connect(days[3], SIGNAL(pressed()), signalMapper, SLOT(map()));
    connect(days[4], SIGNAL(pressed()), signalMapper, SLOT(map()));
    connect(days[5], SIGNAL(pressed()), signalMapper, SLOT(map()));
    connect(days[6], SIGNAL(pressed()), signalMapper, SLOT(map()));

    signalMapper->setMapping(days[0], 0);
    signalMapper->setMapping(days[1], 1);
    signalMapper->setMapping(days[2], 2);
    signalMapper->setMapping(days[3], 3);
    signalMapper->setMapping(days[4], 4);
    signalMapper->setMapping(days[5], 5);
    signalMapper->setMapping(days[6], 6);

    connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(scheduleDay(int)));

    colorTask();
}
コード例 #8
0
void xmlLoader::loadZone(zone &z, ofxXmlSettings &XML) {

    z.setName(XML.getValue("NAME", "default"));

    z.setPos_rel(ofVec2f(XML.getValue("X", 0.5), XML.getValue("Y",0.5)));
    ofPath p;

    loadEvents(z, XML);

    if(XML.tagExists("DRAW_TYPE"))z.setDrawType(XML.getValue("DRAW_TYPE", "debugZone"));

    if(XML.pushTag("DRAW_PARAMS")) {

        vector<parameter> p;
        xmlLoader::loadParams( p ,XML);
        for(int i = 0; i < p.size(); i++)z.setDrawParameter(p[i]);
        XML.popTag();
    }

    pathFactory::createPath(p, z.getDrawData().getShapeType(),
                            XML.getValue("X_DIM",1.0),XML.getValue("Y_DIM", 1.0),
                            z.getDrawData().getParameter("size").abs_val);
    z.setEdgeTemplate(p);

    if(XML.tagExists("ATTACK_SECS"))z.setAttSecs(XML.getValue("ATTACK_SECS", 0.01)); // could be in a param if necessary later
    if(XML.tagExists("DECAY_SECS"))z.setDecSecs(XML.getValue("DECAY_SECS", 0.2));  //
    if(XML.tagExists("ENV_TYPE"))z.setEnvType(XML.getValue("ENV_TYPE", "AR"));

    if(XML.tagExists("SOUND_TYPE"))z.setSoundType(XML.getValue("SOUND_TYPE","brownExploder"));


    if(XML.pushTag("SOUND_PARAMS")) {

        if(XML.tagExists("FILE"))z.setSoundFile(XML.getValue("FILE", "default"));
        vector<parameter> p;
        xmlLoader::loadParams( p ,XML);
        for(int i = 0; i < p.size(); i++)z.setSoundParameter(p[i]);
        XML.popTag();
    }


    if(XML.pushTag("ON_RULE")) {
        zoneRule r;
        xmlLoader::loadRule(r, XML);
        z.setOnRule(r);
        XML.popTag();
    }

    if(XML.pushTag("OFF_RULE")) {
        zoneRule r;
        xmlLoader::loadRule(r, XML);
        z.setOffRule(r);
        XML.popTag();
    }


    loadReactions(z, XML);
    loadSounds(z, XML);


}