ThreadedAudioDevice::~ThreadedAudioDevice()
{
	// This code handles the rare case where the child thread is starting
	// at the same instant that the device is being destroyed.
	PRINT1("~ThreadedAudioDevice\n");
	if (starting() && _thread != 0) {
		waitForThread();
		starting(false);
	}
}
 void AdmittanceController::setMode(unsigned int mode) {
     if (mode_ != mode) {
         stopping();
         mode_ = mode;
         starting();
     }
 }
Esempio n. 3
0
	void TransferApi::loadTransfers() noexcept {
		// add the existing connections
		{
			auto cm = ConnectionManager::getInstance();
			RLock l(cm->getCS());
			for (const auto& d : cm->getTransferConnections(true)) {
				auto info = addTransfer(d, "Inactive, waiting for status updates");
				updateQueueInfo(info);
			}

			for (const auto& u : cm->getTransferConnections(false)) {
				addTransfer(u, "Inactive, waiting for status updates");
			}
		}

		{
			auto um = UploadManager::getInstance();
			RLock l(um->getCS());
			for (const auto& u : um->getUploads()) {
				if (u->getUserConnection().getState() == UserConnection::STATE_RUNNING) {
					on(UploadManagerListener::Starting(), u);
				}
			}
		}

		{
			auto dm = DownloadManager::getInstance();
			RLock l(dm->getCS());
			for (const auto& d : dm->getDownloads()) {
				if (d->getUserConnection().getState() == UserConnection::STATE_RUNNING) {
					starting(d, "Downloading", true);
				}
			}
		}
	}
Esempio n. 4
0
	void TransferApi::starting(const Download* aDownload, const string& aStatus, bool aFullUpdate) noexcept {
		auto t = getTransfer(aDownload->getToken());
		if (!t) {
			return;
		}

		t->setStatusString(aStatus);

		if (aFullUpdate) {
			starting(t, aDownload);
		} else {
			// All flags weren't known when requesting
			OrderedStringSet flags;
			aDownload->appendFlags(flags);
			t->setFlags(flags);

			// Size was unknown for filelists when requesting
			t->setSize(aDownload->getSegmentSize());

			view.onItemUpdated(t, { 
				TransferUtils::PROP_STATUS, TransferUtils::PROP_FLAGS, 
				TransferUtils::PROP_SIZE 
			});
		}
	}
Esempio n. 5
0
	void TransferApi::on(UploadManagerListener::Starting, const Upload* aUpload) noexcept {
		auto t = getTransfer(aUpload->getToken());
		if (!t) {
			return;
		}

		starting(t, aUpload);
	}
