Example #1
0
void Collection::slotChildStopped(quint32 fid)
{
    Doc* doc = qobject_cast <Doc*> (parent());
    Q_ASSERT(doc != NULL);

    Function* function = doc->function(fid);
    disconnect(function, SIGNAL(stopped(quint32)),
               this, SLOT(slotChildStopped(quint32)));

    QMutexLocker locker(&m_functionListMutex);
    m_runningChildren.remove(fid);
}
Example #2
0
void MasterTimer::timerTick()
{
    Doc *doc = qobject_cast<Doc*> (parent());
    Q_ASSERT(doc != NULL);

#ifdef DEBUG_MASTERTIMER
    qDebug() << "[MasterTimer] *********** tick:" << ticksCount++ << "**********";
#endif

    switch (m_beatSourceType)
    {
        case Internal:
        {
            int elapsedTime = qRound((double)m_beatTimer->nsecsElapsed() / 1000000) + m_lastBeatOffset;
            //qDebug() << "Elapsed beat:" << elapsedTime;
            if (elapsedTime >= m_beatTimeDuration)
            {
                // it's time to fire a beat
                m_beatRequested = true;

                // restart the time for the next beat, starting at a delta
                // milliseconds, otherwise it will generate an unpleasant drift
                //qDebug() << "Elapsed:" << elapsedTime << ", delta:" << elapsedTime - m_beatTimeDuration;
                m_lastBeatOffset = elapsedTime - m_beatTimeDuration;
                m_beatTimer->restart();

                // inform the listening classes that a beat is happening
                emit beat();
            }
        }
        break;
        case External:
        break;

        case None:
        default:
            m_beatRequested = false;
        break;
    }

    QList<Universe *> universes = doc->inputOutputMap()->claimUniverses();

    timerTickFunctions(universes);
    timerTickDMXSources(universes);

    doc->inputOutputMap()->releaseUniverses();

    m_beatRequested = false;

    //qDebug() << ">>>>>>>> MASTERTIMER TICK";
    emit tickReady();
}
Example #3
0
QObject* Factory::create(const char* iface, QWidget* parentWidget, QObject *parent, const QVariantList& args, const QString& keyword)
{
    Q_UNUSED(args);
    Q_UNUSED(keyword);
    bool bWantKoDocument = (strcmp(iface, "KoDocument") == 0);

    Doc *doc = new Doc(parentWidget, parent, !bWantKoDocument);

    if (!bWantKoDocument)
        doc->setReadWrite(false);

    return doc;
}
Example #4
0
void Chaser::stopMemberAt(int index)
{
	Doc* doc = qobject_cast <Doc*> (parent());
	Q_ASSERT(doc != NULL);

	t_function_id fid = m_steps.at(index);
	Q_ASSERT(fid != Function::invalidId());

	Function* function = doc->function(fid);
	Q_ASSERT(function != NULL);

	function->stop(m_masterTimer);
}
Example #5
0
int Page::GetContentHeight() const
{
    Doc *doc = dynamic_cast<Doc *>(GetParent());
    assert(doc);

    // Doc::SetDrawingPage should have been called before
    // Make sure we have the correct page
    assert(this == doc->GetDrawingPage());

    System *last = dynamic_cast<System *>(m_children.back());
    assert(last);
    return doc->m_drawingPageHeight - doc->m_drawingPageTopMar - last->GetDrawingYRel() + last->GetHeight();
}
Example #6
0
void ThreadLoadEbook::Run()
{
    //lf(L"ThreadLoadEbook::Run(%s)", fileName);
    Timer t(true);
    Doc doc = Doc::CreateFromFile(fileName);
    double loadingTimeMs = t.GetTimeInMs();
    //lf(L"Loaded %s in %.2f ms", fileName, t.GetTimeInMs());

    // don't load PalmDoc, etc. files as long as they're not correctly formatted
    if (doc.AsMobi() && Pdb_Mobipocket != doc.AsMobi()->GetDocType())
        doc.Delete();

    uitask::Post(new FinishedEbookLoadingTask(win, doc));
}
Example #7
0
void SetMask::setMask(Mask* mask)
{
  Doc* doc = document();

  if (mask) {
    doc->setMask(mask);
    doc->setMaskVisible(!mask->isEmpty());
  }
  else {
    Mask empty;
    doc->setMask(&empty);
    doc->setMaskVisible(false);
  }
}
Example #8
0
void Collection::postLoad()
{
    Doc* doc = qobject_cast <Doc*> (parent());
    Q_ASSERT(doc != NULL);

    /* Check that all member functions exist (nonexistent functions can
       be present only when a corrupted file has been loaded) */
    QMutableListIterator<quint32> it(m_functions);
    while (it.hasNext() == true)
    {
        /* Remove any nonexistent member functions */
        if (doc->function(it.next()) == NULL)
            it.remove();
    }
}
Example #9
0
void MasterTimer::timerTick()
{
    Doc* doc = qobject_cast<Doc*> (parent());
    Q_ASSERT(doc != NULL);

    UniverseArray* universes = doc->outputMap()->claimUniverses();
    universes->zeroIntensityChannels();

    timerTickFunctions(universes);
    timerTickDMXSources(universes);
    timerTickFader(universes);

    doc->outputMap()->releaseUniverses();
    doc->outputMap()->dumpUniverses();
}
Example #10
0
/**
 * @param usuario
 * @param datos
 */
