Example #1
0
/**
 * \brief Load a OPluginItem for the specified interface
 * This will open the resource of the OPluginItem::path() and then will query
 * if the Interface specified in the uuid is available and then will manage the
 * resource and Interface.
 *
 * @param item The OPluginItem that should be loaded
 * @param uuid The Interface to query for
 *
 * @return Either 0 in case of failure or the Plugin as QUnknownInterface*
 */
QUnknownInterface* OGenericPluginLoader::load( const OPluginItem& item, const QUuid& uuid) {
    /*
     * Check if there could be a library
     */
    QString pa = item.path();
    if ( pa.isEmpty() )
        return 0l;

    /*
     * See if we get a library
     * return if we've none
     */
    setSafeMode( pa, true );
    QLibrary *lib = Internal::OPluginLibraryHolder::self()->ref( pa );
    if ( !lib ) {
        setSafeMode();
        return 0l;
    }

    /**
     * try to load the plugin and just in case initialize the pointer to a pointer again
     */
    QUnknownInterface*  iface=0;
    if ( lib->queryInterface(  uuid,  &iface ) == QS_OK ) {
        installTranslators( item.name() );
        m_library.insert( iface, lib );
    }else
        iface = 0;

    setSafeMode();

    return iface;
}
Example #2
0
/**
 * \fn      LongInt::LongInt(int n)
 * \brief   Default constructor.
 *
 * Construct an empty object with the capacity to store "n" digits.
 * The parameter has a default value of DEFAULT_INIT_SIZE. (See LongInt.h)
 *
 */
LongInt::LongInt(int n) {
    setSafeMode();
    number = new char[n+1]; // The extra cell is needed for the EOS character.
    stock = n;
    number += stock;
    size = 1;
    sign = false;
}
StatusIndicatorMenuVerticalView::StatusIndicatorMenuVerticalView(StatusIndicatorMenu *controller) :
    MSceneWindowView(controller),
    controller(controller)
{
    // Create an extension area for the top row plugins
    MApplicationExtensionArea *extensionArea = new MApplicationExtensionArea("com.meego.core.MStatusIndicatorMenuExtensionInterface/1.0");
    connect(extensionArea, SIGNAL(extensionInstantiated(MApplicationExtensionInterface*)), controller, SLOT(setStatusIndicatorMenuInterface(MApplicationExtensionInterface*)));
    connect(extensionArea, SIGNAL(extensionInstantiated(MApplicationExtensionInterface*)), this, SLOT(setExtensionLayoutPosition(MApplicationExtensionInterface*)));
    extensionArea->setObjectName("StatusIndicatorMenuExtensionArea");
    setSafeMode(extensionArea, QFile(CRASH_FILE).exists());
    extensionArea->init();

    // Add panning to the expension area
    MPannableViewport* viewport = new MPannableViewport();
    viewport->setWidget(extensionArea);
    viewport->setVerticalPanningPolicy(MPannableWidget::PanningAsNeeded);
    viewport->setStyleName("StatusIndicatorMenuViewport");
    viewport->positionIndicator()->setStyleName("CommonPositionIndicatorInverted");

    // Put the extension area to a horizontal layout
    QGraphicsLinearLayout *vlayout = new QGraphicsLinearLayout(Qt::Vertical);
    vlayout->setContentsMargins(0, 0, 0, 0);
    vlayout->setSpacing(0);
    vlayout->addItem(viewport);

    // Add a separator line on the bottom of the menu
    MStylableWidget *bottomSeparator = new MStylableWidget;
    bottomSeparator->setStyleName("StatusIndicatorMenuBottomSeparator");
    bottomSeparator->setLayoutPosition(M::VerticalTopPosition);
    vlayout->addItem(bottomSeparator);

    // Create a container widget for extension area and settings button layout
    containerWidget = new MStylableWidget;
    containerWidget->setStyleName("StatusIndicatorMenuExtensionAreaWidget");
    containerWidget->setLayout(vlayout);

    QGraphicsLinearLayout *hlayout = new QGraphicsLinearLayout(Qt::Horizontal);
    hlayout->setContentsMargins(0, 0, 0, 0);
    hlayout->setSpacing(0);
    hlayout->addStretch();
    hlayout->addItem(containerWidget);
    hlayout->addStretch();

    // Add a separator line on the right of the menu
    MStylableWidget *rightSeparator = new MStylableWidget;
    rightSeparator->setStyleName("StatusIndicatorMenuRightSeparator");
    rightSeparator->setLayoutPosition(M::HorizontalLeftPosition);
    hlayout->addItem(rightSeparator);

    controller->setLayout(hlayout);
    containerWidget->installEventFilter(this);
}
Example #4
0
void startSlam(int v)
{
	FileStorage fs("config.yml", FileStorage::READ);
	Mat cam, dist, rpos, q, s;

	fs["cameraMatrix"] >> cam;
	fs["distMatrix"] >> dist;
	fs["sensorPos"] >> rpos;
	fs["q"] >> q;
	fs["s"] >> s;

	fs.release();

	ml = new MarkerLocator(cam, dist, rpos, 100.);

//	Mat q = (Mat_<double>(2,1) << .01, .1*M_PI/180);
//	Mat s = (Mat_<double>(2,1) << 10, .5*M_PI/180);

	slam = new EkfSlam(&scan, q, s);
	#ifdef GUI
	namedWindow("EKFSlam");
	disp = new MapDisplay("Map");
	waitKey();
	#endif

	Mat u = (Mat_<double>(2,1) << 0, 0);

	int fd = openPort();
	oiStart();
	setSafeMode();
	readDist();
	readAngle();

	VideoCapture cap(0);
	if(!cap.isOpened()) {
		printf("Failed capture\n");
		return;
	}

	VideoWriter record("/tmp/demo.avi", CV_FOURCC('D','I','V','X'), 30, Size(1340,600), true);
	if(!record.isOpened()) {
		printf("Failed writer\n");
		return;
	}

	clock_t t;
	time_t stime;
	while(1) {
		t = clock();
		setDrive(v,v);
		double mindist = 99999;

		while(msElap(t) < 100 && !hitWall()) {
			u.at<double>(0) = (double)readDist();
			u.at<double>(1) = M_PI*(double)readAngle()/180;
			mindist = slamStep(u, cap, record);
		}

		// backup before turn when running into something
		if(hitWall() || mindist < 700) {
			if(hitWall()) {
				// backup
				setDrive(-15,-15);
				t = clock();
				while(msElap(t) < 500) {
					u.at<double>(0) = (double)readDist();
					u.at<double>(1) = M_PI*(double)readAngle()/180;
					slamStep(u, cap, record);
				}
			}

			// turn
			if(time(&stime)%60 < 30) {
				setDrive(-5, 5);
			}
			else
				setDrive(5,-5);

			t = clock();
			while(msElap(t) < 250) {
				u.at<double>(0) = 0;
				u.at<double>(1) = M_PI*(double)readAngle()/180;
				slamStep(u, cap, record);
			}
		}
		if(waitKey(10) == 27)
			break;
	}

	setDrive(0,0);
	imwrite("lastFrame.png", g_outFrame);

	close(fd);

	delete ml;
	delete slam;
	#ifdef GUI
	delete disp;
	#endif
}