bool CPfTeamPlayersDAOSQLiteEntity::deleteReg(CPfTeamPlayers *reg)
{
    std::string sql("DELETE FROM PF_TEAM_PLAYERS WHERE X_TEAM_PLAYER=");
    sql += "'"+reg->getXTeamPlayer_str()+"'";
    return exec(sql);
}
示例#2
0
//Exit function
void bye (void)
{
    printf("\nGoodbye, cruel world....\n%s",RESET);
    exec("killall fceux");
}
ExecuteCommandBuilder&  RobotController::release(int commandExitAction){
	return exec(commandExitAction).onEnter([](shared_ptr<RobotController> &rc){
		RCUtils::releaseObjects();
	});
}
示例#4
0
文件: TextLabel.cpp 项目: KDE/labplot
void TextLabel::setHorizontalAlignment(const TextLabel::HorizontalAlignment hAlign) {
	Q_D(TextLabel);
	if (hAlign != d->horizontalAlignment)
		exec(new TextLabelSetHorizontalAlignmentCmd(d, hAlign, i18n("%1: set horizontal alignment")));
}
示例#5
0
文件: TextLabel.cpp 项目: KDE/labplot
void TextLabel::setVisible(bool on) {
	Q_D(TextLabel);
	exec(new TextLabelSetVisibleCmd(d, on, on ? i18n("%1: set visible") : i18n("%1: set invisible")));
}
示例#6
0
文件: TextLabel.cpp 项目: KDE/labplot
void TextLabel::setTeXFontSize(const int fontSize) {
	Q_D(TextLabel);
	if (fontSize != d->teXFontSize)
		exec(new TextLabelSetTeXFontSizeCmd(d, fontSize, i18n("%1: set TeX font size")));
}
示例#7
0
文件: TextLabel.cpp 项目: KDE/labplot
void TextLabel::setPosition(const PositionWrapper& pos) {
	Q_D(TextLabel);
	if (pos.point!=d->position.point || pos.horizontalPosition!=d->position.horizontalPosition || pos.verticalPosition!=d->position.verticalPosition)
		exec(new TextLabelSetPositionCmd(d, pos, i18n("%1: set position")));
}
示例#8
0
PeopleModel::PeopleModel(QObject *parent) :
    QSqlQueryModel(parent)
{
    exec();
}
示例#9
0
void UserThread::run()
{
    serv->start();
    exec();
}
int main(int argc, char *argv[])
{
    exec("sh.coff", argc, argv);
}
示例#11
0
void User::run()
{
    qDebug()<<"run thread: "<< this->metaObject()->className();
    exec();
}
// This test verifies that a re-registering slave sends the terminal
// unacknowledged tasks for a terminal executor. This is required
// for the master to correctly reconcile it's view with the slave's
// view of tasks. This test drops a terminal update to the master
// and then forces the slave to re-register.
TEST_F(MasterSlaveReconciliationTest, SlaveReregisterTerminatedExecutor)
{
  Try<PID<Master> > master = StartMaster();
  ASSERT_SOME(master);

  MockExecutor exec(DEFAULT_EXECUTOR_ID);
  TestContainerizer containerizer(&exec);

  StandaloneMasterDetector detector(master.get());

  Try<PID<Slave> > slave = StartSlave(&containerizer, &detector);
  ASSERT_SOME(slave);

  MockScheduler sched;
  MesosSchedulerDriver driver(
      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);

  Future<FrameworkID> frameworkId;
  EXPECT_CALL(sched, registered(&driver, _, _))
    .WillOnce(FutureArg<1>(&frameworkId));

  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillOnce(LaunchTasks(DEFAULT_EXECUTOR_INFO, 1, 1, 512, "*"))
    .WillRepeatedly(Return()); // Ignore subsequent offers.

  ExecutorDriver* execDriver;
  EXPECT_CALL(exec, registered(_, _, _, _))
    .WillOnce(SaveArg<0>(&execDriver));

  EXPECT_CALL(exec, launchTask(_, _))
    .WillOnce(SendStatusUpdateFromTask(TASK_RUNNING));

  Future<TaskStatus> status;
  EXPECT_CALL(sched, statusUpdate(&driver, _))
    .WillOnce(FutureArg<1>(&status));

  Future<StatusUpdateAcknowledgementMessage> statusUpdateAcknowledgementMessage
    = FUTURE_PROTOBUF(
        StatusUpdateAcknowledgementMessage(), master.get(), slave.get());

  driver.start();

  AWAIT_READY(status);
  EXPECT_EQ(TASK_RUNNING, status.get().state());

  // Make sure the acknowledgement reaches the slave.
  AWAIT_READY(statusUpdateAcknowledgementMessage);

  // Drop the TASK_FINISHED status update sent to the master.
  Future<StatusUpdateMessage> statusUpdateMessage =
    DROP_PROTOBUF(StatusUpdateMessage(), _, master.get());

  Future<ExitedExecutorMessage> executorExitedMessage =
    FUTURE_PROTOBUF(ExitedExecutorMessage(), _, _);

  TaskStatus finishedStatus;
  finishedStatus = status.get();
  finishedStatus.set_state(TASK_FINISHED);
  execDriver->sendStatusUpdate(finishedStatus);

  // Ensure the update was sent.
  AWAIT_READY(statusUpdateMessage);

  // Now kill the executor.
  containerizer.destroy(frameworkId.get(), DEFAULT_EXECUTOR_ID);

  Future<TaskStatus> status2;
  EXPECT_CALL(sched, statusUpdate(&driver, _))
    .WillOnce(FutureArg<1>(&status2));

  // We drop the 'UpdateFrameworkMessage' from the master to slave to
  // stop the status update manager from retrying the update that was
  // already sent due to the new master detection.
  DROP_PROTOBUFS(UpdateFrameworkMessage(), _, _);

  detector.appoint(master.get());

  AWAIT_READY(status2);
  EXPECT_EQ(TASK_FINISHED, status2.get().state());

  driver.stop();
  driver.join();

  Shutdown();
}
// This test verifies that when the slave re-registers, the master
// does not send TASK_LOST update for a task that has reached terminal
// state but is waiting for an acknowledgement.
TEST_F(MasterSlaveReconciliationTest, SlaveReregisterTerminalTask)
{
  Try<PID<Master> > master = StartMaster();
  ASSERT_SOME(master);

  MockExecutor exec(DEFAULT_EXECUTOR_ID);

  StandaloneMasterDetector detector(master.get());

  Try<PID<Slave> > slave = StartSlave(&exec, &detector);
  ASSERT_SOME(slave);

  MockScheduler sched;
  MesosSchedulerDriver driver(
      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);

  EXPECT_CALL(sched, registered(&driver, _, _));

  Future<vector<Offer> > offers;
  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillOnce(FutureArg<1>(&offers))
    .WillRepeatedly(Return()); // Ignore subsequent offers.

  driver.start();

  AWAIT_READY(offers);
  EXPECT_NE(0u, offers.get().size());

  TaskInfo task;
  task.set_name("test task");
  task.mutable_task_id()->set_value("1");
  task.mutable_slave_id()->MergeFrom(offers.get()[0].slave_id());
  task.mutable_resources()->MergeFrom(offers.get()[0].resources());
  task.mutable_executor()->MergeFrom(DEFAULT_EXECUTOR_INFO);

  EXPECT_CALL(exec, registered(_, _, _, _));

  // Send a terminal update right away.
  EXPECT_CALL(exec, launchTask(_, _))
    .WillOnce(SendStatusUpdateFromTask(TASK_FINISHED));

  // Drop the status update from slave to the master, so that
  // the slave has a pending terminal update when it re-registers.
  DROP_PROTOBUF(StatusUpdateMessage(), _, master.get());

  Future<Nothing> _statusUpdate = FUTURE_DISPATCH(_, &Slave::_statusUpdate);

  Future<TaskStatus> status;
  EXPECT_CALL(sched, statusUpdate(&driver, _))
    .WillOnce(FutureArg<1>(&status))
    .WillRepeatedly(Return()); // Ignore retried update due to update framework.

  driver.launchTasks(offers.get()[0].id(), {task});

  AWAIT_READY(_statusUpdate);

  Future<SlaveReregisteredMessage> slaveReregisteredMessage =
    FUTURE_PROTOBUF(SlaveReregisteredMessage(), _, _);

  // Simulate a spurious master change event (e.g., due to ZooKeeper
  // expiration) at the slave to force re-registration.
  detector.appoint(master.get());

  AWAIT_READY(slaveReregisteredMessage);

  // The master should not send a TASK_LOST after the slave
  // re-registers. We check this by calling Clock::settle() so that
  // the only update the scheduler receives is the retried
  // TASK_FINISHED update.
  // NOTE: The status update manager resends the status update when
  // it detects a new master.
  Clock::pause();
  Clock::settle();

  AWAIT_READY(status);
  ASSERT_EQ(TASK_FINISHED, status.get().state());

  EXPECT_CALL(exec, shutdown(_))
    .Times(AtMost(1));

  driver.stop();
  driver.join();

  Shutdown();
}
// This test verifies that the master reconciles tasks that are
// missing from a re-registering slave. In this case, we trigger
// a race between the slave re-registration message and the launch
// message. There should be no TASK_LOST.
// This was motivated by MESOS-1696.
TEST_F(MasterSlaveReconciliationTest, ReconcileRace)
{
  Try<PID<Master> > master = StartMaster();
  ASSERT_SOME(master);

  MockExecutor exec(DEFAULT_EXECUTOR_ID);

  StandaloneMasterDetector detector(master.get());

  Future<SlaveRegisteredMessage> slaveRegisteredMessage =
    FUTURE_PROTOBUF(SlaveRegisteredMessage(), master.get(), _);

  Try<PID<Slave> > slave = StartSlave(&exec, &detector);
  ASSERT_SOME(slave);

  AWAIT_READY(slaveRegisteredMessage);

  MockScheduler sched;
  MesosSchedulerDriver driver(
      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);

  EXPECT_CALL(sched, registered(&driver, _, _));

  Future<vector<Offer> > offers;
  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillOnce(FutureArg<1>(&offers))
    .WillRepeatedly(Return()); // Ignore subsequent offers.

  driver.start();

  // Trigger a re-registration of the slave and capture the message
  // so that we can spoof a race with a launch task message.
  DROP_PROTOBUFS(ReregisterSlaveMessage(), slave.get(), master.get());

  Future<ReregisterSlaveMessage> reregisterSlaveMessage =
    DROP_PROTOBUF(ReregisterSlaveMessage(), slave.get(), master.get());

  detector.appoint(master.get());

  AWAIT_READY(reregisterSlaveMessage);

  AWAIT_READY(offers);
  EXPECT_NE(0u, offers.get().size());

  TaskInfo task;
  task.set_name("test task");
  task.mutable_task_id()->set_value("1");
  task.mutable_slave_id()->MergeFrom(offers.get()[0].slave_id());
  task.mutable_resources()->MergeFrom(offers.get()[0].resources());
  task.mutable_executor()->MergeFrom(DEFAULT_EXECUTOR_INFO);

  ExecutorDriver* executorDriver;
  EXPECT_CALL(exec, registered(_, _, _, _))
    .WillOnce(SaveArg<0>(&executorDriver));

  // Leave the task in TASK_STAGING.
  Future<Nothing> launchTask;
  EXPECT_CALL(exec, launchTask(_, _))
    .WillOnce(FutureSatisfy(&launchTask));

  EXPECT_CALL(sched, statusUpdate(&driver, _))
    .Times(0);

  driver.launchTasks(offers.get()[0].id(), {task});

  AWAIT_READY(launchTask);

  // Send the stale re-registration message, which does not contain
  // the task we just launched. This will trigger a reconciliation
  // by the master.
  Future<SlaveReregisteredMessage> slaveReregisteredMessage =
    FUTURE_PROTOBUF(SlaveReregisteredMessage(), _, _);

  // Prevent this from being dropped per the DROP_PROTOBUFS above.
  FUTURE_PROTOBUF(ReregisterSlaveMessage(), slave.get(), master.get());

  process::post(slave.get(), master.get(), reregisterSlaveMessage.get());

  AWAIT_READY(slaveReregisteredMessage);

  // Neither the master nor the slave should not send a TASK_LOST
  // as part of the reconciliation. We check this by calling
  // Clock::settle() to flush all pending events.
  Clock::pause();
  Clock::settle();
  Clock::resume();

  // Now send TASK_FINISHED and make sure it's the only message
  // received by the scheduler.
  Future<TaskStatus> status;
  EXPECT_CALL(sched, statusUpdate(&driver, _))
    .WillOnce(FutureArg<1>(&status));

  TaskStatus taskStatus;
  taskStatus.mutable_task_id()->CopyFrom(task.task_id());
  taskStatus.set_state(TASK_FINISHED);
  executorDriver->sendStatusUpdate(taskStatus);

  AWAIT_READY(status);
  ASSERT_EQ(TASK_FINISHED, status.get().state());

  EXPECT_CALL(exec, shutdown(_))
    .Times(AtMost(1));

  driver.stop();
  driver.join();

  Shutdown();
}
void TextDevice::run()
{
    exec();
}
示例#16
0
文件: exec.cpp 项目: tucci69/tcp_ssl
	/**
	 *  Parse and execute a command.
	 *
	 *  @param      a command line string
	 *  @param      return code from program
	 */
	int parse_and_exec(const std::string& cmdline)
	{
		std::vector<char*> arg = parse(cmdline);
		return exec(arg);
	}