MainWindow::MainWindow()
{
    m_main = new MainArea();
    QGraphicsView* view = new QGraphicsView(m_main, this);
    view->setOptimizationFlags( QGraphicsView::DontClipPainter |
                                QGraphicsView::DontSavePainterState |
                                QGraphicsView::DontAdjustForAntialiasing );
//    view->setViewportUpdateMode( QGraphicsView::FullViewportUpdate );
    view->setCacheMode( QGraphicsView::CacheBackground );
    view->setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
    view->setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
    setCentralWidget(view);

    setupActions();

#ifndef Q_OS_QNX
    QLayout* l = layout();
    Q_ASSERT(l);
    l->setSizeConstraint(QLayout::SetFixedSize);

    // setup status bar
    KStatusBar* bar = statusBar();
    Q_ASSERT(bar);
    m_time_label = new QLabel("");
    bar->addPermanentWidget(m_time_label);

    m_balls_label = new QLabel("");
    bar->addWidget(m_balls_label);
//     bar->setItemAlignment(STATUSBAR_BALLS, Qt::AlignLeft);
#endif

    connect(m_main, SIGNAL(changeGameTime(int)), this, SLOT(setGameTime(int)));
    connect(m_main, SIGNAL(changeBallNumber(int)), this, SLOT(setBallNumber(int)));
    connect(m_main, SIGNAL(changeState(bool)), this, SLOT(changeState(bool)));
    connect(m_main, SIGNAL(pause(bool)), this, SLOT(pause(bool)));

#ifndef Q_OS_QNX
    stateChanged("playing", KXMLGUIClient::StateReverse);
#endif
    connect(m_main, SIGNAL(starting()), this, SLOT(newGame()));
    connect(m_main, SIGNAL(gameOver(int)), this, SLOT(gameOver(int)));

#ifndef Q_OS_QNX
    KGameDifficulty::init(this, this, SLOT(difficultyChanged(KGameDifficulty::standardLevel)));
    KGameDifficulty::setRestartOnChange(KGameDifficulty::RestartOnChange);
    KGameDifficulty::addStandardLevel(KGameDifficulty::Easy);
    KGameDifficulty::addStandardLevel(KGameDifficulty::Medium);
    KGameDifficulty::addStandardLevel(KGameDifficulty::Hard);
    KGameDifficulty::setLevel(KGameDifficulty::standardLevel(KollisionConfig::gameDifficulty()));
#endif

#ifdef Q_OS_QNX
    //setMinimumSize(m_main->sceneRect().size().toSize());
#endif
}
int ThreadedAudioDevice::doStop()
{
	if (!stopping()) {
		PRINT1("\tThreadedAudioDevice::doStop\n");
		stopping(true);		// signals play thread
		paused(false);
		waitForThread();
		starting(false);
	}
	return 0;
}
Esempio n. 8
0
void FakeBacktraceGenerator::sendData(const QString & filename)
{
    QFile file(filename);
    file.open(QIODevice::ReadOnly | QIODevice::Text);
    QTextStream stream(&file);

    emit starting();
    while (!stream.atEnd()) {
        emit newLine(stream.readLine() + '\n');
    }
    emit newLine(QString());
}
Esempio n. 9
0
bool BacktraceGenerator::start()
{
    //they should always be null before entering this function.
    Q_ASSERT(m_proc == NULL && m_temp == NULL);

    m_parsedBacktrace.clear();
    m_state = Loading;

    emit starting();

    if (!m_debugger.isValid() || !m_debugger.isInstalled()) {
        m_state = FailedToStart;
        emit failedToStart();
        return false;
    }

    m_proc = new KProcess;
    m_proc->setEnv("LC_ALL", "C");   // force C locale

    m_temp = new KTemporaryFile;
    m_temp->open();
    m_temp->write(m_debugger.backtraceBatchCommands().toLatin1());
    m_temp->write("\n", 1);
    m_temp->flush();

    // start the debugger
    QString str = m_debugger.command();
    Debugger::expandString(str, Debugger::ExpansionUsageShell, m_temp->fileName());

    *m_proc << KShell::splitArgs(str);
    m_proc->setOutputChannelMode(KProcess::OnlyStdoutChannel);
    m_proc->setNextOpenMode(QIODevice::ReadWrite | QIODevice::Text);
    connect(m_proc, SIGNAL(readyReadStandardOutput()),
            SLOT(slotReadInput()));
    connect(m_proc, SIGNAL(finished(int,QProcess::ExitStatus)),
            SLOT(slotProcessExited(int,QProcess::ExitStatus)));

    m_proc->start();
    if (!m_proc->waitForStarted()) {
        //we mustn't keep these around...
        m_proc->deleteLater();
        m_temp->deleteLater();
        m_proc = NULL;
        m_temp = NULL;

        m_state = FailedToStart;
        emit failedToStart();
        return false;
    }

    return true;
}
Esempio n. 10
0
void
EndSequence::start()
{
  if (isrunning) return;
  isrunning = true;
  isdone = false;

  Player& tux = *Sector::current()->player;
  end_sequence_controller.reset(new CodeController());
  tux.set_controller(end_sequence_controller.get());
  tux.set_speedlimit(230); //MAX_WALK_XM

  starting();
}
Esempio n. 11
0
PreProcessingPage::PreProcessingPage(Manager* const mngr, KAssistantDialog* const dlg)
    : KPWizardPage(dlg, i18n("<b>Pre-Processing Bracketed Images</b>")),
      d(new PreProcessingPagePriv)
{
    d->mngr          = mngr;
    d->progressTimer = new QTimer(this);
    KVBox *vbox      = new KVBox(this);
    d->title         = new QLabel(vbox);
    d->title->setWordWrap(true);
    d->title->setOpenExternalLinks(true);
    d->alignCheckBox = new QCheckBox(i18n("Align bracketed images"), vbox);
    KConfig config("kipirc");
    KConfigGroup group = config.group(QString("ExpoBlending Settings"));
    d->alignCheckBox->setChecked(group.readEntry("Auto Alignment", true));

    QLabel* space1   = new QLabel(vbox);
    KHBox* hbox      = new KHBox(vbox);
    d->detailsBtn    = new QPushButton(hbox);
    d->detailsBtn->setText(i18n("Details..."));
    d->detailsBtn->hide();
    QLabel* space2   = new QLabel(hbox);
    hbox->setStretchFactor(space2, 10);

    QLabel* space3   = new QLabel(vbox);
    d->progressLabel = new QLabel(vbox);
    d->progressLabel->setAlignment(Qt::AlignCenter);
    QLabel* space4   = new QLabel(vbox);

    vbox->setStretchFactor(space1, 2);
    vbox->setStretchFactor(space3, 2);
    vbox->setStretchFactor(space4, 10);
    vbox->setSpacing(KDialog::spacingHint());
    vbox->setMargin(KDialog::spacingHint());

    setPageWidget(vbox);

    resetTitle();

    QPixmap leftPix = KStandardDirs::locate("data", "kipiplugin_expoblending/pics/assistant-preprocessing.png");
    setLeftBottomPix(leftPix.scaledToWidth(128, Qt::SmoothTransformation));

    connect(d->mngr->thread(), SIGNAL(starting(KIPIExpoBlendingPlugin::ActionData)),
            this, SLOT(slotAction(KIPIExpoBlendingPlugin::ActionData)));

    connect(d->progressTimer, SIGNAL(timeout()),
            this, SLOT(slotProgressTimerDone()));

    connect(d->detailsBtn, SIGNAL(clicked()),
            this, SLOT(slotShowDetails()));
}
Esempio n. 12
0
void Gaming::stateChanged(QProcess::ProcessState state)
{
    switch(state){
    case QProcess::NotRunning:
        emit notRunning();
        break;
    case QProcess::Starting:
        emit starting();
        break;
    case QProcess::Running:
        emit running();
        break;
    }
}
int ThreadedAudioDevice::startThread()
{
	stopping(false);	// Reset.
	if (isPassive())	// Nothing else to do here if passive mode.
		return 0;
	starting(true);
#ifdef PROFILE
	getitimer(ITIMER_PROF, &globalTimerVal);
#endif
	PRINT1("\tThreadedAudioDevice::startThread: starting thread\n");
	int status = pthread_create(&_thread, NULL, _runProcess, this);
	if (status < 0) {
		error("Failed to create thread");
	}
	return status;
}
Esempio n. 14
0
void EventHandler::libeventCallback(int fd, short events, void* arg) {
  EventHandler* handler = reinterpret_cast<EventHandler*>(arg);
  assert(fd == handler->event_.ev_fd);

  auto observer = handler->eventBase_->getExecutionObserver();
  if (observer) {
    observer->starting(reinterpret_cast<uintptr_t>(handler));
  }

  // this can't possibly fire if handler->eventBase_ is nullptr
  (void) handler->eventBase_->bumpHandlingTime();

  handler->handlerReady(events);

  if (observer) {
    observer->stopped(reinterpret_cast<uintptr_t>(handler));
  }
}
Esempio n. 15
0
void AksenMain(void) {
	starting();	
	do {
		if (akt_time() >= timeoutAt) {
			setMotPow(0,0);
			break;
		}
		if(kurven == 8 && sensor[MID_MID] == 1 && sensor[MID_LEFT] == 1 && sensor[MID_RIGHT] == 1){
			setMotPow(0,0);
			break;		
		}
		followLine();
		countLines();
		manage(start);
		
				
	}while(1);
	while(1);
}
Esempio n. 16
0
bool BaseADCDebugLogger::start(std::size_t preSamplesCount, std::size_t postSamplesCount)
{
    if (preSamplesCount == 0 || postSamplesCount == 0)
         std::logic_error("Pre/post samples cound must not be 0");

     std::lock_guard<std::mutex> lock(_mutex);

     _triggerState = false;
     _preSamplesCount = preSamplesCount;
     _postSamplesCount = postSamplesCount;

     if (_workState == SavingState)
         return false;

     starting();

     _workState = WorkingState;

     return true;
}
Esempio n. 17
0
/*
Функция обрабатывающая текущее задание. Работает в два этапа: 1. формирует список файлов для копирования и 2. выполняет копирование со создание каталогов в каталоге destDir.
*/
void CopyJob::handle(int id, const QStringList& sourceFiles, const QDir& destDir)
{
  CopyInfoList files;
  int i, countFiles(0);
  
  // если каталог не существует, завершаем работу
  if ( !destDir.exists() ){ 
    emit error(id, DestDirNotExists, destDir.absolutePath());
    return;
  }
  
  emit starting(id);
  // если при подгатовке файлов к копированию произошла ошибка, завершает работу
  for ( i = 0; i < sourceFiles.count(); i++ )
    try{
      countFiles += prepareCopy(i, 0, sourceFiles.at(i), destDir.absolutePath(), files);
    }catch (const CopyExcepion& e){
      if ( e.error != UserTerminate ) emit error(id, e.error, e.strError);
      return;
    }
  
  emit startingCopy(id, countFiles); // сумарное колличество каталогов и файлов.
    
  i = 0;
  while ( i < files.count() ){
    try{
      files_copy(id, files.at(i), i+1);
      i++;
    }catch (const  CopyExcepion& e){
      if ( e.error == UserTerminate ) break;
      int uc = handleFilesCopyException(id, e.error, e.strError);
      if ( uc ==  CancelOper ) break; 
      if ( uc ==  SkipOper ) i = skipFiles(files, i);
    }
  } 
  
  emit finished(id);
}
void LearningPolicyCMASearch::train(learning::Policy* _policy,
                                    simulation::Simulator* _sim) {
    LOG(INFO) << FUNCTION_NAME();
    LOG(INFO) << "simulator type = " << _sim->type();

    shark::Rng::seed( (unsigned int) time (NULL) );

    PolicyEvaluation prob(_policy, _sim);
    shark::CMA cma;
    // cma.init( prob );
    // cma.setSigma(10.0);
    shark::RealVector starting(prob.numberOfVariables());
    // cma.init( prob, starting, 32, 16, 15.0 );
    // cma.init( prob, starting, 32, 16, 10.0 );
    cma.init( prob, starting, 32, 16, 1000.0 );


    int loopCount = 0;
    do {
        LOG(INFO) << "==== Loop " << loopCount << " ====";
        cma.step( prob );

        // Report information on the optimizer state and the current solution to the console.


        LOG(INFO) << prob.evaluationCounter() << " " << cma.solution().value << " " << cma.solution().point << " " << cma.sigma();

        // Update the params;
        shark::RealVector parameters = cma.solution().point;
        Eigen::VectorXd params(parameters.size());
        for (int i = 0; i < params.size(); i++) {
            params(i) = parameters(i);
        }
        _policy->setParams(params);
        loopCount++;
    } while(cma.solution().value > (0.0) && loopCount < 1000);

}
Esempio n. 19
0
ItemsPage::ItemsPage(Manager* const mngr, KAssistantDialog* const dlg)
         : KPWizardPage(dlg, i18n("<b>Set Bracketed Images</b>")),
           d(new ItemsPagePriv)
{
    d->mngr        = mngr;
    KVBox* vbox    = new KVBox(this);
    QLabel* label1 = new QLabel(vbox);
    label1->setWordWrap(true);
    label1->setText(i18n("<qt>"
                         "<p>Set here the list of your bracketed images to fuse. Please follow these conditions:</p>"
                         "<ul><li>At least 2 images from the same subject must be added to the stack.</li>"
                         "<li>Do not mix images with different color depth.</li>"
                         "<li>All images must have the same dimensions.</li></ul>"
                         "</qt>"));

    d->list = new KPImagesList(vbox);
    d->list->listView()->setColumn(KPImagesListView::User1, i18n("Exposure (EV)"), true);
    d->list->slotAddImages(d->mngr->itemsList());

    setPageWidget(vbox);

    QPixmap leftPix = KStandardDirs::locate("data", "kipiplugin_expoblending/pics/assistant-stack.png");
    setLeftBottomPix(leftPix.scaledToWidth(128, Qt::SmoothTransformation));

    connect(d->mngr->thread(), SIGNAL(starting(KIPIExpoBlendingPlugin::ActionData)),
            this, SLOT(slotAction(KIPIExpoBlendingPlugin::ActionData)));

    connect(d->mngr->thread(), SIGNAL(finished(KIPIExpoBlendingPlugin::ActionData)),
            this, SLOT(slotAction(KIPIExpoBlendingPlugin::ActionData)));

    connect(d->list, SIGNAL(signalAddItems(KUrl::List)),
            this, SLOT(slotAddItems(KUrl::List)));

    connect(d->list, SIGNAL(signalImageListChanged()),
            this, SLOT(slotImageListChanged()));

    QTimer::singleShot(0, this, SLOT(slotSetupList()));
}
int ThreadedAudioDevice::startThread()
{
	stopping(false);	// Reset.
	if (isPassive())	// Nothing else to do here if passive mode.
		return 0;
	starting(true);
#ifdef PROFILE
	getitimer(ITIMER_PROF, &globalTimerVal);
#endif
	PRINT1("\tThreadedAudioDevice::startThread: starting thread\n");
//	pthread_attr_t attr;
//	pthread_attr_init(&attr);
//	int status = pthread_attr_setschedpolicy(&attr, SCHED_RR);
	//if (status != 0) {
	//	fprintf(stderr, "startThread: Failed to set scheduling policy\n");
	//}
//	status = pthread_create(&_thread, &attr, _runProcess, this);
//	pthread_attr_destroy(&attr);
	//if (status < 0) {
	//	error("Failed to create thread");
	//}
	return 0;
}
Esempio n. 21
0
 void Server::doWork() {
     starting();
     while( 1 ) {
         lam f;
         try {
             scoped_lock lk(m);
             while( d.empty() )
                 c.wait(lk.boost());
             f = d.front();
             d.pop_front();
         }
         catch(...) {
             log() << "ERROR exception in Server:doWork?" << endl;
         }
         try {
             f();
             if( rq ) {
                 rq = false;
                 {
                     scoped_lock lk(m);
                     d.push_back(f);
                 }
             }
         }
         catch(std::exception& e) {
             log() << "Server::doWork task:" << name() << " exception:" << e.what() << endl;
         }
         catch(const char *p) {
             log() << "Server::doWork task:" << name() << " unknown c exception:" <<
                   ((p&&strlen(p)<800)?p:"?") << endl;
         }
         catch(...) {
             log() << "Server::doWork unknown exception task:" << name() << endl;
         }
     }
 }
