Example #1
0
void *MainWindow::processEvent(Event *e)
{
    CommandDef *cmd;
    WindowDef  *wnd;
    switch(e->type()){
    case EventSetMainIcon:
        m_icon = (const char*)(e->param());
        setIcon(Pict(m_icon.c_str()));
        break;
    case EventInit:{
            setTitle();
            BarShow b;
            b.bar_id = ToolBarMain;
            b.parent = this;
            Event e(EventShowBar, &b);
            bar = (QToolBar*)e.process();
            restoreToolbar(bar, CorePlugin::m_plugin->data.toolBarState);
            raiseWindow(this);
            break;
        }
    case EventCommandExec:
        cmd = (CommandDef*)(e->param());
        if (cmd->id == CmdQuit)
            quit();
        break;
    case EventAddWindow:
        wnd = (WindowDef*)(e->param());
        addWidget(wnd->widget, wnd->bDown);
        return e->param();
    case EventAddStatus:
        wnd = (WindowDef*)(e->param());
        addStatus(wnd->widget, wnd->bDown);
        return e->param();
    case EventIconChanged:
        setIcon(Pict(m_icon.c_str()));
        break;
    case EventContactChanged:{
            Contact *contact = (Contact*)(e->param());
            if (contact == getContacts()->owner())
                setTitle();
            break;
        }
    }
    return NULL;
}
Example #2
0
void xsCanvasContext::save()
{
	xsCanvasAttribute* newStatus = (xsCanvasAttribute*)xsCalloc(sizeof(xsCanvasAttribute));
	newStatus ->fillColor = fillColor;
	newStatus ->strokeColor = strokeColor;
//	newStatus ->shadowColor = shadowColor;
//	newStatus ->shadowBlur = shadowBlur;
//	newStatus ->shadowOffsetX = shadowOffsetX;
//	newStatus ->shadowOffsetY = shadowOffsetY;
	newStatus ->lineWidth = lineWidth;
//	newStatus ->globalCompositeOperation = globalCompositeOperation;
//	newStatus ->globalAlpha = globalAlpha;
	newStatus ->font = font;
	newStatus ->textAlign = textAlign;
	newStatus ->textBaseline = textBaseline;

	addStatus(newStatus);

}
ICQStatusEditor::ICQStatusEditor( ICQStatusManager *statusManager, QWidget *parent )
: KDialog( parent ), mStatusManager( statusManager )
{
	setCaption( i18n( "Xtraz Status Editor" ) );
	setButtons( KDialog::Ok | KDialog::Cancel );

	mUi = new Ui::XtrazICQStatusEditorUI();
	QWidget *w = new QWidget( this );
	mUi->setupUi( w );
	setMainWidget( w );

	mUi->statusView->setAlternatingRowColors( true );
	mUi->statusView->setTabKeyNavigation( false );
	mUi->statusView->setSelectionBehavior( QAbstractItemView::SelectRows );
	mUi->statusView->setSelectionMode( QAbstractItemView::SingleSelection );
	mUi->statusView->horizontalHeader()->setClickable( false );
	mUi->statusView->horizontalHeader()->setStretchLastSection( true );

	QList<QIcon> icons;
	for ( int i = 0; i < Oscar::XSTAT_LAST; ++i )
		icons << KIcon( QString( "icq_xstatus%1" ).arg( i ) );

	mUi->statusView->setItemDelegate( new StatusDelegate( icons, this ) );

	mXtrazStatusModel = new Xtraz::StatusModel( this );
	mXtrazStatusModel->setStatuses( mStatusManager->xtrazStatuses() );
	mUi->statusView->setModel( mXtrazStatusModel );
	mUi->statusView->setCurrentIndex( mXtrazStatusModel->index( 0, 0 ) );

	connect( mUi->buttonAdd, SIGNAL(clicked()), this, SLOT(addStatus()) );
	connect( mUi->buttonDelete, SIGNAL(clicked()), this, SLOT(deleteStatus()) );
	connect( mUi->buttonUp, SIGNAL(clicked()), this, SLOT(moveUp()) );
	connect( mUi->buttonDown, SIGNAL(clicked()), this, SLOT(moveDown()) );
	connect( this, SIGNAL(okClicked()), this, SLOT(save()) );
	connect( mUi->statusView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
	         this, SLOT(updateButtons()) );

	updateButtons();
	mUi->statusView->setFocus();
}
Example #4
0
StatusMenu::StatusMenu(QWidget* parent)
	: QMenu(parent), currentStatus_(XMPP::Status::Offline)
{
	addStatus(XMPP::Status::Online);
	if (PsiOptions::instance()->getOption("options.ui.menu.status.chat").toBool())
		addStatus(XMPP::Status::FFC);
	addSeparator();
	addStatus(XMPP::Status::Away);
	if (PsiOptions::instance()->getOption("options.ui.menu.status.xa").toBool())
		addStatus(XMPP::Status::XA);
	addStatus(XMPP::Status::DND);
	if (PsiOptions::instance()->getOption("options.ui.menu.status.invisible").toBool()) {
		addSeparator();
		addStatus(XMPP::Status::Invisible);
	}
#ifndef YAPSI_ACTIVEX_SERVER
	addSeparator();
	addStatus(XMPP::Status::Offline);
#endif
}
Example #5
0
    bool CmdSaslStart::run(OperationContext* txn,
                           const std::string& db,
                           BSONObj& cmdObj,
                           int options,
                           std::string& ignored,
                           BSONObjBuilder& result,
                           bool fromRepl) {

        ClientBasic* client = ClientBasic::getCurrent();
        client->resetAuthenticationSession(NULL);

        std::string mechanism;
        if (!extractMechanism(cmdObj, &mechanism).isOK()) {
            return false;
        }
        
        SaslAuthenticationSession* session = 
            SaslAuthenticationSession::create(client->getAuthorizationSession(), mechanism);
        
        boost::scoped_ptr<AuthenticationSession> sessionGuard(session);

        session->setOpCtxt(txn);

        Status status = doSaslStart(session, db, cmdObj, &result);
        addStatus(status, &result);

        if (session->isDone()) {
            audit::logAuthentication(
                    client,
                    session->getMechanism(),
                    UserName(session->getPrincipalId(), db),
                    status.code());
        }
        else {
            client->swapAuthenticationSession(sessionGuard);
        }
        return status.isOK();
    }