void GestorUsuarios::modUsuario(Usuario *usuario, DtoUsuario *datos) {
    usuario->setNombre(datos->nombre);
    usuario->setApellido(datos->apellido);
    Doc* doc = new Doc();
    doc->setTipo(datos->tipoDni);
    usuario->setDoc(doc);
    usuario->setNro_doc(datos->numeroDni);
    Localidad* localidad = new Localidad();
    localidad->setNombre(datos->localidad);
    usuario->setLocalidad(localidad);
    //El caso de uso no contempla la posibilidad de modificar la contraseña

    //Guardo los cambios
    gestorDB->saveUsuario(usuario);
}
Example #11
0
QList <Function*> Chaser::stepFunctions() const
{
    Doc* doc = qobject_cast<Doc*> (parent());
    Q_ASSERT(doc != NULL);

    QList <Function*> list;
    QListIterator <t_function_id> it(m_steps);
    while (it.hasNext() == true)
    {
        Function* function = doc->function(it.next());
        if (function != NULL)
            list << function;
    }

    return list;
}
Example #12
0
void SetPixelFormat::setFormat(PixelFormat format)
{
  Sprite* sprite = this->sprite();

  sprite->setPixelFormat(format);
  sprite->incrementVersion();

  // Regenerate extras
  Doc* doc = static_cast<Doc*>(sprite->document());
  doc->setExtraCel(ExtraCelRef(nullptr));

  // Generate notification
  DocEvent ev(doc);
  ev.sprite(sprite);
  doc->notify_observers<DocEvent&>(&DocObserver::onPixelFormatChanged, ev);
}
void ThreadLoadEbook::Run()
{
    //lf(L"ThreadLoadEbook::Run(%s)", fileName);
    Timer t(true);
    Doc doc = Doc::CreateFromFile(fileName);
    // TODO: even under heavy load, Doc::CreateFromFile doesn't take more
    //       than 50ms - any reason not to synchronously load ebooks?
    double loadingTimeMs = t.GetTimeInMs();
    lf(L"Loaded %s in %.2f ms", fileName, loadingTimeMs);

    // don't load PalmDoc, etc. files as long as they're not correctly formatted
    if (doc.AsMobi() && Pdb_Mobipocket != doc.AsMobi()->GetDocType())
        doc.Delete();

    uitask::Post(new FinishedEbookLoadingTask(win, doc));
}
Example #14
0
 void ForEachToken(Id const & id, Doc const & doc, Fn && fn)
 {
   doc.ForEachToken([&](int8_t lang, Token const & token) {
     if (lang >= 0)
       fn(AddLang(lang, token));
   });
 }
Example #15
0
  /*********************************************
   * Sample particles for a given document
   * 
   * doc: 
   *********************************************/
  LatentSeq DecodeGraph(const Doc doc){
    // ----------------------------------------
    // init
    int nsent = doc.size();
    LatentSeq latseq;
    // ----------------------------------------
    // for each sentence in doc, each latval, compute
    // the posterior prob p(R|cvec, sent)
    vector<float> U;
    for (unsigned sidx = 0; sidx < nsent; sidx ++){
      final_hlist.clear();
      for (int val = 0; val < nlatvar; val ++){
	ComputationGraph cg;
	BuildSentGraph(doc[sidx], sidx, cg, val);
	float prob = as_scalar(cg.forward());
	U.push_back(prob);
	cg.clear();
      }
      // normalize and get the argmax
      log_normalize(U);
      // greedy decoding
      int max_idx = argmax(U);
      // get the corresponding context vector
      final_h = final_hlist[max_idx];
      // 
      U.clear();
      // cerr << "max_latval = " << max_idx << endl;
      latseq.push_back(max_idx);
    }
    // cerr << "====" << endl;
    return latseq;
  }