Esempio n. 22
0
void ActionThread::run()
{
    d->running = true;
    while (d->running)
    {
        ActionThreadPriv::Task* t = 0;
        {
            QMutexLocker lock(&d->mutex);
            if (!d->todo.isEmpty())
                t = d->todo.takeFirst();
            else
                d->condVar.wait(&d->mutex);
        }

        if (t)
        {
            switch (t->action)
            {
                case IDENTIFY:
                case IDENTIFY_FULL:
                {
                    // Identify Camera model.
                    DcrawInfoContainer info;
                    KDcraw::rawFileIdentify(info, t->fileUrl.path());

                    QString identify = i18n("Cannot identify Raw image");
                    if (info.isDecodable)
                    {
                        if (t->action == IDENTIFY)
                            identify = info.make + QString("-") + info.model;
                        else
                        {
                            identify = i18n("Make: %1\n", info.make);
                            identify.append(i18n("Model: %1\n", info.model));

                            if (info.dateTime.isValid())
                            {
                                identify.append(i18n("Created: %1\n",
                                         KGlobal::locale()->formatDateTime(info.dateTime,
                                                                           KLocale::ShortDate, true)));
                            }

                            if (info.aperture != -1.0)
                            {
                                identify.append(i18n("Aperture: f/%1\n", QString::number(info.aperture)));
                            }

                            if (info.focalLength != -1.0)
                            {
                                identify.append(i18n("Focal: %1 mm\n", info.focalLength));
                            }

                            if (info.exposureTime != -1.0)
                            {
                                identify.append(i18n("Exposure: 1/%1 s\n", info.exposureTime));
                            }

                            if (info.sensitivity != -1)
                            {
                                identify.append(i18n("Sensitivity: %1 ISO", info.sensitivity));
                            }
                        }
                    }

                    ActionData ad;
                    ad.action  = t->action;
                    ad.fileUrl = t->fileUrl;
                    ad.message = identify;
                    ad.success = true;
                    emit finished(ad);
                    break;
                }

                case THUMBNAIL:
                {
                    // Get embedded RAW file thumbnail.
                    QImage image;
                    KDcraw::loadDcrawPreview(image, t->fileUrl.path());

                    ActionData ad;
                    ad.action  = t->action;
                    ad.fileUrl = t->fileUrl;
                    ad.image   = image;
                    ad.success = true;
                    emit finished(ad);
                    break;
                }

                case PROCESS:
                {
                    ActionData ad1;
                    ad1.action   = PROCESS;
                    ad1.fileUrl  = t->fileUrl;
                    ad1.starting = true;
                    emit starting(ad1);

                    QFileInfo fi(t->fileUrl.path());
                    QString destPath = fi.absolutePath() + QString("/") + ".kipi-dngconverter-tmp-"
                                     + QString::number(QDateTime::currentDateTime().toTime_t());

                    d->dngProcessor.reset();
                    d->dngProcessor.setInputFile(t->fileUrl.path());
                    d->dngProcessor.setOutputFile(destPath);
                    d->dngProcessor.setBackupOriginalRawFile(d->backupOriginalRawFile);
                    d->dngProcessor.setCompressLossLess(d->compressLossLess);
                    d->dngProcessor.setUpdateFileDate(d->updateFileDate);
                    d->dngProcessor.setPreviewMode(d->previewMode);
                    int ret = d->dngProcessor.convert();

                    ActionData ad2;
                    ad2.action   = PROCESS;
                    ad2.fileUrl  = t->fileUrl;
                    ad2.destPath = destPath;
                    ad2.success  = ret == 0 ? true : false;
                    emit finished(ad2);
                    break;
                }

                default:
                {
                    kError() << "KIPIDNGConverterPlugin:ActionThread: "
                             << "Unknown action specified";
                }
            }
        }

        delete t;
    }
}
Esempio n. 23
0
void BacktraceParser::connectToGenerator(QObject *generator)
{
    connect(generator, SIGNAL(starting()), this, SLOT(resetState()));
    connect(generator, SIGNAL(newLine(QString)), this, SLOT(newLine(QString)));
}
Esempio n. 24
0
 inline void set_started() { state.process_event(starting()); }