Example #6
0
        bool run(const string& dbname,
                 BSONObj& cmdObj,
                 int options,
                 string& errmsg,
                 BSONObjBuilder& result,
                 bool fromRepl) {

            bool anyDB = false;
            BSONElement usersFilter;
            Status status = auth::parseAndValidateInfoCommands(cmdObj,
                                                               "usersInfo",
                                                               dbname,
                                                               &anyDB,
                                                               &usersFilter);
            if (!status.isOK()) {
                addStatus(status, result);
                return false;
            }

            BSONObjBuilder queryBuilder;
            queryBuilder.appendAs(usersFilter, "name");
            if (!anyDB) {
                queryBuilder.append("source", dbname);
            }

            BSONArrayBuilder usersArrayBuilder;
            BSONArrayBuilder& (BSONArrayBuilder::* appendBSONObj) (const BSONObj&) =
                    &BSONArrayBuilder::append<BSONObj>;
            const boost::function<void(const BSONObj&)> function =
                    boost::bind(appendBSONObj, &usersArrayBuilder, _1);
            AuthorizationManager* authzManager = getGlobalAuthorizationManager();
            authzManager->queryAuthzDocument(NamespaceString("admin.system.users"),
                                             queryBuilder.done(),
                                             function);

            result.append("users", usersArrayBuilder.arr());
            return true;
        }