示例#17
0
文件: TextLabel.cpp 项目: KDE/labplot
void TextLabel::setText(const TextWrapper &textWrapper) {
	Q_D(TextLabel);
	if ( (textWrapper.text != d->textWrapper.text) || (textWrapper.teXUsed != d->textWrapper.teXUsed) )
		exec(new TextLabelSetTextCmd(d, textWrapper, i18n("%1: set label text")));
}
// Ensures that when a scheduler enables explicit acknowledgements
// on the driver, there are no implicit acknowledgements sent, and
// the call to 'acknowledgeStatusUpdate' sends the ack to the master.
TEST_F(MesosSchedulerDriverTest, ExplicitAcknowledgements)
{
  Try<Owned<cluster::Master>> master = StartMaster();
  ASSERT_SOME(master);

  MockExecutor exec(DEFAULT_EXECUTOR_ID);
  TestContainerizer containerizer(&exec);

  Owned<MasterDetector> detector = master.get()->createDetector();

  Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), &containerizer);
  ASSERT_SOME(slave);

  MockScheduler sched;
  MesosSchedulerDriver driver(
      &sched,
      DEFAULT_FRAMEWORK_INFO,
      master.get()->pid,
      false,
      DEFAULT_CREDENTIAL);

  EXPECT_CALL(sched, registered(&driver, _, _));

  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillOnce(LaunchTasks(DEFAULT_EXECUTOR_INFO, 1, 1, 16, "*"))
    .WillRepeatedly(Return()); // Ignore subsequent offers.

  Future<TaskStatus> status;
  EXPECT_CALL(sched, statusUpdate(&driver, _))
    .WillOnce(FutureArg<1>(&status));

  // Ensure no status update acknowledgements are sent from the driver
  // to the master until the explicit acknowledgement is sent.
  EXPECT_NO_FUTURE_CALLS(
      mesos::scheduler::Call(),
      mesos::scheduler::Call::ACKNOWLEDGE,
      _ ,
      master.get()->pid);

  EXPECT_CALL(exec, registered(_, _, _, _));

  EXPECT_CALL(exec, launchTask(_, _))
    .WillOnce(SendStatusUpdateFromTask(TASK_RUNNING));

  EXPECT_CALL(exec, shutdown(_))
    .Times(AtMost(1));

  driver.start();

  AWAIT_READY(status);

  // Settle the clock to ensure driver finishes processing the status
  // update, we want to ensure that no implicit acknowledgement gets
  // sent.
  Clock::pause();
  Clock::settle();

  // Now send the acknowledgement.
  Future<mesos::scheduler::Call> acknowledgement = FUTURE_CALL(
      mesos::scheduler::Call(),
      mesos::scheduler::Call::ACKNOWLEDGE,
      _,
      master.get()->pid);

  driver.acknowledgeStatusUpdate(status.get());

  AWAIT_READY(acknowledgement);

  driver.stop();
  driver.join();
}
示例#19
0
文件: TextLabel.cpp 项目: KDE/labplot
void TextLabel::setTeXFontColor(const QColor fontColor) {
	Q_D(TextLabel);
	if (fontColor != d->teXFontColor)
		exec(new TextLabelSetTeXFontColorCmd(d, fontColor, i18n("%1: set TeX font color")));
}
bool PodcastSettingsDialog::configure()
{
    return exec() == QDialog::Accepted;
}
示例#21
0
文件: TextLabel.cpp 项目: KDE/labplot
void TextLabel::setRotationAngle(float angle) {
	Q_D(TextLabel);
	if (angle != d->rotationAngle)
		exec(new TextLabelSetRotationAngleCmd(d, angle, i18n("%1: set rotation angle")));
}
示例#22
0
QString QG_FileDialog::getOpenFile(RS2::FormatType* type){
//    bool fileAccepted = false;
    setAcceptMode ( QFileDialog::AcceptOpen );
    // read default settings:
    RS_SETTINGS->beginGroup("/Paths");
    QString defDir = RS_SETTINGS->readEntry("/Open",
                                              RS_SYSTEM->getHomeDir());
    RS_SETTINGS->endGroup();

    RS_DEBUG->print("defDir: %s", defDir.toLatin1().data());
    QString fn = "";
    QStringList filters;
#ifdef USE_DXFRW
    filters << fDxf << fDxfrw  << fDxf1 << fLff << fCxf << fJww;
#else
    filters << fDxf << fDxf1 << fLff << fCxf << fJww;
#endif

    setWindowTitle(tr("Open %1").arg(name));
#if QT_VERSION >= 0x040400
    setNameFilters(filters);
#endif
    setDirectory(defDir);
    setFileMode(QFileDialog::ExistingFile);
#if QT_VERSION >= 0x040400
    selectNameFilter(fDxfrw);
#endif
    ftype= RS2::FormatDXFRW;
    RS_DEBUG->print("defFilter: %s", fDxfrw.toLatin1().data());

    /* preview RVT PORT preview is currently not supported by QT4
    RS_Graphic* gr = new RS_Graphic;
    QG_GraphicView* prev = new QG_GraphicView(parent);
    prev->setContainer(gr);
    prev->setBorders(1, 1, 1, 1);
    fileDlg->setContentsPreviewEnabled(true);
    fileDlg->setContentsPreview(prev, prev); */

    if (exec()==QDialog::Accepted) {
        QStringList fl = selectedFiles();
        if (!fl.isEmpty()) {
            fn = fl[0];
        }
        fn = QDir::convertSeparators( QFileInfo(fn).absoluteFilePath() );

        if (type!=NULL) {
                getType(selectedFilter());
                *type = ftype;
        }

    // store new default settings:
        RS_SETTINGS->beginGroup("/Paths");
        RS_SETTINGS->writeEntry("/Open", QFileInfo(fn).absolutePath());
        RS_SETTINGS->writeEntry("/OpenFilter", selectedFilter());
        RS_SETTINGS->endGroup();
    }

    RS_DEBUG->print("QG_FileDialog::getOpenFileName: fileName: %s", fn.toLatin1().data());
    RS_DEBUG->print("QG_FileDialog::getOpenFileName: OK");

    // RVT PORT delete prev;
    // RVT PORT delete gr;
    return fn;
}
示例#23
0
文件: TextLabel.cpp 项目: KDE/labplot
void TextLabel::setVerticalAlignment(const TextLabel::VerticalAlignment vAlign) {
	Q_D(TextLabel);
	if (vAlign != d->verticalAlignment)
		exec(new TextLabelSetVerticalAlignmentCmd(d, vAlign, i18n("%1: set vertical alignment")));
}
示例#24
0
QString QG_FileDialog::getSaveFile(RS2::FormatType* type){
    setAcceptMode ( QFileDialog::AcceptSave );
    // read default settings:
    RS_SETTINGS->beginGroup("/Paths");
    QString defDir = RS_SETTINGS->readEntry("/Save",
                                              RS_SYSTEM->getHomeDir());
/*    QString defFilter = RS_SETTINGS->readEntry("/SaveFilter",
                                                 "Drawing Exchange DXF 2000 (*.dxf)");*/
    RS_SETTINGS->endGroup();

    if(!defDir.endsWith("/") && !defDir.endsWith("\\"))
        defDir += QDir::separator();

    RS_DEBUG->print("defDir: %s", defDir.toLatin1().data());

    // setup filters
    QStringList filters;

#ifdef USE_DXFRW
    filters << fDxf2000 << fDxfrw2000  << fDxfR12 << fLff << fCxf << fJww;
#else
    filters << fDxf2000 << fDxfR12 << fLff << fCxf << fJww;
#endif

    ftype = RS2::FormatDXF;
    RS_DEBUG->print("defFilter: %s", fDxf2000.toLatin1().data());

    // when defFilter is added the below should use the default extension.
    // generate an untitled name
    QString fn = "Untitled";
    if(QFile::exists( defDir + fn + getExtension( ftype ) ))
    {
        int fileCount = 1;
        while(QFile::exists( defDir + fn + QString("%1").arg(fileCount) +
                             getExtension(ftype)) )
            ++fileCount;
        fn += QString("%1").arg(fileCount);
    }

    // initialize dialog properties
    setWindowTitle(tr("Save %1 As").arg(name));
    setFileMode(QFileDialog::AnyFile);
    setDirectory(defDir);
    setFilters(filters);
#if QT_VERSION >= 0x040400
    selectNameFilter(fDxf2000);
#endif
    selectFile(fn);
    auto&& ext=getExtension(ftype);
    if(ext.size()==4){
        if(ext[0]=='.') ext.remove(0,1);
    }
    if(ext.size()==3) setDefaultSuffix (ext);


    // only return non empty string when we have a complete, user approved, file name.
    if (exec()!=QDialog::Accepted)
        return QString("");

    QStringList fl = selectedFiles();
    if (fl.isEmpty())
        return QString("");

    QFileInfo fi = QFileInfo( fl[0] );
    fn = QDir::convertSeparators( fi.absoluteFilePath() );

    getType(selectedFilter());
    if (type!=NULL)
        *type = ftype;

    // append default extension:
    if (fi.fileName().endsWith(".dxf",Qt::CaseInsensitive)==-1)
        fn += getExtension(ftype);

    // store new default settings:
    RS_SETTINGS->beginGroup("/Paths");
    RS_SETTINGS->writeEntry("/Save", fi.absolutePath());
    //RS_SETTINGS->writeEntry("/SaveFilter", fileDlg->selectedFilter());
    RS_SETTINGS->endGroup();

    return fn;
}
示例#25
0
/**
 * @brief MainWindow::MainWindow
 * @param parent
 */
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setMinimumHeight(500);

    MainWindow::m_instance = this;

    qDebug() << "MediaElch version" << QApplication::applicationVersion() << "starting up";

    for (int i=WidgetMovies ; i!=WidgetDownloads; i++) {
        QMap<MainActions, bool> actions;
        for (int n=ActionSearch ; n!=ActionExport ; n++) {
            actions.insert(static_cast<MainActions>(n), false);
        }
        if (static_cast<MainWidgets>(i) == WidgetMovies || static_cast<MainWidgets>(i) == WidgetTvShows || static_cast<MainWidgets>(i) == WidgetConcerts)
            actions[ActionFilterWidget] = true;
        m_actions.insert(static_cast<MainWidgets>(i), actions);
    }

    m_aboutDialog = new AboutDialog(ui->centralWidget);
    m_supportDialog = new SupportDialog(ui->centralWidget);
    m_settingsWindow = new SettingsWindow(ui->centralWidget);
    m_fileScannerDialog = new FileScannerDialog(ui->centralWidget);
    m_xbmcSync = new XbmcSync(ui->centralWidget);
    m_renamer = new Renamer(ui->centralWidget);
    m_settings = Settings::instance(this);
    m_exportDialog = new ExportDialog(this);
    setupToolbar();

    NotificationBox::instance(this)->reposition(this->size());
    Manager::instance();

    if (!m_settings->mainSplitterState().isNull()) {
        ui->movieSplitter->restoreState(m_settings->mainSplitterState());
        ui->tvShowSplitter->restoreState(m_settings->mainSplitterState());
        ui->setsWidget->splitter()->restoreState(m_settings->mainSplitterState());
        ui->concertSplitter->restoreState(m_settings->mainSplitterState());
        ui->genreWidget->splitter()->restoreState(m_settings->mainSplitterState());
        ui->certificationWidget->splitter()->restoreState(m_settings->mainSplitterState());
    }

    if (m_settings->mainWindowSize().isValid() && !m_settings->mainWindowPosition().isNull()) {
        resize(m_settings->mainWindowSize());
        move(m_settings->mainWindowPosition());
        #ifdef Q_OS_WIN32
        if (m_settings->mainWindowMaximized())
            showMaximized();
        #endif
    }
    // Size for Screenshots
    // resize(1121, 735);

    connect(ui->filesWidget, SIGNAL(movieSelected(Movie*)), ui->movieWidget, SLOT(setMovie(Movie*)));
    connect(ui->filesWidget, SIGNAL(movieSelected(Movie*)), ui->movieWidget, SLOT(setEnabledTrue(Movie*)));
    connect(ui->filesWidget, SIGNAL(noMovieSelected()), ui->movieWidget, SLOT(clear()));
    connect(ui->filesWidget, SIGNAL(noMovieSelected()), ui->movieWidget, SLOT(setDisabledTrue()));
    connect(ui->filesWidget, SIGNAL(sigStartSearch()), this, SLOT(onActionSearch()));

    connect(ui->concertFilesWidget, SIGNAL(concertSelected(Concert*)), ui->concertWidget, SLOT(setConcert(Concert*)));
    connect(ui->concertFilesWidget, SIGNAL(concertSelected(Concert*)), ui->concertWidget, SLOT(setEnabledTrue(Concert*)));
    connect(ui->concertFilesWidget, SIGNAL(noConcertSelected()), ui->concertWidget, SLOT(clear()));
    connect(ui->concertFilesWidget, SIGNAL(noConcertSelected()), ui->concertWidget, SLOT(setDisabledTrue()));

    connect(ui->tvShowFilesWidget, SIGNAL(sigTvShowSelected(TvShow*)), ui->tvShowWidget, SLOT(onTvShowSelected(TvShow*)));
    connect(ui->tvShowFilesWidget, SIGNAL(sigSeasonSelected(TvShow*,int)), ui->tvShowWidget, SLOT(onSeasonSelected(TvShow*,int)));
    connect(ui->tvShowFilesWidget, SIGNAL(sigEpisodeSelected(TvShowEpisode*)), ui->tvShowWidget, SLOT(onEpisodeSelected(TvShowEpisode*)));
    connect(ui->tvShowFilesWidget, SIGNAL(sigTvShowSelected(TvShow*)), ui->tvShowWidget, SLOT(onSetEnabledTrue(TvShow*)));
    connect(ui->tvShowFilesWidget, SIGNAL(sigSeasonSelected(TvShow*,int)), ui->tvShowWidget, SLOT(onSetEnabledTrue(TvShow*, int)));
    connect(ui->tvShowFilesWidget, SIGNAL(sigEpisodeSelected(TvShowEpisode*)), ui->tvShowWidget, SLOT(onSetEnabledTrue(TvShowEpisode*)));
    connect(ui->tvShowFilesWidget, SIGNAL(sigNothingSelected()), ui->tvShowWidget, SLOT(onClear()));
    connect(ui->tvShowFilesWidget, SIGNAL(sigNothingSelected()), ui->tvShowWidget, SLOT(onSetDisabledTrue()));

    connect(ui->movieWidget, SIGNAL(actorDownloadProgress(int,int,int)), this, SLOT(progressProgress(int,int,int)));
    connect(ui->movieWidget, SIGNAL(actorDownloadStarted(QString,int)), this, SLOT(progressStarted(QString,int)));
    connect(ui->movieWidget, SIGNAL(actorDownloadFinished(int)), this, SLOT(progressFinished(int)));

    connect(ui->tvShowWidget, SIGNAL(sigDownloadsStarted(QString,int)), this, SLOT(progressStarted(QString,int)));
    connect(ui->tvShowWidget, SIGNAL(sigDownloadsProgress(int,int,int)), this, SLOT(progressProgress(int,int,int)));
    connect(ui->tvShowWidget, SIGNAL(sigDownloadsFinished(int)), this, SLOT(progressFinished(int)));

    connect(ui->navbar, SIGNAL(sigFilterChanged(QList<Filter*>,QString)), this, SLOT(onFilterChanged(QList<Filter*>,QString)));

    connect(ui->movieSplitter, SIGNAL(splitterMoved(int,int)), this, SLOT(moveSplitter(int,int)));
    connect(ui->tvShowSplitter, SIGNAL(splitterMoved(int,int)), this, SLOT(moveSplitter(int,int)));
    connect(ui->setsWidget->splitter(), SIGNAL(splitterMoved(int,int)), this, SLOT(moveSplitter(int,int)));
    connect(ui->genreWidget->splitter(), SIGNAL(splitterMoved(int,int)), this, SLOT(moveSplitter(int,int)));
    connect(ui->certificationWidget->splitter(), SIGNAL(splitterMoved(int,int)), this, SLOT(moveSplitter(int,int)));
    connect(ui->concertSplitter, SIGNAL(splitterMoved(int,int)), this, SLOT(moveSplitter(int,int)));

    connect(Manager::instance()->tvShowFileSearcher(), SIGNAL(tvShowsLoaded(int)), ui->tvShowFilesWidget, SLOT(renewModel()));
    connect(Manager::instance()->tvShowFileSearcher(), SIGNAL(tvShowsLoaded(int)), this, SLOT(updateTvShows()));
    connect(m_fileScannerDialog, SIGNAL(accepted()), this, SLOT(setNewMarks()));
    connect(ui->downloadsWidget, SIGNAL(sigScanFinished(bool)), this, SLOT(setNewMarkForImports(bool)));

    connect(m_xbmcSync, SIGNAL(sigTriggerReload()), this, SLOT(onTriggerReloadAll()));
    connect(m_xbmcSync, SIGNAL(sigFinished()), this, SLOT(onXbmcSyncFinished()));

    connect(m_renamer, SIGNAL(sigFilesRenamed(Renamer::RenameType)), this, SLOT(onFilesRenamed(Renamer::RenameType)));

    connect(m_settingsWindow, SIGNAL(sigSaved()), this, SLOT(onRenewModels()), Qt::QueuedConnection);

    connect(ui->setsWidget, SIGNAL(sigJumpToMovie(Movie*)), this, SLOT(onJumpToMovie(Movie*)));
    connect(ui->certificationWidget, SIGNAL(sigJumpToMovie(Movie*)), this, SLOT(onJumpToMovie(Movie*)));
    connect(ui->genreWidget, SIGNAL(sigJumpToMovie(Movie*)), this, SLOT(onJumpToMovie(Movie*)));

    connect(Update::instance(this), SIGNAL(sigNewVersion(QString)), this, SLOT(onNewVersion(QString)));

    MovieSearch::instance(ui->centralWidget);
    TvShowSearch::instance(ui->centralWidget);
    ImageDialog::instance(ui->centralWidget);
    MovieListDialog::instance(ui->centralWidget);
    ImagePreviewDialog::instance(ui->centralWidget);
    ConcertSearch::instance(ui->centralWidget);
    TrailerDialog::instance(ui->centralWidget);
    TvTunesDialog::instance(ui->centralWidget);
    NameFormatter::instance(this);
    MovieMultiScrapeDialog::instance(ui->centralWidget);
    Notificator::instance(0, ui->centralWidget);