Esempio n. 25
0
ProcessorDlg::ProcessorDlg(const QList<QUrl>& list)
    : QDialog(0),
      d(new Private)
{
    setModal(false);
    setWindowTitle(QString::fromUtf8("Convert RAW files To PNG"));

    d->buttons               = new QDialogButtonBox(QDialogButtonBox::Apply | QDialogButtonBox::Close, this);
    d->thread                = new MyActionThread(this);
    d->list                  = list;
    d->count                 = d->list.count();
    qDebug() << d->list;

    d->page                  = new QWidget(this);
    QVBoxLayout* const vbx   = new QVBoxLayout(this);
    vbx->addWidget(d->page);
    vbx->addWidget(d->buttons);
    setLayout(vbx);

    int cpu                  = d->thread->maximumNumberOfThreads();
    QGridLayout* const grid  = new QGridLayout(d->page);
    QLabel* const pid        = new QLabel(QString::fromUtf8("Main PID: %1").arg(QCoreApplication::applicationPid()),  this);
    QLabel* const core       = new QLabel(QString::fromUtf8("CPU cores available: %1").arg(cpu), this);
    QWidget* const hbox      = new QWidget(this);
    d->items                 = new QLabel(this);

    QHBoxLayout* const hlay  = new QHBoxLayout(hbox);
    QLabel* const coresLabel = new QLabel(QString::fromUtf8("Cores to use: "), this);
    d->usedCore              = new QSpinBox(this);
    d->usedCore->setRange(1, cpu);
    d->usedCore->setSingleStep(1);
    d->usedCore->setValue(cpu);
    hlay->addWidget(coresLabel);
    hlay->addWidget(d->usedCore);
    hlay->setContentsMargins(QMargins());

    d->progressView = new QScrollArea(this);
    QWidget* const progressbox      = new QWidget(d->progressView->viewport());
    QVBoxLayout* const progressLay  = new QVBoxLayout(progressbox);
    d->progressView->setWidget(progressbox);
    d->progressView->setWidgetResizable(true);

    grid->addWidget(pid,             0, 0, 1, 1);
    grid->addWidget(core,            1, 0, 1, 1);
    grid->addWidget(hbox,            2, 0, 1, 1);
    grid->addWidget(d->items,        3, 0, 1, 1);
    grid->addWidget(d->progressView, 4, 0, 1, 1);

    foreach (const QUrl& url, d->list)
    {
        QProgressBar* const bar = new QProgressBar(progressbox);
        QString file            = url.toLocalFile();
        QFileInfo fi(file);
        bar->setMaximum(100);
        bar->setMinimum(0);
        bar->setValue(100);
        bar->setObjectName(file);
        bar->setFormat(fi.fileName());
        progressLay->addWidget(bar);
    }

    progressLay->addStretch();

    QPushButton* const applyBtn  = d->buttons->button(QDialogButtonBox::Apply);
    QPushButton* const cancelBtn = d->buttons->button(QDialogButtonBox::Close);

    connect(applyBtn, SIGNAL(clicked()),
            this, SLOT(slotStart()));

    connect(cancelBtn, SIGNAL(clicked()),
            this, SLOT(slotStop()));

    connect(d->thread, SIGNAL(starting(QUrl)),
            this, SLOT(slotStarting(QUrl)));

    connect(d->thread, SIGNAL(finished(QUrl)),
            this, SLOT(slotFinished(QUrl)));

    connect(d->thread, SIGNAL(failed(QUrl,QString)),
            this, SLOT(slotFailed(QUrl,QString)));

    connect(d->thread, SIGNAL(progress(QUrl,int)),
            this, SLOT(slotProgress(QUrl,int)));

    updateCount();
    resize(500, 400);
}
Esempio n. 26
0
void Info::showEvent(QShowEvent* show_Info){
     isClosed = false;
     starting();
     QWidget::showEvent(show_Info);
}
Esempio n. 27
0
void Thread::begin(){
	if(!isRunning()){
		emit starting();
		start(HighestPriority);
	}
}
Esempio n. 28
0
Python CProfile::WriteSketchDefn(HeeksObj* sketch, bool reversed )
{
	// write the python code for the sketch
	Python python;

	if ((sketch->GetShortString() != NULL) && (wxString(sketch->GetShortString()).size() > 0))
	{
		python << (wxString::Format(_T("comment(%s)\n"), PythonString(sketch->GetShortString()).c_str()));
	}

	python << _T("curve = area.Curve()\n");

	bool started = false;
	std::list<HeeksObj*> spans;
	switch(sketch->GetType())
	{
	case SketchType:
		for(HeeksObj* span_object = sketch->GetFirstChild(); span_object; span_object = sketch->GetNextChild())
		{
			if(reversed)spans.push_front(span_object);
			else spans.push_back(span_object);
		}
		break;
	case CircleType:
		spans.push_back(sketch);
		break;
	case AreaType:
		break;
	}

	std::list<HeeksObj*> new_spans;
	for(std::list<HeeksObj*>::iterator It = spans.begin(); It != spans.end(); It++)
	{
		HeeksObj* span = *It;
		if(span->GetType() == SplineType)
		{
			std::list<HeeksObj*> new_spans2;
			heeksCAD->SplineToBiarcs(span, new_spans2, CProfile::max_deviation_for_spline_to_arc);
			if(reversed)
			{
				for(std::list<HeeksObj*>::reverse_iterator It2 = new_spans2.rbegin(); It2 != new_spans2.rend(); It2++)
				{
					HeeksObj* s = *It2;
					new_spans.push_back(s);
				}
			}
			else
			{
				for(std::list<HeeksObj*>::iterator It2 = new_spans2.begin(); It2 != new_spans2.end(); It2++)
				{
					HeeksObj* s = *It2;
					new_spans.push_back(s);
				}
			}
		}
		else
		{
			new_spans.push_back(span->MakeACopy());
		}
	}

	for(std::list<HeeksObj*>::iterator It = new_spans.begin(); It != new_spans.end(); It++)
	{
		HeeksObj* span_object = *It;
		double s[3] = {0, 0, 0};
		double e[3] = {0, 0, 0};
		double c[3] = {0, 0, 0};


		if(span_object){
			int type = span_object->GetType();
			if(type == LineType || type == ArcType || type == CircleType)
			{
				if(!started && type != CircleType)
				{
					if(reversed)span_object->GetEndPoint(s);
					else span_object->GetStartPoint(s);
					CNCPoint start(s);

					python << _T("curve.append(area.Point(");
					python << start.X(true);
					python << _T(", ");
					python << start.Y(true);
					python << _T("))\n");
					started = true;
				}
				if(reversed)span_object->GetStartPoint(e);
				else span_object->GetEndPoint(e);
				CNCPoint end(e);

				if(type == LineType)
				{
					python << _T("curve.append(area.Point(");
					python << end.X(true);
					python << _T(", ");
					python << end.Y(true);
					python << _T("))\n");
				}
				else if(type == ArcType)
				{
					span_object->GetCentrePoint(c);
					CNCPoint centre(c);

					double pos[3];
					heeksCAD->GetArcAxis(span_object, pos);
					int span_type = ((pos[2] >=0) != reversed) ? 1: -1;
					python << _T("curve.append(area.Vertex(");
					python << (span_type);
					python << (_T(", area.Point("));
					python << end.X(true);
					python << (_T(", "));
					python << end.Y(true);
					python << (_T("), area.Point("));
					python << centre.X(true);
					python << (_T(", "));
					python << centre.Y(true);
					python << (_T(")))\n"));
				}
				else if(type == CircleType)
				{
					std::list< std::pair<int, gp_Pnt > > points;
					span_object->GetCentrePoint(c);

					double radius = heeksCAD->CircleGetRadius(span_object);

					// Setup the four arcs to make up the full circle using UNadjusted
					// coordinates.  We do this so that the offsets are expressed along the
					// X and Y axes.  We will adjust the resultant points later.

					// The kurve code needs a start point first.
					points.push_back( std::make_pair(0, gp_Pnt( c[0], c[1] + radius, c[2] )) ); // north
					if(reversed)
					{
						points.push_back( std::make_pair(1, gp_Pnt( c[0] - radius, c[1], c[2] )) ); // west
						points.push_back( std::make_pair(1, gp_Pnt( c[0], c[1] - radius, c[2] )) ); // south
						points.push_back( std::make_pair(1, gp_Pnt( c[0] + radius, c[1], c[2] )) ); // east
						points.push_back( std::make_pair(1, gp_Pnt( c[0], c[1] + radius, c[2] )) ); // north
					}
					else
					{
						points.push_back( std::make_pair(-1, gp_Pnt( c[0] + radius, c[1], c[2] )) ); // east
						points.push_back( std::make_pair(-1, gp_Pnt( c[0], c[1] - radius, c[2] )) ); // south
						points.push_back( std::make_pair(-1, gp_Pnt( c[0] - radius, c[1], c[2] )) ); // west
						points.push_back( std::make_pair(-1, gp_Pnt( c[0], c[1] + radius, c[2] )) ); // north
					}

					CNCPoint centre(c);

					for (std::list< std::pair<int, gp_Pnt > >::iterator l_itPoint = points.begin(); l_itPoint != points.end(); l_itPoint++)
					{
						CNCPoint pnt( l_itPoint->second );

						python << (_T("curve.append(area.Vertex("));
						python << l_itPoint->first << _T(", area.Point(");
						python << pnt.X(true);
						python << (_T(", "));
						python << pnt.Y(true);
						python << (_T("), area.Point("));
						python << centre.X(true);
						python << (_T(", "));
						python << centre.Y(true);
						python << (_T(")))\n"));
					} // End for
				}
			}
		}
	}

	// delete the spans made
	for(std::list<HeeksObj*>::iterator It = new_spans.begin(); It != new_spans.end(); It++)
	{
		HeeksObj* span = *It;
		delete span;
	}

	python << _T("\n");

	if(m_profile_params.m_start_given || m_profile_params.m_end_given)
	{
		double startx, starty, finishx, finishy;

		wxString start_string;
		if(m_profile_params.m_start_given)
		{
#ifdef UNICODE
			std::wostringstream ss;
#else
			std::ostringstream ss;
#endif

			gp_Pnt starting(m_profile_params.m_start[0] / theApp.m_program->m_units,
					m_profile_params.m_start[1] / theApp.m_program->m_units,
					0.0 );

			startx = starting.X();
			starty = starting.Y();

			ss.imbue(std::locale("C"));
			ss<<std::setprecision(10);
			ss << ", start = area.Point(" << startx << ", " << starty << ")";
			start_string = ss.str().c_str();
		}


		wxString finish_string;
		wxString beyond_string;
		if(m_profile_params.m_end_given)
		{
#ifdef UNICODE
			std::wostringstream ss;
#else
			std::ostringstream ss;
#endif

			gp_Pnt finish(m_profile_params.m_end[0] / theApp.m_program->m_units,
					m_profile_params.m_end[1] / theApp.m_program->m_units,
					0.0 );

			finishx = finish.X();
			finishy = finish.Y();

			ss.imbue(std::locale("C"));
			ss<<std::setprecision(10);
			ss << ", finish = area.Point(" << finishx << ", " << finishy << ")";
			finish_string = ss.str().c_str();

			if(m_profile_params.m_end_beyond_full_profile)beyond_string = _T(", end_beyond = True");
		}

		python << (wxString::Format(_T("kurve_funcs.make_smaller( curve%s%s%s)\n"), start_string.c_str(), finish_string.c_str(), beyond_string.c_str())).c_str();
	}

	return(python);
}
Esempio n. 29
0
	void TransferApi::on(DownloadManagerListener::Requesting, const Download* aDownload, bool hubChanged) noexcept {
		starting(aDownload, STRING(REQUESTING), true);
	}
Esempio n. 30
0
	void TransferApi::on(DownloadManagerListener::Starting, const Download* aDownload) noexcept {
		// No need for full update as it's done in the requesting phase
		starting(aDownload, "Starting...", false);
	}