Example #7
0
void XDebugServer::deinitDbgp() {
  // Unless we've already stopped, send the shutdown message
  if (m_status != Status::Stopped) {
    setStatus(Status::Stopping, Reason::Ok);

    // Send the xml shutdown response
    auto response = xdebug_xml_node_init("response");
    addXmlns(*response);
    addStatus(*response);
    if (m_lastCommand != nullptr) {
      addCommand(*response, *m_lastCommand);
    }
    sendMessage(*response);
    xdebug_xml_node_dtor(response);

    // Wait for a response from the client. Regardless of the command loop
    // result, we exit.
    doCommandLoop();
  }

  // Free the input buffer & the last command
  req::free(m_buffer);
  delete m_lastCommand;
}
Example #8
0
bool HttpResponse::addHeading ()
{
	bool more = false;

	if ( getAttributes() & FILE_ATTRIBUTE_HIDDEN )
	{
		// never show hidden files
		addError( idHttpForbidden );
	}
	else if ( getAttributes() & FILE_ATTRIBUTE_DIRECTORY )
	{
		if ( _server->getAllowListing() )
		{
			// create a directory listing
			addStatus( idHttpOk );
			addString( CRLF );
			more = true;
		}
		else
			addError( idHttpForbidden );
	}
	else
	{
		LPCTSTR fileName = getFullPath().c_str();

		if ( _file.openFastRead(getFullPath()) )
		{
			if ( getStatus() != REQ_SIMPLE )
			{
				TimeStamp timeIfMod;

				string strIfMod = getHeaderValue( idParamIfModifiedSince );

				if ( strIfMod.size() > 0 &&
					HttpUtil::fromHttpTime( strIfMod, timeIfMod ) &&
					!HttpUtil::ifModSince( _file, timeIfMod ) )
				{
					// eh, it hasn't been modified
					addStatus( idHttpNotModified );

					// don't need it anymore
					_file.close();
				}
				else
				{
					// send it off
					addStatus( idHttpOk );

					// set content type and length
					long contentLength = _file.size();

					addContentType();
					addHeader( idParamContentLength, contentLength );

					// get the last modified time
					FILETIME ft;
					if ( GetFileTime( _file, NULL, NULL, &ft ) )
					{
						string strTime = HttpUtil::getHttpDate( &ft );
						addHeader( idParamLastModified, strTime );
					}

					more = true;
				}

				// blank line
				addString( CRLF );
			}
			else
			{
				more = true;
			}
		}
		else
		{
			// couldn't open; try again later
			addError( idHttpUnavailable );
		}
	}
	return more;
}
        // TODO: The bulk of the implementation of this will need to change once we're using the
        // new v2 authorization storage format.
        bool run(const string& dbname,
                 BSONObj& cmdObj,
                 int options,
                 string& errmsg,
                 BSONObjBuilder& result,
                 bool fromRepl) {
            std::string userName;
            std::string password;
            std::string userSource; // TODO: remove this.
            bool readOnly; // TODO: remove this.
            BSONElement extraData;
            BSONElement roles;

            if (cmdObj.hasField("pwd") && cmdObj.hasField("userSource")) {
                errmsg = "User objects can't have both 'pwd' and 'userSource'";
                return false;
            }

            if (!cmdObj.hasField("pwd") && !cmdObj.hasField("userSource")) {
                errmsg = "User objects must have one of 'pwd' and 'userSource'";
                return false;
            }

            if (cmdObj.hasField("roles") && cmdObj.hasField("readOnly")) {
                errmsg = "User objects can't have both 'roles' and 'readOnly'";
                return false;
            }

            Status status = bsonExtractStringField(cmdObj, "user", &userName);
            if (!status.isOK()) {
                addStatus(Status(ErrorCodes::UserModificationFailed,
                                 "\"user\" string not specified"),
                          result);
                return false;
            }

            status = bsonExtractStringFieldWithDefault(cmdObj, "pwd", "", &password);
            if (!status.isOK()) {
                addStatus(Status(ErrorCodes::UserModificationFailed,
                                 "Invalid \"pwd\" string"),
                          result);
                return false;
            }

            status = bsonExtractStringFieldWithDefault(cmdObj, "userSource", "", &userSource);
            if (!status.isOK()) {
                addStatus(Status(ErrorCodes::UserModificationFailed,
                                 "Invalid \"userSource\" string"),
                          result);
                return false;
            }

            status = bsonExtractBooleanFieldWithDefault(cmdObj, "readOnly", false, &readOnly);
            if (!status.isOK()) {
                addStatus(Status(ErrorCodes::UserModificationFailed,
                                 "Invalid \"readOnly\" boolean"),
                          result);
                return false;
            }

            if (cmdObj.hasField("extraData")) {
                status = bsonExtractField(cmdObj, "extraData", &extraData);
                if (!status.isOK()) {
                    addStatus(Status(ErrorCodes::UserModificationFailed,
                                     "Invalid \"extraData\" object"),
                              result);
                    return false;
                }
            }

            if (cmdObj.hasField("roles")) {
                status = bsonExtractField(cmdObj, "roles", &roles);
                if (!status.isOK()) {
                    addStatus(Status(ErrorCodes::UserModificationFailed,
                                     "Invalid \"roles\" array"),
                              result);
                    return false;
                }
            }

            BSONObjBuilder userObjBuilder;
            userObjBuilder.append("user", userName);
            if (cmdObj.hasField("pwd")) {
                // TODO: hash password once we're receiving plaintext passwords here.
                userObjBuilder.append("pwd", password);
            }

            if (cmdObj.hasField("userSource")) {
                userObjBuilder.append("userSource", userSource);
            }

            if (cmdObj.hasField("readOnly")) {
                userObjBuilder.append("readOnly", readOnly);
            }

            if (cmdObj.hasField("extraData")) {
                userObjBuilder.append("extraData", extraData);
            }

            if (cmdObj.hasField("roles")) {
                userObjBuilder.append(roles);
            }

            status = getGlobalAuthorizationManager()->insertPrivilegeDocument(dbname,
                                                                              userObjBuilder.obj());
            if (!status.isOK()) {
                addStatus(status, result);
                return false;
            }

            return true;
        }