Example #16
0
void Collection::slotChildStopped(t_function_id fid)
{
	Doc* doc = qobject_cast <Doc*> (parent());
	Q_ASSERT(doc != NULL);

	Function* function;
	function = doc->function(fid);
	Q_ASSERT(function != NULL);

	disconnect(function, SIGNAL(stopped(t_function_id)),
		   this, SLOT(slotChildStopped(t_function_id)));

	m_childCountMutex.lock();
	m_childCount--;
	m_childCountMutex.unlock();
}
Example #17
0
void Scene_Test::arm()
{
    Doc* doc = new Doc(this, m_cache);

    Fixture* fxi = new Fixture(doc);
    fxi->setName("Test Fixture");
    fxi->setAddress(15);
    fxi->setUniverse(3);
    fxi->setChannels(10);
    doc->addFixture(fxi);

    Scene* s1 = new Scene(doc);
    s1->setName("First");
    s1->setValue(fxi->id(), 0, 123);
    s1->setValue(fxi->id(), 7, 45);
    s1->setValue(fxi->id(), 3, 67);
    doc->addFunction(s1);

    QVERIFY(s1->armedChannels().size() == 0);
    s1->arm();
    QVERIFY(s1->armedChannels().size() == 3);

    SceneChannel ch;
    ch = s1->armedChannels().at(0);
    QVERIFY(ch.address == fxi->universeAddress());
    QVERIFY(ch.start == 0);
    QVERIFY(ch.current == 0);
    QVERIFY(ch.target == 123);

    ch = s1->armedChannels().at(1);
    QVERIFY(ch.address == fxi->universeAddress() + 7);
    QVERIFY(ch.start == 0);
    QVERIFY(ch.current == 0);
    QVERIFY(ch.target == 45);

    ch = s1->armedChannels().at(2);
    QVERIFY(ch.address == fxi->universeAddress() + 3);
    QVERIFY(ch.start == 0);
    QVERIFY(ch.current == 0);
    QVERIFY(ch.target == 67);

    s1->disarm();
    QVERIFY(s1->armedChannels().size() == 0);
    QVERIFY(s1->values().size() == 3);

    delete doc;
}
Example #18
0
void Collection::stop(MasterTimer* timer)
{
	Doc* doc = qobject_cast <Doc*> (parent());
	Q_ASSERT(doc != NULL);

	/* TODO: this stops these functions, regardless of whether they
	   were started by this collection or not */
	QListIterator <t_function_id> it(m_steps);
	while (it.hasNext() == true)
	{
		Function* function = doc->function(it.next());
		Q_ASSERT(function != NULL);
		function->stop(timer);
	}

	Function::stop(timer);
}
Example #19
0
static void ShowProperties(HWND parent, Doc doc, DisplayModel *dm, bool extended=false)
{
    PropertiesLayout *layoutData = FindPropertyWindowByParent(parent);
    if (layoutData) {
        SetActiveWindow(layoutData->hwnd);
        return;
    }

    if (!doc.IsEngine() && !doc.IsEbook())
        return;
    layoutData = new PropertiesLayout();
    gPropertiesWindows.Append(layoutData);
    GetProps(doc, layoutData, dm, extended);

    if (!CreatePropertiesWindow(parent, layoutData))
        delete layoutData;
}
Example #20
0
void launcher::Launcher::loadMaterialLibrary(std::string path)
{
    LOG_INFO("Loading material library from " << path);

    bfs::recursive_directory_iterator dir(path), end;
    for (; dir != end; dir++)
    {
        if (bfs::is_regular_file(dir->path()))
            if (ba::iends_with(dir->path().string(), ".xml"))
            {
                string fname = dir->path().string();
                LOG_DEBUG("Loading material library item from " << fname);
                Doc doc = Doc::fromFile(fname);
                loadMaterialsFromXml(doc.getRootElement().xpath("/materials/material"));
            }
    }
}
Example #21
0
bool Chaser::contains(quint32 functionId)
{
    Doc *doc = this->doc();
    Q_ASSERT(doc != NULL);

    foreach(ChaserStep step, m_steps)
    {
        Function *function = doc->function(step.fid);
        // contains() can be called during init, function may be NULL
        if (function == NULL)
            continue;

        if (function->id() == functionId)
            return true;
        if (function->contains(functionId))
            return true;
    }
Example #22
0
/*!
  Sets this Node's Doc to \a doc. If \a replace is false and
  this Node already has a Doc, a warning is reported that the
  Doc is being overridden, and it reports where the previous
  Doc was found. If \a replace is true, the Doc is replaced
  silently.
 */
void Node::setDoc(const Doc& doc, bool replace)
{
    if (!d.isEmpty() && !replace) {
        doc.location().warning(tr("Overrides a previous doc"));
        d.location().warning(tr("(The previous doc is here)"));
    }
    d = doc;
}
Example #23
0
void EbookController::SetDoc(Doc newDoc, int startReparseIdxArg, DisplayMode displayMode)
{
    CrashIf(!newDoc.IsDocLoaded());
    currPageReparseIdx = startReparseIdxArg;
    if ((size_t)currPageReparseIdx >= newDoc.GetHtmlDataSize())
        currPageReparseIdx = 0;
    CloseCurrentDocument();

    doc = newDoc;
    // displayMode could be any value if alternate UI was used, we have to limit it to
    // either DM_SINGLE_PAGE or DM_FACING
    if (DM_AUTOMATIC == displayMode)
        displayMode = gGlobalPrefs->defaultDisplayModeEnum;
    SetDisplayMode(displayMode);
    TriggerLayout();
    UpdateStatus();
}
Example #24
0
void MaskContentCommand::onExecute(Context* context)
{
  Doc* document;
  {
    ContextWriter writer(context);
    document = writer.document();

    Cel* cel = writer.cel(); // Get current cel (can be NULL)
    if (!cel)
      return;

    gfx::Color color;
    if (writer.layer()->isBackground()) {
      ColorPicker picker;
      picker.pickColor(*writer.site(),
                       gfx::PointF(0.0, 0.0),
                       current_editor->projection(),
                       ColorPicker::FromComposition);
      color = color_utils::color_for_layer(picker.color(), writer.layer());
    }
    else
      color = cel->image()->maskColor();

    Mask newMask;
    gfx::Rect imgBounds = cel->image()->bounds();
    if (algorithm::shrink_bounds(cel->image(), imgBounds, color)) {
      newMask.replace(imgBounds.offset(cel->bounds().origin()));
    }
    else {
      newMask.replace(cel->bounds());
    }

    Tx tx(writer.context(), "Select Content", DoesntModifyDocument);
    tx(new cmd::SetMask(document, &newMask));
    document->resetTransformation();
    tx.commit();
  }

  // Select marquee tool
  if (tools::Tool* tool = App::instance()->toolBox()
      ->getToolById(tools::WellKnownTools::RectangularMarquee)) {
    ToolBar::instance()->selectTool(tool);
  }

  update_screen_for_document(document);
}
Example #25
0
void SymmetryModeCommand::onExecute(Context* ctx)
{
  auto& enabled = Preferences::instance().symmetryMode.enabled;
  // When the m_mode is NONE, it toggles the whole symmetry controls in
  // the context bar.
  if (m_mode == app::gen::SymmetryMode::NONE) {
    enabled(!enabled());
  }
  // In other case it toggles the specific document symmetry specified
  // in m_mode.
  else {
    Doc* doc = ctx->activeDocument();
    DocumentPreferences& docPref = Preferences::instance().document(doc);
    const app::gen::SymmetryMode actual = docPref.symmetry.mode();

    // If the symmetry options are hidden, we'll always show them and
    // activate the m_mode symmetry. We cannot just toggle the
    // symmetry when the options aren't visible in the context bar,
    // because if m_mode is checked, this would cause to show the
    // symmetry options in the context bar but with a unchecked m_mode
    // symmetry.
    if (!enabled()) {
      docPref.symmetry.mode(app::gen::SymmetryMode(int(m_mode) | int(actual)));
      enabled(true);
    }
    // If the symmetry options are visible, we just switch the m_mode
    // symmetry.
    else {
      docPref.symmetry.mode(app::gen::SymmetryMode(int(m_mode) ^ int(actual)));
    }

    // Redraw all editors
    //
    // TODO It looks like only the current editor shows the symmetry,
    //      so it's not necessary to invalidate all editors (only the
    //      current one).
    doc->notifyGeneralUpdate();

    // Redraw the buttons in the context bar.
    //
    // TODO Same with context bar, in the future the context bar could
    //      be listening the DocPref changes to be automatically
    //      invalidated (like it already does with symmetryMode.enabled)
    App::instance()->contextBar()->updateForActiveTool();
  }
}
Example #26
0
void Page::LayOutPitchPos()
{
    Doc *doc = dynamic_cast<Doc *>(GetParent());
    assert(doc);

    // Doc::SetDrawingPage should have been called before
    // Make sure we have the correct page
    assert(this == doc->GetDrawingPage());

    // Set the pitch / pos alignement
    SetAlignmentPitchPosParams setAlignmentPitchPosParams(doc);
    Functor setAlignmentPitchPos(&Object::SetAlignmentPitchPos);
    this->Process(&setAlignmentPitchPos, &setAlignmentPitchPosParams);

    CalcStemParams calcStemParams(doc);
    Functor calcStem(&Object::CalcStem);
    this->Process(&calcStem, &calcStemParams);
}
Doc* Doc::findRep() {
  if (!parent_) {
    return this;
  } else {
    // Flatten the tree structure: important optimization to attain inverse ackermann running time
    parent_ = parent_->findRep();
    return parent_;
  }
}
Example #28
0
void MasterTimer::fadeAndStopAll(int timeout)
{
    if (timeout == 0)
        return;

    Doc* doc = qobject_cast<Doc*> (parent());
    Q_ASSERT(doc != NULL);

    QList<FadeChannel> fcList;

    QList<Universe *> universes = doc->inputOutputMap()->claimUniverses();
    for (int i = 0; i < universes.count(); i++)
    {
        QHashIterator <int,uchar> it(universes[i]->intensityChannels());
        while (it.hasNext() == true)
        {
            it.next();

            Fixture* fxi = doc->fixture(doc->fixtureForAddress(it.key()));
            if (fxi != NULL)
            {
                uint ch = it.key() - fxi->universeAddress();
                if (fxi->channelCanFade(ch))
                {
                    FadeChannel fc(doc, fxi->id(), ch);
                    fc.setStart(it.value());
                    fc.setTarget(0);
                    fc.setFadeTime(timeout);
                    fcList.append(fc);
                }
            }
        }
    }
    doc->inputOutputMap()->releaseUniverses();

    // Stop all functions first
    stopAllFunctions();

    // Instruct mastertimer to do a fade out of all
    // the intensity channels that can fade
    QMutexLocker faderLocker(&m_faderMutex);
    foreach(FadeChannel fade, fcList)
        fader()->add(fade);
}
Example #29
0
static void CreateThumbnailForDoc(Doc doc, DisplayState& ds)
{
    CrashIf(!doc.AsMobi() && !doc.AsEpub());

    if (!ShouldSaveThumbnail(ds))
        return;

    // if there is cover image, we use it to generate thumbnail by scaling
    // image width to thumbnail dx, scaling height proportionally and using
    // as much of it as fits in thumbnail dy
    RenderedBitmap *bmp = ThumbFromCoverPage(doc);
    if (!bmp) {
        // no cover image so generate thumbnail from first page
        SizeI pageSize(THUMBNAIL_DX * 3, THUMBNAIL_DY * 3);
        SizeI dstSize(THUMBNAIL_DX, THUMBNAIL_DY);
        bmp = RenderFirstDocPageToBitmap(doc, pageSize, dstSize, 10);
    }
    SaveThumbnailForFile(doc.GetFilePath(), bmp);
}
Example #30
0
VrmlMFNode* VrmlScene::readWrl( VrmlMFString *urls, Doc *relative,
				VrmlNamespace *ns )
{
  Doc url;
  int i, n = urls->size();
  for (i=0; i<n; ++i)
    {
      //theSystem->debug("Trying to read url '%s'\n", urls->get(i));
      url.seturl( urls->get(i), relative );
      VrmlMFNode *kids = VrmlScene::readWrl( &url, ns );
      if ( kids )
	return kids;
      else if (i < n-1 && strncmp(urls->get(i),"urn:",4))
	theSystem->warn("Couldn't read url '%s': %s\n",
			urls->get(i), strerror( errno));
    }

  return 0;
}