#ifdef Q_OS_WIN32
    setStyleSheet(styleSheet() + " #centralWidget { border-bottom: 1px solid rgba(0, 0, 0, 100); } ");

    QFont font = ui->labelMovies->font();
    font.setPointSize(font.pointSize()-3);
    font.setBold(true);
    ui->labelMovies->setFont(font);
    ui->labelConcerts->setFont(font);
    ui->labelShows->setFont(font);
    ui->labelDownloads->setFont(font);
#endif

    // hack. without only the fileScannerDialog pops up and blocks until it has finished
    show();
    onMenu(WidgetMovies);

    // Start scanning for files
    QTimer::singleShot(0, m_fileScannerDialog, SLOT(exec()));

    if (Settings::instance()->checkForUpdates())
        Update::instance()->checkForUpdate();
}
示例#26
0
/*!
  This is the main routine for parsing input on the clientSocket.
  There should be one command for each line of input.  This reads one
  line, and looks at the first word (up to the first space character) to
  determine the command.   Then if there are body or robot indices to read,
  it calls a support routine to read those and return a vector of bodies or
  robots.  These are then passed to the appropriate routine to carry out the
  action and write out any necessary results.
*/
void
ClientSocket::readClient()
{
  int i,numData,numBodies,numRobots;
  double time;
  std::vector<Body *> bodyVec;
  std::vector<Robot *> robVec;

  bool ok;

  while ( sock->canReadLine() ) {
    line = sock->readLine();
    line.truncate(line.length()-1); //strip newline character
    lineStrList =
      QStringList::split(' ',line);
    if (!lineStrList.size() > 0)
        return;
    strPtr = lineStrList.begin();

#ifdef GRASPITDBG
    std::cout <<"Command parser line: "<<line << std::endl;
#endif
    
    if (*strPtr == "getContacts") {
      strPtr++; if (strPtr == lineStrList.end()) continue;
      numData = (*strPtr).toInt(&ok); strPtr++;
      if (!ok) continue;

#ifdef GRASPITDBG
      std::cout << "Num data: "<<numData<<std::endl;
#endif

      if (readBodyIndList(bodyVec)) continue;
      numBodies = bodyVec.size();
      for (i=0;i<numBodies;i++)
        sendContacts(bodyVec[i],numData);
    }
    
    else if (*strPtr == "getAverageContacts") {
      strPtr++;
      if (readBodyIndList(bodyVec)) continue;
      numBodies = bodyVec.size();
      for (i=0;i<numBodies;i++)
	sendAverageContacts(bodyVec[i]);
    }
    
    else if (*strPtr == "getBodyName") {
      strPtr++;
      if (readBodyIndList(bodyVec)) continue;
      numBodies = bodyVec.size();
      for (i=0;i<numBodies;i++)
	sendBodyName(bodyVec[i]);
    }
    else if(*strPtr == "setBodyName") {
      strPtr++;
      int body_index;
      if(strPtr != lineStrList.end()){
        body_index = strPtr->toInt(&ok);
        strPtr++;
        if(strPtr == lineStrList.end())
          return;
        if (body_index == -1 || body_index >= graspItGUI->getIVmgr()->getWorld()->getNumBodies())
        {
          body_index = graspItGUI->getIVmgr()->getWorld()->getNumBodies() - 1;          
        }
        graspItGUI->getIVmgr()->getWorld()->getBody(body_index)->setName(*strPtr);
      }
    }
    
    else if (*strPtr == "getRobotName") {
      strPtr++;
      if (readRobotIndList(robVec)) continue;
      numRobots = robVec.size();
      for (i=0;i<numRobots;i++)
	sendRobotName(robVec[i]);
    }
    
    else if (*strPtr == "getDOFVals") {
      strPtr++;
      if (readRobotIndList(robVec)) continue;
      numRobots = robVec.size();
      for (i=0;i<numRobots;i++)
	sendDOFVals(robVec[i]);
    }
    
    else if (*strPtr == "moveDOFs") {
      strPtr++;
      readDOFVals();
    }
    
    else if (*strPtr == "render")
      graspItGUI->getIVmgr()->getViewer()->render();
    
    else if (*strPtr == "setDOFForces") {
      strPtr++;
      if (readRobotIndList(robVec)) continue;
      numRobots = robVec.size();
      for (i=0;i<numRobots;i++)
	if (readDOFForces(robVec[i])==FAILURE) continue;
    }
    
    else if ((*strPtr) == "moveDynamicBodies") {
      strPtr++;
      if (strPtr == lineStrList.end()) ok = FALSE;
      else {
	time = (*strPtr).toDouble(&ok); strPtr++;
      }
      if (!ok)
	moveDynamicBodies(-1);
      else
	moveDynamicBodies(time);
    }
    
    else if (*strPtr == "computeNewVelocities") {

#ifdef GRASPITDBG
      std::cout << "cnv" << std::endl;
#endif

      strPtr++; if (strPtr == lineStrList.end()) continue;
      time = (*strPtr).toDouble(&ok); strPtr++;
      if (!ok) continue;

#ifdef GRASPITDBG
      std::cout << time <<std::endl;
#endif
      computeNewVelocities(time);
    }    
    else if ((*strPtr) == "outputPlannerResults"){      
      strPtr++;
      outputPlannerResults(0);      
    }
    else if ((*strPtr) == "outputCurrentGrasp"){      
      strPtr++;
      outputCurrentGrasp();
    }    
    else if ((*strPtr) == "sendBodyTransf"){            
      strPtr++;
      verifyInput(1);
      sendBodyTransf();
    }
    else if ((*strPtr) == "setBodyTransf"){            
      strPtr++;
      verifyInput(7);
      setBodyTransf();
    }
    else if ((*strPtr) == "addObstacle"){            
      strPtr++;
      verifyInput(1);
      addObstacle(*(strPtr+1));
      strPtr+=2;
    }
    else if ((*strPtr) == "addObject"){
      verifyInput(2);
      addGraspableBody(*(strPtr+1), *(strPtr+2));
      strPtr+=3;
      verifyInput(7);
      transf object_pose;
      readTransf(&object_pose);
      World * w = graspItGUI->getIVmgr()->getWorld();
      w->getGB(w->getNumGB() - 1)->setTran(object_pose);
    }
    
    else if ((*strPtr) == "getCurrentHandTran"){
      strPtr++;
      getCurrentHandTran();
    }
    else if ((*strPtr) == "signalGraspUnreachable"){
      strPtr+=4;
      std::cout << line.toStdString() << std::endl;
      graspItGUI->getIVmgr()->blinkBackground();
    }
    else if ((*strPtr) == "setBackgroundColor"){
      ++strPtr;
      bool ok;
      double r = strPtr->toDouble(&ok);
      ++strPtr;
      double g = strPtr->toDouble(&ok);
      ++strPtr;
      double b = strPtr->toDouble(&ok);
      ++strPtr;
      graspItGUI->getIVmgr()->getViewer()->setBackgroundColor(SbColor(r,g,b));
    }

    else if ((*strPtr) == "getPlannerTarget"){
      strPtr+=1;
      QTextStream os(sock) ;
      os << graspItGUI->getIVmgr()->getWorld()->getCurrentHand()->getGrasp()->getObject()->getName() << "\n";
    } 
    else if ((*strPtr) == "setPlannerTarget"){
      QTextStream os(sock);
      os << setPlannerTarget(*(strPtr+1)) << "\n";
      strPtr+=2;

    }    

    else if ((*strPtr) == "rotateHandLat"){
      strPtr+=1;
      rotateHandLat();
    }
    else if ((*strPtr) == "rotateHandLong"){
      strPtr+=1;
      rotateHandLong();
    }    
    else if ((*strPtr) == "exec"){
      strPtr+=1;
      exec();
    } 
    else if ((*strPtr) == "next"){
      strPtr+=1;
      next();
    }
    else if ((*strPtr) == "state"){
      strPtr+=1;
      recievedStateMsg();
    }
    else if ((*strPtr) == "addPointCloud")
    {
      strPtr += 1;
      addPointCloud();
      //QTextStream os(sock);
      //os << addPointCloud() <<" \n";

    }
    else if ((*strPtr) == "setCameraOrigin")
      {
	strPtr += 1;
	setCameraOrigin();
      }
    else if ((*strPtr) == "removeBodies"){
      strPtr += 1;
      removeBodies();
    }
    else if ((*strPtr) == "clearGraspableBodies"){
      strPtr += 1;
      removeBodies(true);
            
    }
    else if ((*strPtr) == "setGraspAttribute"){
      	strPtr += 1;
	verifyInput(3);
	setGraspAttribute();
      	
    }
    else if ((*strPtr) == "drawCircle"){
      strPtr += 1;
	    drawCircle();  
    }
    else if ((*strPtr) == "drawCursor"){
      strPtr += 1;
        drawCursor();
    }
    else if ((*strPtr) == "connectToPlanner")
    {
      connect(graspItGUI->getIVmgr(), SIGNAL( analyzeApproachDir(GraspPlanningState *) ), this, SLOT(analyzeApproachDir(GraspPlanningState*)));
      connect(graspItGUI->getIVmgr(), SIGNAL( analyzeGrasp(const GraspPlanningState *) ), this, SLOT(analyzeGrasp(const GraspPlanningState*)));
      connect(graspItGUI->getIVmgr(), SIGNAL( analyzeNextGrasp() ), this, SLOT(analyzeNextGrasp()));       
      connect(graspItGUI->getIVmgr(), SIGNAL( processWorldPlanner(int) ), this, SLOT( outputPlannerResults(int)));
      connect(graspItGUI->getIVmgr(), SIGNAL( runObjectRecognition() ), this, SLOT( runObjectRecognition() ));
      connect(graspItGUI->getIVmgr(), SIGNAL( sendString(const QString &) ), this, SLOT( sendString(const QString &) ));	  
      QTextStream os(sock);
      os << "1 \n";
      os.flush();
    }
    else if ((*strPtr) =="setRobotColor")
示例#27
0
ExecuteCommandBuilder&  RobotController::grab(shared_ptr<Entity> &obj, int commandExitAction){
	return exec(commandExitAction).onEnter([obj, this](shared_ptr<RobotController> &rc){
		RCUtils::pinObjectToEffector(obj, *rc->robot);
	});
}
示例#28
0
void TestSuiteBasic::run() {
  emit sendOutput("--------- Basic Test ----------");
  basicTestCreateObjects();

  if (m_3DPoints >= 0) {
    rt3DPointBufferDataObject* ptObj = static_cast<rt3DPointBufferDataObject*>(rtBaseHandle::instance().getObjectWithID(m_3DPoints));

    if (!ptObj) {
      emit sendOutput("Could Not Get 3D Sphere Object! FAIL!");
    } else {

      emit sendOutput("Setting Data for 3D Spheres...");
      rtBasic3DPointData pp[10][10];
      rtBasic3DPointData p[4];

      p[0].setX(0.0);
      p[0].setY(0.0);
      p[0].setZ(0.0);
      p[0].setPointSize(0.25);
      p[0].getProperty()->SetColor(1, 0, 0); //Red
      p[0].getProperty()->SetOpacity(0.2);

      p[1].setX(1.0);
      p[1].setY(0.0);
      p[1].setZ(0.0);
      p[1].setPointSize(0.25);
      p[1].getProperty()->SetColor(1, 0, 0);

      p[2].setX(0.0);
      p[2].setY(1.0);
      p[2].setZ(0.0);
      p[2].setPointSize(0.25);
      p[2].getProperty()->SetColor(0, 1, 0);

      p[3].setX(0.0);
      p[3].setY(0.0);
      p[3].setZ(1.0);
      p[3].setPointSize(0.25);
      p[3].getProperty()->SetColor(0, 0, 1);

      ptObj->lock();
      for (int ix1=0; ix1<4; ix1++) {
        ptObj->addPoint(p[ix1]);
      }

      // Add 100 semi-transparent spheres.
      for (int ix1=2; ix1<12; ix1++) {
        for (int ix2=2; ix2<12; ix2++) {
          pp[ix1-2][ix2-2].setX(ix1);
          pp[ix1-2][ix2-2].setY(ix2);
          pp[ix1-2][ix2-2].setZ(2);
          pp[ix1-2][ix2-2].setPointSize(0.25);
          pp[ix1-2][ix2-2].getProperty()->SetColor(0,1,0);
          pp[ix1-2][ix2-2].getProperty()->SetOpacity(0.2);
          ptObj->addPoint(pp[ix1-2][ix2-2]);
        }
      }
      ptObj->Modified();
      ptObj->unlock();
    }
      
    m_lookupTable->SetHueRange(0.5, 1.0);
    m_lookupTable->SetSaturationRange(0.5, 1.0);
    m_lookupTable->SetValueRange(0.5, 1.0);

    m_imgMapToColors->SetOutputFormatToRGB();
    m_imgMapToColors->SetLookupTable(m_lookupTable);

  }


  if (m_cath[0]) {
    rtCathDataObject* ptObj = static_cast<rtCathDataObject*>(rtBaseHandle::instance().getObjectWithID(m_cath[0]));
    if (!ptObj) {
      emit sendOutput("Could Not Get 1 Coil Catheter Object! FAIL!");
    } else {
      emit sendOutput("Setting Cath Data...");
      ptObj->lock();
      int c1 = ptObj->addCoil(0);
      ptObj->setCoilCoords(c1, 1.5, 1.5, 1.5);
      ptObj->addCathProperty("SNR");
      ptObj->setCoilPropValue(c1,"SNR",50);
      ptObj->Modified();
      ptObj->unlock();
    }
  }

  if (m_cath[1]) {
    rtCathDataObject* ptObj = static_cast<rtCathDataObject*>(rtBaseHandle::instance().getObjectWithID(m_cath[1]));
    if (!ptObj) {
      emit sendOutput("Could Not Get 2 Coil Catheter Object! FAIL!");
    } else {
      emit sendOutput("Setting Cath Data...");
      ptObj->lock();
      int c1 = ptObj->addCoil(0);
      int c2 = ptObj->addCoil(1);
      ptObj->setCoilCoords(c1, 1.5, 1.5, 1.5);
      ptObj->addCathProperty("SNR");
      ptObj->setCoilPropValue(c1,"SNR",50);
      ptObj->setCoilCoords(c2, 13.2, 7.5, 2.5);
      ptObj->setCoilPropValue(c2,"SNR",25);
      ptObj->Modified();
      ptObj->unlock();
    }
  }

  if (m_cath[2]) {
    rtCathDataObject* ptObj = static_cast<rtCathDataObject*>(rtBaseHandle::instance().getObjectWithID(m_cath[2]));
    if (!ptObj) {
      emit sendOutput("Could Not Get 5 Coil Catheter Object! FAIL!");
    } else {
      emit sendOutput("Setting Cath Data...");
      ptObj->lock();
      int c1 = ptObj->addCoil(0);
      int c2 = ptObj->addCoil(0);
      int c3 = ptObj->addCoil(1);
      int c4 = ptObj->addCoil(2);
      int c5 = ptObj->addCoil(3);
      ptObj->addCathProperty("SNR");
      ptObj->setCoilCoords(c1, 1.5, 1.5, 1.5);
      ptObj->setCoilPropValue(c1,"SNR",50);
      ptObj->setCoilCoords(c2, 1.6, 1.4, 1.3);
      ptObj->setCoilPropValue(c2,"SNR",25);
      ptObj->setCoilCoords(c3, 13.2, 7.5, 2.5);
      ptObj->setCoilPropValue(c3,"SNR",80);
      ptObj->setCoilCoords(c4, 22.5, 9.0, 7.0);
      ptObj->setCoilPropValue(c4,"SNR",30);
      ptObj->setCoilCoords(c5, 27.3, 11.2, 9.1);
      ptObj->setCoilPropValue(c5,"SNR",10);
      ptObj->Modified();
      ptObj->unlock();
    }
  }

  if (m_smallVol >= 0) {
    rt3DVolumeDataObject* ptObj = static_cast<rt3DVolumeDataObject*>(rtBaseHandle::instance().getObjectWithID(m_smallVol));
    if (!ptObj) {
      emit sendOutput("Could Not Get Small Volume Object! FAIL!");
    } else {
      emit sendOutput("Load Small Volume Data...");
      vtkImageSinusoidSource* sinSrc = vtkImageSinusoidSource::New();

      sinSrc->SetWholeExtent(0,127, 0, 127, 0, 127);
      sinSrc->SetDirection(1, 2, 3);
      sinSrc->SetPeriod(25);
      sinSrc->SetPhase(1);
      sinSrc->SetAmplitude(10);
      sinSrc->Update();

      ptObj->lock();
      ptObj->copyNewImageData(sinSrc->GetOutput());
      ptObj->translateData(200, 20, 2);
      ptObj->getTransform()->RotateX(25); // Rotate around X 25 degrees
      ptObj->Modified();
      ptObj->unlock();

      sinSrc->Delete();
    }
  }

  if (m_2DPlane >= 0) {
    rt2DSliceDataObject* ptObj = static_cast<rt2DSliceDataObject*>(rtBaseHandle::instance().getObjectWithID(m_2DPlane));
    if (!ptObj) {
      emit sendOutput("Could Not Get 2D Plane Object! FAIL!");
    } else {
      emit sendOutput("Load 2D Plane Data...");
      vtkImageSinusoidSource* sinSrc = vtkImageSinusoidSource::New();
      vtkImageShiftScale *shift = vtkImageShiftScale::New();

      sinSrc->SetWholeExtent(0,255, 0, 255, 0, 0);
      sinSrc->SetDirection(1, 2, 3);
      sinSrc->SetPeriod(30);
      sinSrc->SetPhase(1);
      sinSrc->SetAmplitude(10);
      sinSrc->Update();
      
      shift->SetInput(sinSrc->GetOutput());
      shift->SetOutputScalarType(VTK_UNSIGNED_CHAR);
      shift->SetShift(20);
      shift->Update();

      ptObj->lock();
      ptObj->getTransform()->Translate(20, 200, 2);
      ptObj->getTransform()->RotateX(25);
      ptObj->getTransform()->RotateY(25);
      ptObj->getTransform()->RotateZ(25);
      ptObj->copyImageData2D(shift->GetOutput());
      ptObj->Modified();
      ptObj->unlock();

      sinSrc->Delete();
    }
  }
  
  if (m_2DPlaneColor >= 0) {
    rt2DSliceDataObject* ptObj = static_cast<rt2DSliceDataObject*>(rtBaseHandle::instance().getObjectWithID(m_2DPlaneColor));
    if (!ptObj) {
      emit sendOutput("Could Not Get 2D Color Plane Object! FAIL!");
    } else {
      emit sendOutput("Load 2D Color Plane Data...");

      vtkImageSinusoidSource* sinSrc = vtkImageSinusoidSource::New();

      vtkPNGReader *pngReader = vtkPNGReader::New();
      pngReader->SetFileName( m_pngFileName.toStdString().c_str() );
      pngReader->SetNumberOfScalarComponents(3);
      pngReader->SetDataScalarType(VTK_UNSIGNED_CHAR);
      pngReader->Update();

      ptObj->lock();
      ptObj->getTransform()->Translate(100, 300, 2);
      ptObj->getTransform()->RotateX(25);
      ptObj->getTransform()->RotateY(25);
      ptObj->getTransform()->RotateZ(25);
      ptObj->copyImageData2D(pngReader->GetOutput());
      ptObj->Modified();
      ptObj->unlock();

      sinSrc->Delete(); 
    }
  }

  if (m_2DPlane16 >= 0) {
    rt2DSliceDataObject* ptObj = static_cast<rt2DSliceDataObject*>(rtBaseHandle::instance().getObjectWithID(m_2DPlane16));
    if (!ptObj) {
      emit sendOutput("Could Not Get 2D 16-bit Plane Object! FAIL!");
    } else {
      emit sendOutput("Load 2D 16-bit Plane Data...");

      vtkDICOMImageReader *dcmReader = vtkDICOMImageReader::New();
      dcmReader->SetFileName( m_dicomFileName.toStdString().c_str() );
      dcmReader->SetNumberOfScalarComponents(1);
      dcmReader->SetDataScalarType(VTK_UNSIGNED_SHORT);
      dcmReader->Update();

      ptObj->lock();
      ptObj->getTransform()->Translate(100, 300, 2);
      ptObj->getTransform()->RotateX(25);
      ptObj->getTransform()->RotateY(25);
      ptObj->getTransform()->RotateZ(25);
      ptObj->copyImageData2D(dcmReader->GetOutput());
      ptObj->Modified();
      ptObj->unlock();
    }
  }
  

  if (m_matrix >= 0) {
    rtMatrixDataObject* ptObj = static_cast<rtMatrixDataObject*>(rtBaseHandle::instance().getObjectWithID(m_matrix));
    if (!ptObj) {
      emit sendOutput("Could Not Get Matrix Object! FAIL!");
    } else {
      emit sendOutput("Load Matrix Orientation...");

      ptObj->lock();
      ptObj->getTransform()->RotateX(25);
      ptObj->getTransform()->RotateY(25);
      ptObj->getTransform()->RotateZ(25);
      ptObj->Modified();
      ptObj->unlock();

    }
  }

  if (m_polyObj>=0) {
    rtPolyDataObject* ptObj = static_cast<rtPolyDataObject*>(rtBaseHandle::instance().getObjectWithID(m_polyObj));
    if (!ptObj) {
      emit sendOutput("Could Not Get Poly Object! FAIL!");
    } else {
      emit sendOutput("Load Poly Object Surfaces...");
      rtBasic3DPointData tempPt;
      rtPolyDataObject::PolyPointLink tempLink;
      QList<rtBasic3DPointData> ptList;
      QList<rtPolyDataObject::PolyPointLink> linkList;

      tempPt.setX(0.0);
      tempPt.setY(0.0);
      tempPt.setZ(0.0);
      tempPt.setColor(1.0, 0.0, 0.0);
      ptList.push_back(tempPt);

      tempPt.setX(10.0);
      tempPt.setY(0.0);
      tempPt.setZ(0.0);
      tempPt.setColor(0.0, 1.0, 0.0);
      ptList.push_back(tempPt);

      tempPt.setX(0.0);
      tempPt.setY(10.0);
      tempPt.setZ(0.0);
      tempPt.setColor(0.0, 0.0, 1.0);
      ptList.push_back(tempPt);

      tempPt.setX(15.0);
      tempPt.setY(15.0);
      tempPt.setZ(-10.0);
      tempPt.setColor(1.0, 0.0, 0.0);
      ptList.push_back(tempPt);

      tempPt.setX(0.0);
      tempPt.setY(0.0);
      tempPt.setZ(-10.0);
      tempPt.setColor(0.5, 0.5, 0.5);
      ptList.push_back(tempPt);

      tempLink.threeVertex[0] = 0;
      tempLink.threeVertex[1] = 1;
      tempLink.threeVertex[2] = 2;
      linkList.push_back(tempLink);

      tempLink.threeVertex[0] = 3;
      tempLink.threeVertex[1] = 1;
      tempLink.threeVertex[2] = 2;
      linkList.push_back(tempLink);

      tempLink.threeVertex[0] = 1;
      tempLink.threeVertex[1] = 0;
      tempLink.threeVertex[2] = 4;
      linkList.push_back(tempLink);

      tempLink.threeVertex[0] = 2;
      tempLink.threeVertex[1] = 0;
      tempLink.threeVertex[2] = 4;
      linkList.push_back(tempLink);

      ptObj->lock();
      emit sendOutput("Load Poly Object Geometry...");
      ptObj->setNewGeometry(&ptList, &linkList);
      emit sendOutput("Done Loading Poly Object Geometry...");
      ptObj->Modified();
      ptObj->unlock();
    }
  }


  if (m_ctf>=0) {
    rtColorFuncDataObject* ptObj = static_cast<rtColorFuncDataObject*>(rtBaseHandle::instance().getObjectWithID(m_ctf));
    if (!ptObj) {
      emit sendOutput("Could Not Get Color Transfer Function! FAIL!");
    } else {
      emit sendOutput("Load Color Function Points...");
      vtkColorTransferFunction* temp = vtkColorTransferFunction::New();
      temp->SetColorSpaceToRGB();
      temp->RemoveAllPoints();
      temp->AddRGBPoint(0.0, 0.0, 0.0, 0.0);
      temp->AddRGBPoint(255.0, 1.0, 1.0, 1.0);

      // Send the color function to the object.
      ptObj->lock();
      ptObj->setColorFunction(temp);
      ptObj->Modified();
      ptObj->unlock();

      temp->Delete();
    }
  }

  if (m_ctfGreen>=0) {
    rtColorFuncDataObject* ptObj = static_cast<rtColorFuncDataObject*>(rtBaseHandle::instance().getObjectWithID(m_ctfGreen));
    if (!ptObj) {
      emit sendOutput("Could Not Get Color Transfer Function! FAIL!");
    } else {
      emit sendOutput("Load Color Function Points...");
      vtkColorTransferFunction* temp = vtkColorTransferFunction::New();
      temp->SetColorSpaceToRGB();
      temp->RemoveAllPoints();
      temp->AddRGBPoint(0.0, 0.0, 0.0, 0.0);
      temp->AddRGBPoint(255.0, 0.1, 1.0, 0.1);

      // Send the color function to the object.
      ptObj->lock();
      ptObj->setColorFunction(temp);
      ptObj->Modified();
      ptObj->unlock();

      temp->Delete();
    }
  }

  if (m_ctfTraffic >= 0)
  {
      rtColorFuncDataObject* ptObj = static_cast<rtColorFuncDataObject*>(rtBaseHandle::instance().getObjectWithID(m_ctfTraffic));
      if (!ptObj) {
        emit sendOutput("Could Not Get Color Transfer Function! FAIL!");
      } else {
        emit sendOutput("Load Color Function Points...");
        vtkColorTransferFunction* temp = vtkColorTransferFunction::New();
        temp->SetColorSpaceToRGB();
        temp->RemoveAllPoints();
        temp->AddRGBPoint(0.0,1.0,0.0,0.0,0.5,1.0);
        temp->AddRGBPoint(30.0,1.0,1.0,0.0,0.5,1.0);
        temp->AddRGBPoint(60.0,0.0,1.0,0.0,0.5,1.0);
        // Send the color function to the object.
        ptObj->lock();
        ptObj->setColorFunction(temp);
        ptObj->Modified();
        ptObj->unlock();

        temp->Delete();
      }

  if (m_piece>=0) {
    rtPieceFuncDataObject* ptObj = static_cast<rtPieceFuncDataObject*>(rtBaseHandle::instance().getObjectWithID(m_piece));
    if (!ptObj) {
      emit sendOutput("Could Not Get Color Transfer Function! FAIL!");
    } else {
      emit sendOutput("Load Color Function Points...");
      vtkPiecewiseFunction* temp = vtkPiecewiseFunction::New();
      temp->RemoveAllPoints();
      temp->AddPoint(0.0, 0.0);
      temp->AddPoint(255.0, 1.0);

      // Send the color function to the object.
      ptObj->lock();
      ptObj->setPiecewiseFunction(temp);
      ptObj->Modified();
      ptObj->unlock();

      temp->Delete();
    }
  }

  m_imgChange.start();
  // Start the event loop.
  exec();
  m_imgChange.stop();

  emit sendOutput("-------- End Basic Test ---------");
}
}
示例#29
0
文件: qthread.cpp 项目: maxxant/qt
/*!
    The starting point for the thread. After calling start(), the
    newly created thread calls this function. The default
    implementation simply calls exec().

    You can reimplement this function to facilitate advanced thread
    management. Returning from this method will end the execution of
    the thread.

    \sa start() wait()
*/
void QThread::run()
{
    (void) exec();
}
示例#30
0
int TeamManager::getExpSize(zPosI pos,DWORD sceneid)
{
  ExpSizeExec exec(pos,sceneid);
  team.execEvery(exec);
  return exec.size;
}