Example #10
0
        bool run(const string& dbname,
                 BSONObj& cmdObj,
                 int options,
                 string& errmsg,
                 BSONObjBuilder& result,
                 bool fromRepl) {
            AuthorizationManager* authzManager = getGlobalAuthorizationManager();
            AuthzDocumentsUpdateGuard updateGuard(authzManager);
            if (!updateGuard.tryLock("Grant privileges to role")) {
                addStatus(Status(ErrorCodes::LockBusy, "Could not lock auth data update lock."),
                          result);
                return false;
            }

            RoleName roleName;
            PrivilegeVector privilegesToAdd;
            BSONObj writeConcern;
            Status status = auth::parseAndValidateRolePrivilegeManipulationCommands(
                    cmdObj,
                    "grantPrivilegesToRole",
                    dbname,
                    &roleName,
                    &privilegesToAdd,
                    &writeConcern);
            if (!status.isOK()) {
                addStatus(status, result);
                return false;
            }

            if (!authzManager->roleExists(roleName)) {
                addStatus(Status(ErrorCodes::RoleNotFound,
                                 mongoutils::str::stream() << roleName.getFullName() <<
                                         " does not name an existing role"),
                          result);
                return false;
            }

            if (authzManager->isBuiltinRole(roleName)) {
                addStatus(Status(ErrorCodes::InvalidRoleModification,
                                 mongoutils::str::stream() << roleName.getFullName() <<
                                         " is a built-in role and cannot be modified."),
                          result);
                return false;
            }

            PrivilegeVector privileges = authzManager->getDirectPrivilegesForRole(roleName);
            for (PrivilegeVector::iterator it = privilegesToAdd.begin();
                    it != privilegesToAdd.end(); ++it) {
                Privilege::addPrivilegeToPrivilegeVector(&privileges, *it);
            }

            // Build up update modifier object to $set privileges.
            mutablebson::Document updateObj;
            mutablebson::Element setElement = updateObj.makeElementObject("$set");
            status = updateObj.root().pushBack(setElement);
            if (!status.isOK()) {
                addStatus(status, result);
                return false;
            }
            mutablebson::Element privilegesElement = updateObj.makeElementArray("privileges");
            status = setElement.pushBack(privilegesElement);
            if (!status.isOK()) {
                addStatus(status, result);
                return false;
            }
            status = authzManager->getBSONForPrivileges(privileges, privilegesElement);
            if (!status.isOK()) {
                addStatus(status, result);
                return false;
            }

            BSONObjBuilder updateBSONBuilder;
            updateObj.writeTo(&updateBSONBuilder);
            status = authzManager->updateRoleDocument(
                    roleName,
                    updateBSONBuilder.done(),
                    writeConcern);
            if (!status.isOK()) {
                addStatus(status, result);
                return false;
            }

            return true;
        }
Example #11
0
        bool run(const string& dbname,
                 BSONObj& cmdObj,
                 int options,
                 string& errmsg,
                 BSONObjBuilder& result,
                 bool fromRepl) {
            AuthorizationManager* authzManager = getGlobalAuthorizationManager();
            AuthzDocumentsUpdateGuard updateGuard(authzManager);
            if (!updateGuard.tryLock("Revoke role delegation from user")) {
                addStatus(Status(ErrorCodes::LockBusy, "Could not lock auth data update lock."),
                          result);
                return false;
            }

            UserName userName;
            std::vector<RoleName> roles;
            BSONObj writeConcern;
            Status status = auth::parseUserRoleManipulationCommand(cmdObj,
                                                                   "revokeDelegateRolesFromUser",
                                                                   dbname,
                                                                   authzManager,
                                                                   &userName,
                                                                   &roles,
                                                                   &writeConcern);
            if (!status.isOK()) {
                addStatus(status, result);
                return false;
            }

            User::RoleDataMap userRoles;
            status = getCurrentUserRoles(authzManager, userName, &userRoles);
            if (!status.isOK()) {
                addStatus(status, result);
                return false;
            }

            for (vector<RoleName>::iterator it = roles.begin(); it != roles.end(); ++it) {
                RoleName& roleName = *it;
                User::RoleDataMap::iterator roleDataIt = userRoles.find(roleName);
                if (roleDataIt == userRoles.end()) {
                    continue; // User already doesn't have the role, nothing to do
                }
                User::RoleData& role = roleDataIt->second;
                if (role.hasRole) {
                    // If the user still has the role, need to leave it in the roles array
                    role.canDelegate = false;
                } else {
                    // If the user doesn't have the role, and now can't delegate it either, remove
                    // the role from that user's roles array entirely
                    userRoles.erase(roleDataIt);
                }
            }

            BSONArray newRolesBSONArray = rolesToBSONArray(userRoles);
            status = authzManager->updatePrivilegeDocument(
                    userName, BSON("$set" << BSON("roles" << newRolesBSONArray)), writeConcern);
            // Must invalidate even on bad status - what if the write succeeded but the GLE failed?
            authzManager->invalidateUserByName(userName);
            if (!status.isOK()) {
                addStatus(status, result);
                return false;
            }

            return true;
        }
Example #12
0
void Animal::doAction(int action, bool isOrder)
{
//    if( isOrder && motionQueue.front()->isOrder == false )
//        pBody->stopAllActions();
    cancelAllMotions(0);
    
    switch (action) {
        case ACTION_BASIC_COME:
            break;
        case ACTION_BASIC_CURE:
            cancelAllMotions(ACTION_BASIC_CURE);
            setStatus(STATUS_FULLNESS, 80);
            setStatus(STATUS_HEALTH, 70);
            setStatus(STATUS_JOY, 95);
            addStatus(STATUS_EXP, 10);
            break;
        case ACTION_BASIC_EAT:
            addMotion(EAT, 3, isOrder);
            addStatus(STATUS_FULLNESS, 20);
            addStatus(STATUS_POOP, 30);
            addStatus(STATUS_EXP, 10);
            break;
        case ACTION_BASIC_REST:
            addMotion(SIT, 3, isOrder);
            addStatus(STATUS_JOY, 10);
            addStatus(STATUS_HEALTH, 10);
            addStatus(STATUS_EXP, 10);
            break;
        case ACTION_BASIC_RUN:
            addMotion(RUN_LEFT, 3, isOrder);
            addStatus(STATUS_SLEEP, 10);
            addStatus(STATUS_HEALTH, 10);
            addStatus(STATUS_EXP, 10);
            break;
        case ACTION_BASIC_SLEEP:
            addMotion(SLEEP, 100, isOrder);
            addStatus(STATUS_HEALTH, 10);
            addStatus(STATUS_FULLNESS, -20);
            addStatus(STATUS_EXP, 10);
            break;
        case ACTION_BASIC_STOP:
            cancelAllMotions(true);
            addStatus(STATUS_EXP, 20);
            break;
        case ACTION_BASIC_WAKE:
            cancelAllMotions(true);
            addStatus(STATUS_EXP, 20);
            addStatus(STATUS_SLEEP, 60);
            break;
        case ACTION_BASIC_POOP:
            addMotion(POOP, 3, isOrder);
            addStatus(STATUS_EXP, 20);
            setStatus(STATUS_POOP, 0);
            break;
        case ACTION_TRAINING_CLEANPOOP:
            break;
        case ACTION_TRAINING_ROPE:
            addMotion(FUN_ROPE, 10, isOrder);
            addStatus(STATUS_JOY, 50);
            addStatus(STATUS_HEALTH, 30);
            addStatus(STATUS_FULLNESS, -20);
            addStatus(STATUS_EXP, 20);
            break;
        case ACTION_TRAINING_RUNNING:
            addMotion(FUN_RUNNING, 10, isOrder);
            addStatus(STATUS_JOY, 50);
            addStatus(STATUS_HEALTH, 30);
            addStatus(STATUS_FULLNESS, -20);
            addStatus(STATUS_EXP, 20);
            break;
        case ACTION_PLAYING_PLAY:
            switch (rand()%3) {
                case 0:
                    addMotion(FUN_ROPE, 10, isOrder);
                    break;
                case 1:
                    addMotion(FUN_SWING, 10, isOrder);
                    break;
                case 2:
                    addMotion(FUN_RUNNING, 10, isOrder);
                    break;
            }
            addStatus(STATUS_JOY, 50);
            addStatus(STATUS_HEALTH, 30);
            addStatus(STATUS_FULLNESS, -20);
            addStatus(STATUS_EXP, 20);
            break;
        case ACTION_PLAYING_SWING:
            addMotion(FUN_SWING, 10, isOrder);
            addStatus(STATUS_JOY, 50);
            addStatus(STATUS_HEALTH, 30);
            addStatus(STATUS_FULLNESS, -20);
            addStatus(STATUS_EXP, 20);
            break;
        case ACTION_EXTRA_DIE:
           break;
        default:
            CCLog("Animal::doAction : wrong action input");
            break;
    }
}
	void PointCloudProcessor::_doEuclideanClusterExtraction(const QList<pcl::PointCloud<PointType>::Ptr> & clouds)
	{
		QList<pcl::PointCloud<PointType>::Ptr> clusteredClouds;
		foreach (pcl::PointCloud<PointType>::Ptr cloud, clouds)
		{
			// Create the filtering object: downsample the dataset using a leaf size of 10cm
			pcl::PointCloud<PointType>::Ptr cloudFiltered (new pcl::PointCloud<PointType> ());
			pcl::VoxelGrid<PointType> vg;
			vg.setInputCloud (cloud);
			vg.setLeafSize (0.1f, 0.1f, 0.1f);
			vg.filter (*cloudFiltered);
			int nr_points = static_cast<int>(cloudFiltered->points.size());
			addStatus(QStringLiteral("PointCloud after filtering has: ") + QString::number(nr_points) + QStringLiteral(" data points."));

			// Create the segmentation object for the planar model and set all the parameters
			pcl::SACSegmentation<PointType> seg;
			pcl::PointIndices::Ptr inliers (new pcl::PointIndices);
			pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients);
			pcl::PointCloud<PointType>::Ptr cloud_plane (new pcl::PointCloud<PointType> ());
			seg.setOptimizeCoefficients (true);
			seg.setModelType (pcl::SACMODEL_PLANE);
			seg.setMethodType (pcl::SAC_RANSAC);
			seg.setMaxIterations (100);
			seg.setDistanceThreshold (0.02);

			pcl::PointCloud<PointType>::Ptr cloud_f (new pcl::PointCloud<PointType>);
			while (cloudFiltered->points.size () > 0.3 * nr_points)
			{
				// Segment the largest planar component from the remaining cloud
				seg.setInputCloud (cloudFiltered);
				seg.segment (*inliers, *coefficients);
				if (inliers->indices.size () == 0)
				{
					addStatus(QStringLiteral("Could not estimate a planar model for the given dataset."));
					break;
				}

				// Extract the planar inliers from the input cloud
				pcl::ExtractIndices<PointType> extract;
				extract.setInputCloud (cloudFiltered);
				extract.setIndices (inliers);
				extract.setNegative (false);

				// Get the points associated with the planar surface
				extract.filter (*cloud_plane);
				addStatus(QStringLiteral("PointCloud representing the planar component: ") + QString::number(cloud_plane->points.size()) + QStringLiteral(" data points."));

				// Remove the planar inliers, extract the rest
				extract.setNegative (true);
				extract.filter (*cloud_f);
				*cloudFiltered = *cloud_f;
			}

			// Creating the KdTree object for the search method of the extraction
			pcl::search::KdTree<PointType>::Ptr tree (new pcl::search::KdTree<PointType>);
			tree->setInputCloud (cloudFiltered);

			std::vector<pcl::PointIndices> cluster_indices;
			pcl::EuclideanClusterExtraction<PointType> ec;
			ec.setClusterTolerance (0.2); // 20cm
			ec.setMinClusterSize (100);
			ec.setMaxClusterSize (250000);
			ec.setSearchMethod (tree);
			ec.setInputCloud (cloudFiltered);
			ec.extract (cluster_indices);

			for (auto it = cluster_indices.begin (); it != cluster_indices.end (); ++it)
			{
				pcl::PointCloud<PointType>::Ptr cloud_cluster (new pcl::PointCloud<PointType>);
				for (auto pit = it->indices.begin (); pit != it->indices.end (); pit++)
				{
					cloud_cluster->points.push_back (cloudFiltered->points[*pit]); //*
				}
				cloud_cluster->width = cloud_cluster->points.size ();
				cloud_cluster->height = 1;
				cloud_cluster->is_dense = true;

				clusteredClouds.push_back(cloud_cluster);
			}
		}
Example #14
0
void PsiBlob::die(){
	MessageHandler::Instance()->createMessage(2,this,BlobGame::instance(),this,100);
	addStatus(Dead);
	//play death animation
}
Example #15
0
  //Called when a new command is sent to me
void FuseTracker::gotCommand( FuseCppInterface::NotableAction action, 
                              QString path )
{
  int rm;
  int add;
  QString my_path;
  bool avoid_update = false;

    //If the path is doubling up on the dupfs sync, then kill one
  path = path.replace( RegEx_Dup, "");
  my_path = QString("%1%2").arg( Mounted).arg( path).replace( RegEx_Special, "\\\\\\1");

    //handle an actino
  switch ( action )
  {
      //Delete
    case FuseCppInterface::UNLINK:
    case FuseCppInterface::RMDIR:
      addStatus( ADDING_ITEMS );

        //Run the svn command
      rm = runCmd( QString("/usr/bin/svn remove %1").arg(my_path) );

        //Add this new item
      if ( rm != 0 )
        Updated_Items.remove(my_path);
      break;

      //Add new files
    case FuseCppInterface::SYMLINK:
    case FuseCppInterface::HARDLINK:

    case FuseCppInterface::MKNOD:
    case FuseCppInterface::MKDIR:
    case FuseCppInterface::CREATE:
    case FuseCppInterface::OPEN:
      addStatus( ADDING_ITEMS );

        //Run the svn command
      add = runCmd( QString("/usr/bin/svn add %1").arg(my_path) );

        //Add this new item
      if ( add == 0 )
        Updated_Items[my_path] = OrmLight();
      break;

      //These operations mean we need to update our data at some point
    case FuseCppInterface::CHMOD:
    case FuseCppInterface::CHOWN:
    case FuseCppInterface::TRUNCATE:
    case FuseCppInterface::FTRUNCATE:
    case FuseCppInterface::UTIMES:
    case FuseCppInterface::WRITE:
    case FuseCppInterface::FLUSH:
    case FuseCppInterface::CLOSE:
    case FuseCppInterface::FSYNC:
    case FuseCppInterface::SETXATTR:
    case FuseCppInterface::REMOVEXATTR:
        //Add this new item for update
      Updated_Items[my_path] = OrmLight();
      break;

      //Handle an svn update
    case FuseCppInterface::SVN_COMMIT:
      //qDebug("Running svn commit");
        //Don't allow this action to cause a new commit
      avoid_update = true;

      removeStatus( SYNC_PUSH_REQUIRED );
      addStatus( SYNC_PUSH );

        //If there aren't any updated items, quit out now
      if ( Updated_Items.count() <= 0 )
        return;

        //handle our sync mode
      if ( Op_Mode == OP_SYNC_MODE )
      {
        updateRev();

          //Conduct an update before we commit to avoid conflicts
        QStringList list = updateFiles();
        if ( list.size() > 0 )
          runCmd( QString("/usr/bin/svn update --force --non-interactive --accept mine-full %1").arg(list.join(" ")));

          //Make a list of all the files to be updated
        QString files = QStringList( Updated_Items.keys() ).join(" ");

          //Make it happen
        runCmd( QString("/usr/bin/svn ci -m \\\"Updated %1 Items\\\" --non-interactive --depth immediates %2").arg( Updated_Items.count() ).arg( files ) );

          //Clear out all the now updated items
        QFile::remove( QString("%1/.dupfs_action_log").
                              arg((*Config)["svn_dir"]));
        Updated_Items.clear();
      }
            //Store a local file of the changes to be made at a later time
      else if ( Op_Mode == OP_OFFLINE_MODE )
      {
          //save my list of files requiring a change to the FS
        QString filename = QString("%1/.dupfs_action_log").
                                arg((*Config)["svn_dir"]);
        Updated_Items.saveToFile( filename );
      }

        //Remove my push stats
      removeStatus( SYNC_PUSH );
      break;

      //Check if its a special command
    case FuseCppInterface::SVN_UPDATE:
      //qDebug("Running svn update");
        //Don't allow this action to cause a new commit
      avoid_update = true;

        //Only do this if we aren't offline
      if ( Op_Mode != OP_OFFLINE_MODE )
      {
        removeStatus( SYNC_PULL_REQUIRED );
        addStatus( SYNC_PULL );

          //Issue my update command
        QStringList list = updateFiles();
        runCmd( QString("/usr/bin/svn update --force --non-interactive --accept mine-full %1").arg(list.join(" ")));

        removeStatus( SYNC_PULL );
      }
      break;


      //not sure, just ignore
    case FuseCppInterface::RENAME:
    default:
      return;
      break;
  };

    //If we got here, we know we got a valid command
    //If timer isn't started, start it and then quit out
  if ( !avoid_update && !Timer_Commit_Started )
  {
    addStatus( SYNC_PUSH_REQUIRED );
    Timer_Count = 0;
    Timer_Commit_Started = true;
  }
}
Example #16
0
bool Character::update(const Ogre::FrameEvent& evt)
{

	if(mState == ST_DEAD) // если мертвый, оставляем только текущую анимацию и выходим
	{ 
		mGraphicBody->update(evt); 
		return 0;
	}

	// посчитаем не спал ли статус
	if(mStatus.lockTime >0)
	{
		mStatus.lockTime -= evt.timeSinceLastFrame;
	}
	else //if (mStatus.status != STATUS_NORMAL)
	{
		addStatus(STATUS_NORMAL, "", 0);
		StatusMoveVec = Ogre::Vector3::ZERO; //перемещаеть этим вектором можно только под статусом    
	}

	// повернем лицом к противнику
	Ogre::Vector3 direction = mTargetNode->getPosition() - mNode->getPosition();
	direction.y = 0;
	Ogre::Real distance = direction.normalise();

	if(distance > 0.2)
	{
		Ogre::Vector3 src = mNode->getOrientation() * Ogre::Vector3::UNIT_X;
		src.y = 0;
	    if ((1.0f + src.dotProduct(direction)) < 0.0001f) 
	    {
	        mNode->yaw(Ogre::Degree(180));
	    }
	    else
	    {
	        Ogre::Quaternion quat = src.getRotationTo(direction);
	        mNode->rotate(quat);
	    } // else

	    mPhysicsBody->setOrientation(cvt(mNode->getOrientation()));
	}
	//------------------------------------------------------------------

	if(mState == ST_ATACK && !mPhysicsBody->isLock()) // если атака закончилась
	{
		mState = ST_NOTHING; 
	}

	if(mState != ST_WALK && mState != ST_RUN) MoveVec = Ogre::Vector3::ZERO; // занулим если не передвигаемся
	Ogre::Vector3 newPosition = mNode->getPosition() + (MoveVec + StatusMoveVec + pushVec + JumpVec)*evt.timeSinceLastFrame;
	mNode->setPosition(newPosition);
	pushVec = Ogre::Vector3::ZERO; // занулим, если вдруг возникнет персечение объектов то этот вектор опять пропишеться

	if(mPose == POSE_JUMP)  // считаем прыжек
	{
		if(newPosition.y >= 0) 
		{
			Ogre::Real newY = JumpVec.y - 10 * evt.timeSinceLastFrame;   //учтем гравитацию
			JumpVec = Ogre::Vector3(JumpVec.x, newY, JumpVec.z);    //
		}
		else   //приземление после прыжка
		{
			mPose = POSE_STAND;
			JumpVec = Ogre::Vector3::ZERO;
			mGraphicBody->a_stance(); 
			mGraphicBody->setAnimationRate(1);
			mPhysicsBody->setBaseBodiesTransforms();
			mMoveDir = MV_NULL;
			mPhysicsBody->break_atack(1);
		}
	}

	mPhysicsBody->setPosition(cvt(newPosition));

	if(mGraphicBody->isAnimationComplete()) //на всякий случай - чтобы при отсутствии анимаций стоял в стойке
	{
		mGraphicBody->a_stance(); 
		mGraphicBody->setAnimationRate(1);
	}

	mPhysicsBody->update(evt);
	mGraphicBody->update(evt);

}