Пример #1
0
int main(int argc, char **argv)
{
    PLogger logger("app");

    QGuiApplication app(argc, argv);
    app.setApplicationName("Precursors QML Client");
    app.setApplicationVersion("0.5.0-alpha1");
    app.setOrganizationDomain("skewedaspect.com");
    app.setOrganizationName("Skewed Aspect");

    logger.info("Starting " + QString("%1 v%2").arg(app.applicationName()).arg(app.applicationVersion()));

    // Setup our managers
    PSettingsManager& settings = PSettingsManager::instance();
    PChannels& networking = PChannels::instance();
    PreUtil& utils = PreUtil::instance();
    PLogManager& logMan = PLogManager::instance();
	ControlsManager& controls = ControlsManager::instance();
    Horde3DManager& horde3d = Horde3DManager::instance();
    TimestampSync& timestamp = TimestampSync::instance();
	Math3D math3d;

	// Load controls contexts
	if(!controls.loadContextDefs("resources/contexts.json"))
	{
		return -1;
	} // end if

    // Register application fonts
    QFontDatabase::addApplicationFont("resources/fonts/trajan.otf");
    QFontDatabase::addApplicationFont("resources/fonts/titillium.ttf");

    // Register custom types with QML
    qmlRegisterType<Entity>("Precursors", 1, 0, "Entity");

    qmlRegisterType<PLogger>("Precursors.Logging", 1, 0, "PLogger");

    qmlRegisterType<PChannels>("Precursors.Networking", 1, 0, "PChannels");
    qmlRegisterType<PChannelsRequest>("Precursors.Networking", 1, 0, "PChannelsRequest");

    qmlRegisterType<Horde3DItem>("Horde3D", 1, 0, "Horde3DItem");
    qmlRegisterType<Horde3DWindow>("Horde3D", 1, 0, "Horde3DWindow");

    qmlRegisterType<ControlContext>();
    qmlRegisterType<AnalogControlSlot>();
    qmlRegisterType<DigitalControlSlot>();

	qmlRegisterUncreatableType<Math3D, 1>("Precursors", 1, 0, "Math3D", "Math3D cannot be instantiated.");

    // Setup QML
    QQmlApplicationEngine engine;

    // Put our singletons on the root context
    engine.rootContext()->setContextProperty("settings", &settings);
    engine.rootContext()->setContextProperty("logMan", &logMan);
    engine.rootContext()->setContextProperty("networking", &networking);
    engine.rootContext()->setContextProperty("utils", &utils);
    engine.rootContext()->setContextProperty("controls", &controls);
    engine.rootContext()->setContextProperty("horde3d", &horde3d);
    engine.rootContext()->setContextProperty("timestamp", &timestamp);
    engine.rootContext()->setContextProperty("math3d", &math3d);

    // load our main qml file
    engine.load("resources/qml/launcher.qml");

    return app.exec();
} // end main
// Run with: image.png image.mask 15 filled.png
int main(int argc, char *argv[])
{
  // Verify arguments
  if(argc != 5)
  {
    std::cerr << "Required arguments: image.png image.mask patchHalfWidth output.png" << std::endl;
    std::cerr << "Input arguments: ";
    for(int i = 1; i < argc; ++i)
    {
      std::cerr << argv[i] << " ";
    }
    return EXIT_FAILURE;
  }

  // Parse arguments
  std::string imageFilename = argv[1];
  std::string maskFilename = argv[2];

  std::stringstream ssPatchRadius;
  ssPatchRadius << argv[3];
  unsigned int patchHalfWidth = 0;
  ssPatchRadius >> patchHalfWidth;

  std::string outputFilename = argv[4];

  // Output arguments
  std::cout << "Reading image: " << imageFilename << std::endl;
  std::cout << "Reading mask: " << maskFilename << std::endl;
  std::cout << "Patch half width: " << patchHalfWidth << std::endl;
  std::cout << "Output: " << outputFilename << std::endl;

  typedef itk::Image<itk::CovariantVector<float, 3>, 2> ImageType;
//  typedef itk::VectorImage<float, 2> ImageType;

  typedef  itk::ImageFileReader<ImageType> ImageReaderType;
  ImageReaderType::Pointer imageReader = ImageReaderType::New();
  imageReader->SetFileName(imageFilename);
  imageReader->Update();

  ImageType::Pointer image = ImageType::New();
  ITKHelpers::DeepCopy(imageReader->GetOutput(), image.GetPointer());

  Mask::Pointer mask = Mask::New();
  mask->Read(maskFilename);

//  bool compatibleMask = PatchHelpers::CheckSurroundingRegionsOfAllHolePixels(mask, patchHalfWidth);
//  if(!compatibleMask)
//  {
//    throw std::runtime_error("The mask is not compatible!");
//  }

  std::cout << "Mask size: " << mask->GetLargestPossibleRegion().GetSize() << std::endl;
  std::cout << "hole pixels: " << mask->CountHolePixels() << std::endl;
  std::cout << "valid pixels: " << mask->CountValidPixels() << std::endl;

  // Setup the GUI system
  QApplication app( argc, argv );
  // Without this, after we close the first dialog
  // (after the first iteration that is not accepted automatically), the event loop quits.
  app.setQuitOnLastWindowClosed(false);

//  InteractiveInpaintingWithVerification(imageReader->GetOutput(), mask, patchHalfWidth);
  QtConcurrent::run(boost::bind(InteractiveInpaintingWithVerification<ImageType>,
                    imageReader->GetOutput(), mask, patchHalfWidth));

  return app.exec();
}
Пример #3
0
int main(int argc, char *argv[])
{
   ossimArgumentParser argumentParser(&argc, argv);
   ossimInit::instance()->addOptions(argumentParser);
   ossimInit::instance()->initialize(argumentParser);
   argumentParser.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
   argumentParser.getApplicationUsage()->setApplicationName(argumentParser.getApplicationName());
   argumentParser.getApplicationUsage()->setDescription(argumentParser.getApplicationName()+" GUI application for the ossim core library");
   argumentParser.getApplicationUsage()->setCommandLineUsage(argumentParser.getApplicationName()+" [options]");
   argumentParser.getApplicationUsage()->addCommandLineOption("-project","OPTIONAL: project file");
   argumentParser.getApplicationUsage()->addCommandLineOption("No '-','*.gcl' file","untagged project file with 'gcl' extension");
  
   if (argumentParser.read("-h") || argumentParser.read("--help"))
   {
      argumentParser.getApplicationUsage()->write(std::cout);
      exit(0);
   }

   // project file
   std::string tempString;
   ossimArgumentParser::ossimParameter stringParam(tempString);
   ossimString projFile;
   while(argumentParser.read("-project", stringParam))
   {
      projFile = tempString;
   }

   // additional check for stand-alone ".gcl" project file
   // or list of images
   std::vector<ossimString> ilist;
   if (argc > 1)
   {
      for (int k=1; k<argc; ++k)
      {
         tempString = argv[k];
         if (tempString.find(".gcl") != std::string::npos)
         {
            projFile = tempString;
         }
         else
         {
            ilist.push_back(tempString);
         }
      }
   }


   argumentParser.reportRemainingOptionsAsUnrecognized();   
   QApplication app(argc, argv);
   QSplashScreen splash(QPixmap(":/splash/GeoCellSplash.png"));
   splash.setWindowFlags(splash.windowFlags()|Qt::WindowStaysOnTopHint);
   splash.show();
#ifdef OSSIMQT_USE_WINDOWS_STYLE
   QWindowsStyle *style = new QWindowsStyle();
   app.setStyle(style);
#endif
   ossimObjectFactoryRegistry::instance()->registerFactory(ossimGui::OssimObjectFactory::instance());
   ossimGui::MainWindow*  mainWindow = new ossimGui::MainWindow();
   
   // Load command line project file or image files if present
   if (projFile.size()>0)
   {
      mainWindow->loadProjectFile(projFile);
   }
   else if (ilist.size()>0)
   {
      mainWindow->loadImageFileList(ilist);
   }
   mainWindow->show();

   OpenThreads::Thread::microSleep((1000*1000));
   //splash.finish(mainWindow);
   splash.close();
   int result = app.exec();
   ossimInit::instance()->finalize();

   return result;
}
Пример #4
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    {
//! [0]
    QWidget *window = new QWidget;
//! [0] //! [1]
    QPushButton *button1 = new QPushButton("One");
//! [1] //! [2]
    QPushButton *button2 = new QPushButton("Two");
    QPushButton *button3 = new QPushButton("Three");
    QPushButton *button4 = new QPushButton("Four");
    QPushButton *button5 = new QPushButton("Five");
//! [2]

//! [3]
    QHBoxLayout *layout = new QHBoxLayout;
//! [3] //! [4]
    layout->addWidget(button1);
    layout->addWidget(button2);
    layout->addWidget(button3);
    layout->addWidget(button4);
    layout->addWidget(button5);

    window->setLayout(layout);
//! [4]
    window->setWindowTitle("QHBoxLayout");
//! [5]
    window->show();
//! [5]
    }
    
    {
//! [6]
    QWidget *window = new QWidget;
//! [6] //! [7]
    QPushButton *button1 = new QPushButton("One");
//! [7] //! [8]
    QPushButton *button2 = new QPushButton("Two");
    QPushButton *button3 = new QPushButton("Three");
    QPushButton *button4 = new QPushButton("Four");
    QPushButton *button5 = new QPushButton("Five");
//! [8]

//! [9]
    QVBoxLayout *layout = new QVBoxLayout;
//! [9] //! [10]
    layout->addWidget(button1);
    layout->addWidget(button2);
    layout->addWidget(button3);
    layout->addWidget(button4);
    layout->addWidget(button5);

    window->setLayout(layout);
//! [10]
    window->setWindowTitle("QVBoxLayout");
//! [11]
    window->show();
//! [11]
    }
    
    {
//! [12]
    QWidget *window = new QWidget;
//! [12] //! [13]
    QPushButton *button1 = new QPushButton("One");
//! [13] //! [14]
    QPushButton *button2 = new QPushButton("Two");
    QPushButton *button3 = new QPushButton("Three");
    QPushButton *button4 = new QPushButton("Four");
    QPushButton *button5 = new QPushButton("Five");
//! [14]

//! [15]
    QGridLayout *layout = new QGridLayout;
//! [15] //! [16]
    layout->addWidget(button1, 0, 0);
    layout->addWidget(button2, 0, 1);
    layout->addWidget(button3, 1, 0, 1, 2);
    layout->addWidget(button4, 2, 0);
    layout->addWidget(button5, 2, 1);

    window->setLayout(layout);
//! [16]
    window->setWindowTitle("QGridLayout");
//! [17]
    window->show();
//! [17]
    }

    {
//! [18]
    QWidget *window = new QWidget;
//! [18]
//! [19]
    QPushButton *button1 = new QPushButton("One");
    QLineEdit *lineEdit1 = new QLineEdit();
//! [19]
//! [20]
    QPushButton *button2 = new QPushButton("Two");
    QLineEdit *lineEdit2 = new QLineEdit();
    QPushButton *button3 = new QPushButton("Three");
    QLineEdit *lineEdit3 = new QLineEdit();
//! [20]
//! [21]
    QFormLayout *layout = new QFormLayout;
//! [21]
//! [22]
    layout->addRow(button1, lineEdit1);
    layout->addRow(button2, lineEdit2);
    layout->addRow(button3, lineEdit3);

    window->setLayout(layout);
//! [22]
    window->setWindowTitle("QFormLayout");
//! [23]
    window->show();
//! [23]    
    }

    {
//! [24]
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(formWidget);
    setLayout(layout);
//! [24]
    }
    return app.exec();
}
int main(int argc, char **argv)
{

{
QCommandLineParser parser;
//! [0]
bool verbose = parser.isSet("verbose");
//! [0]
}

{
//! [1]
QCoreApplication app(argc, argv);
QCommandLineParser parser;
QCommandLineOption verboseOption("verbose");
parser.addOption(verboseOption);
parser.process(app);
bool verbose = parser.isSet(verboseOption);
//! [1]
}

{
QCommandLineParser parser;
//! [2]
// Usage: image-editor file
//
// Arguments:
//   file                  The file to open.
parser.addPositionalArgument("file", QCoreApplication::translate("main", "The file to open."));

// Usage: web-browser [urls...]
//
// Arguments:
//   urls                URLs to open, optionally.
parser.addPositionalArgument("urls", QCoreApplication::translate("main", "URLs to open, optionally."), "[urls...]");

// Usage: cp source destination
//
// Arguments:
//   source                Source file to copy.
//   destination           Destination directory.
parser.addPositionalArgument("source", QCoreApplication::translate("main", "Source file to copy."));
parser.addPositionalArgument("destination", QCoreApplication::translate("main", "Destination directory."));
//! [2]
}

{
//! [3]
QCoreApplication app(argc, argv);
QCommandLineParser parser;

parser.addPositionalArgument("command", "The command to execute.");

// Call parse() to find out the positional arguments.
parser.parse(QCoreApplication::arguments());

const QStringList args = parser.positionalArguments();
const QString command = args.isEmpty() ? QString() : args.first();
if (command == "resize") {
    parser.clearPositionalArguments();
    parser.addPositionalArgument("resize", "Resize the object to a new size.", "resize [resize_options]");
    parser.addOption(QCommandLineOption("size", "New size.", "new_size"));
    parser.process(app);
    // ...
}

/*
This code results in context-dependent help:

$ tool --help
Usage: tool command

Arguments:
  command  The command to execute.

$ tool resize --help
Usage: tool resize [resize_options]

Options:
  --size <size>  New size.

Arguments:
  resize         Resize the object to a new size.
*/
//! [3]
}

{
//! [4]
QCommandLineParser parser;
parser.setApplicationDescription(QCoreApplication::translate("main", "The best application in the world"));
parser.addHelpOption();
//! [4]
}

}
Пример #6
0
int main ( int argc, char **argv )
{
	Q_INIT_RESOURCE(qtractor);
#ifdef CONFIG_STACKTRACE
#if defined(__GNUC__) && defined(Q_OS_LINUX)
	signal(SIGILL,  stacktrace);
	signal(SIGFPE,  stacktrace);
	signal(SIGSEGV, stacktrace);
	signal(SIGABRT, stacktrace);
	signal(SIGBUS,  stacktrace);
#endif
#endif
	qtractorApplication app(argc, argv);

	// Construct default settings; override with command line arguments.
	qtractorOptions options;
	if (!options.parse_args(app.arguments())) {
		app.quit();
		return 1;
	}

	// Have another instance running?
	if (app.setup()) {
		app.quit();
		return 2;
	}

#if QT_VERSION >= 0x050100
#ifdef CONFIG_LV2_UI_GTK2
	// Initialize GTK+ framework (LV2 plug-in UI GTK2 support)...
	gtk_init(NULL, NULL);
#endif	// CONFIG_LV2_UI_GTK2
#endif

	// Special style paths...
	if (QDir(CONFIG_PLUGINSDIR).exists())
		app.addLibraryPath(CONFIG_PLUGINSDIR);

	// Custom style theme...
	if (!options.sCustomStyleTheme.isEmpty())
		app.setStyle(QStyleFactory::create(options.sCustomStyleTheme));

	// Custom color theme (eg. "KXStudio")...
	QPalette pal(app.palette());
	unsigned int iUpdatePalette = 0;
	if (update_palette(pal, options.sCustomColorTheme))
		++iUpdatePalette;
	// Dark themes grayed/disabled color group fix...
	if (pal.base().color().value() < 0x7f) {
		const QColor& color = pal.window().color();
		const int iGroups = int(QPalette::Active | QPalette::Inactive) + 1;
		for (int i = 0; i < iGroups; ++i) {
			const QPalette::ColorGroup group = QPalette::ColorGroup(i);
			pal.setBrush(group, QPalette::Light,    color.lighter(140));
			pal.setBrush(group, QPalette::Midlight, color.lighter(100));
			pal.setBrush(group, QPalette::Mid,      color.lighter(90));
			pal.setBrush(group, QPalette::Dark,     color.darker(160));
			pal.setBrush(group, QPalette::Shadow,   color.darker(180));
		}
		pal.setColorGroup(QPalette::Disabled,
			pal.windowText().color().darker(),
			pal.button(),
			pal.light(),
			pal.dark(),
			pal.mid(),
			pal.text().color().darker(),
			pal.text().color().lighter(),
			pal.base(),
			pal.window());
	#if QT_VERSION >= 0x050000
		pal.setColor(QPalette::Disabled,
			QPalette::Highlight, pal.mid().color());
		pal.setColor(QPalette::Disabled,
			QPalette::ButtonText, pal.mid().color());
	#endif
		++iUpdatePalette;
	}
	// New palette update?
	if (iUpdatePalette > 0)
		app.setPalette(pal);

	// Set default base font...
	if (options.iBaseFontSize > 0)
		app.setFont(QFont(app.font().family(), options.iBaseFontSize));

	// Construct, setup and show the main form (a pseudo-singleton).
	qtractorMainForm w;
	w.setup(&options);
	w.show();

	// Settle this one as application main widget...
	app.setMainWidget(&w);

	return app.exec();
}
Пример #7
0
// Usage: ./Volumetricd.exe ../../data/monkey.obj 256 4 2 90
int main(int argc, char **argv)
{
	if (argc < 6)
	{
		std::cerr << "Missing parameters. Abort." 
			<< std::endl
			<< "Usage:  ./Volumetricd.exe ../../data/monkey.obj 256 8 2 90"
			<< std::endl;
		return EXIT_FAILURE;
	}
	Timer timer;
	const std::string filepath = argv[1];
	const int vol_size = atoi(argv[2]);
	const int vx_size = atoi(argv[3]);
	const int cloud_count = atoi(argv[4]);
	const int rot_interval = atoi(argv[5]);

	std::pair<std::vector<double>, std::vector<double>> depth_buffer;

	//
	// Projection and Modelview Matrices
	//
	Eigen::Matrix4d K = perspective_matrix(fov_y, aspect_ratio, near_plane, far_plane);
	std::pair<Eigen::Matrix4d, Eigen::Matrix4d>	T(Eigen::Matrix4d::Identity(), Eigen::Matrix4d::Identity());


	//
	// Creating volume
	//
	Eigen::Vector3d voxel_size(vx_size, vx_size, vx_size);
	Eigen::Vector3d volume_size(vol_size, vol_size, vol_size);
	Eigen::Vector3d voxel_count(volume_size.x() / voxel_size.x(), volume_size.y() / voxel_size.y(), volume_size.z() / voxel_size.z());
	//
	Eigen::Affine3d grid_affine = Eigen::Affine3d::Identity();
	grid_affine.translate(Eigen::Vector3d(0, 0, -256));
	grid_affine.scale(Eigen::Vector3d(1, 1, -1));	// z is negative inside of screen


	Grid<double> grid(volume_size, voxel_size, grid_affine.matrix());


	//
	// Importing .obj
	//
	timer.start();
	std::vector<Eigen::Vector3d> points3DOrig, pointsTmp;
	import_obj(filepath, points3DOrig);
	timer.print_interval("Importing monkey    : ");
	std::cout << "Monkey point count  : " << points3DOrig.size() << std::endl;

	// 
	// Translating and rotating monkey point cloud 
	std::pair<std::vector<Eigen::Vector3d>, std::vector<Eigen::Vector3d>> cloud;
	//
	Eigen::Affine3d rotate = Eigen::Affine3d::Identity();
	Eigen::Affine3d translate = Eigen::Affine3d::Identity();
	translate.translate(Eigen::Vector3d(0, 0, -256));


	// 
	// Compute first cloud
	//
	for (Eigen::Vector3d p3d : points3DOrig)
	{
		Eigen::Vector4d rot = translate.matrix() * rotate.matrix() * p3d.homogeneous();
		rot /= rot.w();
		cloud.first.push_back(rot.head<3>());
	}
	//
	// Update grid with first cloud
	//
	timer.start();
	create_depth_buffer<double>(depth_buffer.first, cloud.first, K, Eigen::Matrix4d::Identity(), far_plane);
	timer.print_interval("CPU compute depth   : ");

	timer.start();
	update_volume(grid, depth_buffer.first, K, T.first);
	timer.print_interval("CPU Update volume   : ");

	//
	// Compute next clouds
	Eigen::Matrix4d cloud_mat = Eigen::Matrix4d::Identity();
	Timer iter_timer;
	for (int i = 1; i < cloud_count; ++i)
	{
		std::cout << std::endl << i << " : " << i * rot_interval << std::endl;
		iter_timer.start();

		// Rotation matrix
		rotate = Eigen::Affine3d::Identity();
		rotate.rotate(Eigen::AngleAxisd(DegToRad(i * rot_interval), Eigen::Vector3d::UnitY()));

		cloud.second.clear();
		for (Eigen::Vector3d p3d : points3DOrig)
		{
			Eigen::Vector4d rot = translate.matrix() * rotate.matrix() * p3d.homogeneous();
			rot /= rot.w();
			cloud.second.push_back(rot.head<3>());
		}

		//export_obj("../../data/cloud_cpu_2.obj", cloud.second);

		timer.start();
		create_depth_buffer<double>(depth_buffer.second, cloud.second, K, Eigen::Matrix4d::Identity(), far_plane);
		timer.print_interval("Compute depth buffer: ");

		//export_depth_buffer("../../data/cpu_depth_buffer_2.obj", depth_buffer.second);

		timer.start();
		Eigen::Matrix4d icp_mat;
		ComputeRigidTransform(cloud.first, cloud.second, icp_mat);
		timer.print_interval("Compute rigid transf: ");

		//std::cout << std::fixed << std::endl << "icp_mat " << std::endl << icp_mat << std::endl;

		// accumulate matrix
		cloud_mat = cloud_mat * icp_mat;

		//std::cout << std::fixed << std::endl << "cloud_mat " << std::endl << cloud_mat << std::endl;

		timer.start();
		//update_volume(grid, depth_buffer.second, K, cloud_mat.inverse());
		update_volume(grid, depth_buffer.second, K, cloud_mat.inverse());
		timer.print_interval("Update volume       : ");


		// copy second point cloud to first
		cloud.first = cloud.second;
		//depth_buffer.first = depth_buffer.second;

		iter_timer.print_interval("Iteration time      : ");
	}


	//std::cout << "------- // --------" << std::endl;
	//for (int i = 0; i <  grid.data.size(); ++i)
	//{
	//	const Eigen::Vector3d& point = grid.data[i].point;

	//	std::cout << point.transpose() << "\t\t" << grid.data[i].tsdf << " " << grid.data[i].weight << std::endl;
	//}
	//std::cout << "------- // --------" << std::endl;

//	timer.start();
//	export_volume("../../data/grid_volume_cpu.obj", grid.data);
//	timer.print_interval("Exporting volume    : ");
//	return 0;


	QApplication app(argc, argv);

	//
	// setup opengl viewer
	// 
	GLModelViewer glwidget;
	glwidget.resize(640, 480);
	glwidget.setPerspective(60.0f, 0.1f, 10240.0f);
	glwidget.move(320, 0);
	glwidget.setWindowTitle("Point Cloud");
	glwidget.setWeelSpeed(0.1f);
	glwidget.setDistance(-0.5f);
	glwidget.show();

	
	Eigen::Matrix4d to_origin = Eigen::Matrix4d::Identity();
	to_origin.col(3) << -(volume_size.x() / 2.0), -(volume_size.y() / 2.0), -(volume_size.z() / 2.0), 1.0;	// set translate


	std::vector<Eigen::Vector4f> vertices, colors;

	int i = 0;
	for (int z = 0; z <= volume_size.z(); z += voxel_size.z())
	{
		for (int y = 0; y <= volume_size.y(); y += voxel_size.y())
		{
			for (int x = 0; x <= volume_size.x(); x += voxel_size.x(), i++)
			{
				const float tsdf = grid.data.at(i).tsdf;

				//Eigen::Vector4d p = grid_affine.matrix() * to_origin * Eigen::Vector4d(x, y, z, 1);
				Eigen::Vector4d p = to_origin * Eigen::Vector4d(x, y, z, 1);
				p /= p.w();

				if (tsdf > 0.1)
				{
					vertices.push_back(p.cast<float>());
					colors.push_back(Eigen::Vector4f(0, 1, 0, 1));
				}
				else if (tsdf < -0.1)
				{
					vertices.push_back(p.cast<float>());
					colors.push_back(Eigen::Vector4f(1, 0, 0, 1));
				}
			}
		}
	}




	//
	// setup model
	// 
	std::shared_ptr<GLModel> model(new GLModel);
	model->initGL();
	model->setVertices(&vertices[0][0], vertices.size(), 4);
	model->setColors(&colors[0][0], colors.size(), 4);
	glwidget.addModel(model);


	//
	// setup kinect shader program
	// 
	std::shared_ptr<GLShaderProgram> kinectShaderProgram(new GLShaderProgram);
	if (kinectShaderProgram->build("color.vert", "color.frag"))
		model->setShaderProgram(kinectShaderProgram);

	return app.exec();
}
Пример #8
0
// N.B. On Windows, this should be called from WinMain. Link against qtmain and specify
// /SubSystem:Windows
int main(int argc, char* argv[])
{
#ifdef _WIN32
  const bool console_attached = AttachConsole(ATTACH_PARENT_PROCESS) != FALSE;
  HANDLE stdout_handle = ::GetStdHandle(STD_OUTPUT_HANDLE);
  if (console_attached && stdout_handle)
  {
    freopen("CONOUT$", "w", stdout);
    freopen("CONOUT$", "w", stderr);
  }
#endif

  QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
  QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
  QCoreApplication::setOrganizationName(QStringLiteral("Dolphin Emulator"));
  QCoreApplication::setOrganizationDomain(QStringLiteral("dolphin-emu.org"));
  QCoreApplication::setApplicationName(QStringLiteral("dolphin-emu"));

  QApplication app(argc, argv);

#ifdef _WIN32
  // Get the default system font because Qt's way of obtaining it is outdated
  NONCLIENTMETRICS metrics = {};
  LOGFONT& logfont = metrics.lfMenuFont;
  metrics.cbSize = sizeof(NONCLIENTMETRICS);

  if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(metrics), &metrics, 0))
  {
    // Sadly Qt 5 doesn't support turning a native font handle into a QFont so this is the next best
    // thing
    QFont font = QApplication::font();
    font.setFamily(QString::fromStdString(UTF16ToUTF8(logfont.lfFaceName)));

    font.setItalic(logfont.lfItalic);
    font.setStrikeOut(logfont.lfStrikeOut);
    font.setUnderline(logfont.lfUnderline);

    // The default font size is a bit too small
    font.setPointSize(QFontInfo(font).pointSize() * 1.2);

    QApplication::setFont(font);
  }
#endif

  auto parser = CommandLineParse::CreateParser(CommandLineParse::ParserOptions::IncludeGUIOptions);
  const optparse::Values& options = CommandLineParse::ParseArguments(parser.get(), argc, argv);
  const std::vector<std::string> args = parser->args();

#ifdef _WIN32
  FreeConsole();
#endif

  UICommon::SetUserDirectory(static_cast<const char*>(options.get("user")));
  UICommon::CreateDirectories();
  UICommon::Init();
  Resources::Init();
  Settings::Instance().SetBatchModeEnabled(options.is_set("batch"));

  // Hook up alerts from core
  RegisterMsgAlertHandler(QtMsgAlertHandler);

  // Hook up translations
  Translation::Initialize();

  // Whenever the event loop is about to go to sleep, dispatch the jobs
  // queued in the Core first.
  QObject::connect(QAbstractEventDispatcher::instance(), &QAbstractEventDispatcher::aboutToBlock,
                   &app, &Core::HostDispatchJobs);

  std::unique_ptr<BootParameters> boot;
  if (options.is_set("exec"))
  {
    const std::list<std::string> paths_list = options.all("exec");
    const std::vector<std::string> paths{std::make_move_iterator(std::begin(paths_list)),
                                         std::make_move_iterator(std::end(paths_list))};
    boot = BootParameters::GenerateFromFile(paths);
  }
  else if (options.is_set("nand_title"))
  {
    const std::string hex_string = static_cast<const char*>(options.get("nand_title"));
    if (hex_string.length() == 16)
    {
      const u64 title_id = std::stoull(hex_string, nullptr, 16);
      boot = std::make_unique<BootParameters>(BootParameters::NANDTitle{title_id});
    }
    else
    {
      QMessageBox::critical(nullptr, QObject::tr("Error"), QObject::tr("Invalid title ID."));
    }
  }
  else if (!args.empty())
  {
    boot = BootParameters::GenerateFromFile(args.front());
  }

  int retval;

  {
    DolphinAnalytics::Instance()->ReportDolphinStart("qt");

    MainWindow win{std::move(boot)};
    if (options.is_set("debugger"))
      Settings::Instance().SetDebugModeEnabled(true);
    win.Show();

#if defined(USE_ANALYTICS) && USE_ANALYTICS
    if (!SConfig::GetInstance().m_analytics_permission_asked)
    {
      QMessageBox analytics_prompt(&win);

      analytics_prompt.setIcon(QMessageBox::Question);
      analytics_prompt.setWindowModality(Qt::WindowModal);
      analytics_prompt.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
      analytics_prompt.setWindowTitle(QObject::tr("Allow Usage Statistics Reporting"));
      analytics_prompt.setText(
          QObject::tr("Do you authorize Dolphin to report information to Dolphin's developers?"));
      analytics_prompt.setInformativeText(
          QObject::tr("If authorized, Dolphin can collect data on its performance, "
                      "feature usage, and configuration, as well as data on your system's "
                      "hardware and operating system.\n\n"
                      "No private data is ever collected. This data helps us understand "
                      "how people and emulated games use Dolphin and prioritize our "
                      "efforts. It also helps us identify rare configurations that are "
                      "causing bugs, performance and stability issues.\n"
                      "This authorization can be revoked at any time through Dolphin's "
                      "settings."));

      const int answer = analytics_prompt.exec();

      SConfig::GetInstance().m_analytics_permission_asked = true;
      Settings::Instance().SetAnalyticsEnabled(answer == QMessageBox::Yes);

      DolphinAnalytics::Instance()->ReloadConfig();
    }
#endif

    auto* updater = new Updater(&win);
    updater->start();

    retval = app.exec();
  }

  Core::Shutdown();
  UICommon::Shutdown();
  Host::GetInstance()->deleteLater();

  return retval;
}
Пример #9
0
int main(int argc, char **argv)
{
	try
	{
    /* Registering the below classes as metatypes in order to make
		them liable to be sent through signal parameters. */
		qRegisterMetaType<ObjectType>("ObjectType");
		qRegisterMetaType<Exception>("Exception");
		qRegisterMetaType<ValidationInfo>("ValidationInfo");

		//Install a signal handler to start crashhandler when SIGSEGV or SIGABRT is emitted
		signal(SIGSEGV, startCrashHandler);
		signal(SIGABRT, startCrashHandler);

		Application app(argc,argv);

		//Loading the application splash screen
		QSplashScreen splash;
		QPixmap pix(QPixmap(":imagens/imagens/pgmodeler_splash.png"));
		splash.setPixmap(pix);
		splash.setMask(pix.mask());

		#ifndef Q_OS_MAC
			splash.setWindowFlags(Qt::SplashScreen | Qt::FramelessWindowHint);
		#else
			splash.setWindowFlags(Qt::SplashScreen | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
		#endif

    #ifdef Q_OS_WIN
      splash.show();
    #else
      splash.showMaximized();
    #endif

		app.processEvents();

		//Creates the main form
		MainWindow fmain;

		//Loading models via command line on MacOSX are disabled until the file association work correclty on that system
		#ifndef Q_OS_MAC
     QStringList params=app.arguments();
     params.pop_front();

		 //If the user specifies a list of files to be loaded
     if(!params.isEmpty())
      fmain.loadModels(params);
		#endif

		splash.finish(&fmain);
		fmain.showMaximized();

		return(app.exec());
	}
	catch(Exception &e)
	{
		QTextStream ts(stdout);
		ts << e.getExceptionsText();
		return(e.getErrorType());
	}
}
Пример #10
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    return QTest::qExec(new DocumentStructureTest, argc, argv);
}
Пример #11
0
int main(int argc, char *argv[]) {
    Application app(argc, argv, "citydemo");
    return app.Run();
}
Пример #12
0
// Application entry point
int main( int argc, char *argv[] )
{
    QT_REQUIRE_VERSION( argc, argv, "4.7.0" );

#ifndef QT_DEBUG
    qInstallMsgHandler( MessageHandler );
#endif

    MainApplication app( argc, argv );
    XercesExt::XercesInit init;

    try
    {
        // We prevent Qt from constantly creating and deleting threads.
        // Using a negative number forces the threads to stay around;
        // that way, we always have a steady number of threads ready to do work.
        QThreadPool::globalInstance()->setExpiryTimeout( -1 );

        // Specify the plugin folders
        // (language codecs and image loaders)
        app.addLibraryPath( "codecs" );
        app.addLibraryPath( "iconengines" );
        app.addLibraryPath( "imageformats" );

        // Set application information for
        // easier use of QSettings classes
        QCoreApplication::setOrganizationName( "sigil-ebook" );
        QCoreApplication::setOrganizationDomain("sigil-ebook.com");
        QCoreApplication::setApplicationName( "sigil" );
        QCoreApplication::setApplicationVersion(SIGIL_VERSION);

        // Setup the translator and load the translation for the selected language
        QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
        QTranslator translator;

        SettingsStore settings;
        const QString qm_name = QString("sigil_%1").arg(settings.uiLanguage());

        // Run though all locations and stop once we find and are able to load
        // an appropriate translation.
        foreach (QString path, UILanguage::GetPossibleTranslationPaths()) {
            if (QDir(path).exists()) {
                if (translator.load(qm_name, path)) {
                    break;
                }
            }
        }
        app.installTranslator(&translator);

        // We set the window icon explicitly on Linux.
        // On Windows this is handled by the RC file,
        // and on Mac by the ICNS file.
    #ifdef Q_WS_X11
        app.setWindowIcon( GetApplicationIcon() );
    #endif

        // On Unix systems, we make sure that the temp folder we
        // create is accessible by all users. On Windows, there's
        // a temp folder per user.
    #ifndef Q_WS_WIN
        CreateTempFolderWithCorrectPermissions();
    #endif

        // Needs to be created on the heap so that
        // the reply has time to return.
        UpdateChecker *checker = new UpdateChecker( &app );
        checker->CheckForUpdate();

        // Install an event filter for the application
        // so we can catch OS X's file open events
        AppEventFilter *filter = new AppEventFilter( &app );
        app.installEventFilter( filter );

        const QStringList &arguments = QCoreApplication::arguments();

        if (arguments.contains("-t")) {
            std::cout  << TempFolder::GetPathToSigilScratchpad().toStdString() << std::endl;
            return 1;
        //} else if (arguments.count() == 3) {
            // Used for an undocumented, unsupported *-to-epub
            // console conversion. USE AT YOUR OWN PERIL!
            return QuickConvert( arguments );
        } else {
            // Normal startup
            MainWindow *widget = GetMainWindow( arguments );
            widget->show();
            return app.exec();
        }
    }
    catch ( ExceptionBase &exception )
    {
        Utility::DisplayExceptionErrorDialog( Utility::GetExceptionInfo( exception ) );
        return 1;
    }
}
Пример #13
0
int main(int argc, char** argv)
{
    // nspluginviewer is a helper app, it shouldn't do session management at all
   setenv( "SESSION_MANAGER", "", 1 );

   // trap X errors
   kdDebug(1430) << "1 - XSetErrorHandler" << endl;
   XSetErrorHandler(x_errhandler);
   setvbuf( stderr, NULL, _IONBF, 0 );

   kdDebug(1430) << "2 - parseCommandLine" << endl;
   parseCommandLine(argc, argv);

   kdDebug(1430) << "3 - create QXtEventLoop" << endl;
   QXtEventLoop integrator( "nspluginviewer" );
   parseCommandLine(argc, argv);
   TDELocale::setMainCatalogue("nsplugin");

   kdDebug(1430) << "4 - create TDEApplication" << endl;
   TDEApplication app( argc,  argv, "nspluginviewer", true, true, true );
   GlibEvents glibevents;

   {
      TDEConfig cfg("kcmnspluginrc", true);
      cfg.setGroup("Misc");
      int v = KCLAMP(cfg.readNumEntry("Nice Level", 0), 0, 19);
      if (v > 0) {
         nice(v);
      }
      v = cfg.readNumEntry("Max Memory", 0);
      if (v > 0) {
         rlimit rl;
         memset(&rl, 0, sizeof(rl));
         if (0 == getrlimit(RLIMIT_AS, &rl)) {
            rl.rlim_cur = kMin(v, int(rl.rlim_max));
            setrlimit(RLIMIT_AS, &rl);
         }
      }
   }

   // initialize the dcop client
   kdDebug(1430) << "5 - app.dcopClient" << endl;
   DCOPClient *dcop = app.dcopClient();
   if (!dcop->attach())
   {
      KMessageBox::error(NULL,
                            i18n("There was an error connecting to the Desktop "
                                 "communications server. Please make sure that "
                                 "the 'dcopserver' process has been started, and "
                                 "then try again."),
                            i18n("Error Connecting to DCOP Server"));
      exit(1);
   }

   kdDebug(1430) << "6 - dcop->registerAs" << endl;
   if (g_dcopId != 0)
      g_dcopId = dcop->registerAs( g_dcopId, false );
   else
      g_dcopId = dcop->registerAs("nspluginviewer");

   dcop->setNotifications(true);

   // create dcop interface
   kdDebug(1430) << "7 - new NSPluginViewer" << endl;
   NSPluginViewer *viewer = new NSPluginViewer( "viewer", 0 );

   // start main loop
#if TQT_VERSION < 0x030100
   kdDebug(1430) << "8 - XtAppProcessEvent" << endl;
   while (!g_quit)
     XtAppProcessEvent( g_appcon, XtIMAll);
#else
   kdDebug(1430) << "8 - app.exec()" << endl;
   app.exec();
#endif

   // delete viewer
   delete viewer;
}
Пример #14
0
/**
 * Main. Creates Application window.
 */
int main(int argc, char** argv)
{
    QT_REQUIRE_VERSION(argc, argv, "5.2.1");

    RS_DEBUG->setLevel(RS_Debug::D_WARNING);

    QApplication app(argc, argv);
    QCoreApplication::setOrganizationName("LibreCAD");
    QCoreApplication::setApplicationName("LibreCAD");
    QCoreApplication::setApplicationVersion(XSTR(LC_VERSION));

    QSettings settings;

    bool first_load = settings.value("Startup/FirstLoad", 1).toBool();

    const QString lpDebugSwitch0("-d"),lpDebugSwitch1("--debug") ;
    const QString help0("-h"), help1("--help");
    bool allowOptions=true;
    QList<int> argClean;
    for (int i=0; i<argc; i++)
    {
        QString argstr(argv[i]);
        if(allowOptions&&QString::compare("--", argstr)==0)
        {
            allowOptions=false;
            continue;
        }
        if (allowOptions && (help0.compare(argstr, Qt::CaseInsensitive)==0 ||
                             help1.compare(argstr, Qt::CaseInsensitive)==0 ))
        {
            qDebug()<<"librecad::usage: <options> <dxf file>";
            qDebug()<<"-h, --help\tdisplay this message";
            qDebug()<<"";
            qDebug()<<" --help\tdisplay this message";
            qDebug()<<"-d, --debug <level>";
            RS_DEBUG->print( RS_Debug::D_NOTHING, "possible debug levels:");
            RS_DEBUG->print( RS_Debug::D_NOTHING, "    %d Nothing", RS_Debug::D_NOTHING);
            RS_DEBUG->print( RS_Debug::D_NOTHING, "    %d Critical", RS_Debug::D_CRITICAL);
            RS_DEBUG->print( RS_Debug::D_NOTHING, "    %d Error", RS_Debug::D_ERROR);
            RS_DEBUG->print( RS_Debug::D_NOTHING, "    %d Warning", RS_Debug::D_WARNING);
            RS_DEBUG->print( RS_Debug::D_NOTHING, "    %d Notice", RS_Debug::D_NOTICE);
            RS_DEBUG->print( RS_Debug::D_NOTHING, "    %d Informational", RS_Debug::D_INFORMATIONAL);
            RS_DEBUG->print( RS_Debug::D_NOTHING, "    %d Debugging", RS_Debug::D_DEBUGGING);
            exit(0);
        }
        if ( allowOptions&& (argstr.startsWith(lpDebugSwitch0, Qt::CaseInsensitive) ||
                             argstr.startsWith(lpDebugSwitch1, Qt::CaseInsensitive) ))
        {
            argClean<<i;

            // to control the level of debugging output use --debug with level 0-6, e.g. --debug3
            // for a list of debug levels use --debug?
            // if no level follows, the debugging level is set
            argstr.remove(QRegExp("^"+lpDebugSwitch0));
            argstr.remove(QRegExp("^"+lpDebugSwitch1));
            char level;
            if(argstr.size()==0)
            {
                if(i+1<argc)
                {
                    if(QRegExp("\\d*").exactMatch(argv[i+1]))
                    {
                        ++i;
                        qDebug()<<"reading "<<argv[i]<<" as debugging level";
                        level=argv[i][0];
                        argClean<<i;
                    }
                    else
                        level='3';
                }
                else
                    level='3'; //default to D_WARNING
            }
            else
                level=argstr.toStdString()[0];

            switch(level)
            {
            case '?' :
                RS_DEBUG->print( RS_Debug::D_NOTHING, "possible debug levels:");
                RS_DEBUG->print( RS_Debug::D_NOTHING, "    %d Nothing", RS_Debug::D_NOTHING);
                RS_DEBUG->print( RS_Debug::D_NOTHING, "    %d Critical", RS_Debug::D_CRITICAL);
                RS_DEBUG->print( RS_Debug::D_NOTHING, "    %d Error", RS_Debug::D_ERROR);
                RS_DEBUG->print( RS_Debug::D_NOTHING, "    %d Warning", RS_Debug::D_WARNING);
                RS_DEBUG->print( RS_Debug::D_NOTHING, "    %d Notice", RS_Debug::D_NOTICE);
                RS_DEBUG->print( RS_Debug::D_NOTHING, "    %d Informational", RS_Debug::D_INFORMATIONAL);
                RS_DEBUG->print( RS_Debug::D_NOTHING, "    %d Debugging", RS_Debug::D_DEBUGGING);
                return 0;

            case '0' + RS_Debug::D_NOTHING :
                RS_DEBUG->setLevel( RS_Debug::D_NOTHING);
                ++i;
                break;

            case '0' + RS_Debug::D_CRITICAL :
                RS_DEBUG->setLevel( RS_Debug::D_CRITICAL);
                ++i;
                break;

            case '0' + RS_Debug::D_ERROR :
                RS_DEBUG->setLevel( RS_Debug::D_ERROR);
                ++i;
                break;

            case '0' + RS_Debug::D_WARNING :
                RS_DEBUG->setLevel( RS_Debug::D_WARNING);
                ++i;
                break;

            case '0' + RS_Debug::D_NOTICE :
                RS_DEBUG->setLevel( RS_Debug::D_NOTICE);
                ++i;
                break;

            case '0' + RS_Debug::D_INFORMATIONAL :
                RS_DEBUG->setLevel( RS_Debug::D_INFORMATIONAL);
                ++i;
                break;

            case '0' + RS_Debug::D_DEBUGGING :
                RS_DEBUG->setLevel( RS_Debug::D_DEBUGGING);
                ++i;
                break;

            default :
                RS_DEBUG->setLevel(RS_Debug::D_DEBUGGING);
                break;
            }
        }
    }
    RS_DEBUG->print("param 0: %s", argv[0]);

    QFileInfo prgInfo( QFile::decodeName(argv[0]) );
    QString prgDir(prgInfo.absolutePath());
    RS_SETTINGS->init(app.organizationName(), app.applicationName());
    RS_SYSTEM->init(app.applicationName(), app.applicationVersion(), XSTR(QC_APPDIR), prgDir);

    // parse command line arguments that might not need a launched program:
    QStringList fileList = handleArgs(argc, argv, argClean);

    QString unit = settings.value("Defaults/Unit", "Invalid").toString();

    // show initial config dialog:
    if (first_load)
    {
        RS_DEBUG->print("main: show initial config dialog..");
        QG_DlgInitial di(nullptr);
        QPixmap pxm(":/main/intro_librecad.png");
        di.setPixmap(pxm);
        if (di.exec())
        {
            RS_SETTINGS->beginGroup("/Defaults");
            unit = RS_SETTINGS->readEntry("/Unit", "None");
            RS_SETTINGS->endGroup();
        }
        RS_DEBUG->print("main: show initial config dialog: OK");
    }

    auto splash = new QSplashScreen;

    bool show_splash = settings.value("Startup/ShowSplash", 1).toBool();

    if (show_splash)
    {
        QPixmap pixmap(":/main/splash_librecad.png");
        splash->setPixmap(pixmap);
        splash->setAttribute(Qt::WA_DeleteOnClose);
        splash->show();
        splash->showMessage(QObject::tr("Loading.."),
                            Qt::AlignRight|Qt::AlignBottom, Qt::black);
        app.processEvents();
        RS_DEBUG->print("main: splashscreen: OK");
    }

    RS_DEBUG->print("main: init fontlist..");
    RS_FONTLIST->init();
    RS_DEBUG->print("main: init fontlist: OK");

    RS_DEBUG->print("main: init patternlist..");
    RS_PATTERNLIST->init();
    RS_DEBUG->print("main: init patternlist: OK");

    RS_DEBUG->print("main: loading translation..");

    settings.beginGroup("Appearance");
    QString lang = settings.value("Language", "en").toString();
    QString langCmd = settings.value("LanguageCmd", "en").toString();
    settings.endGroup();

    RS_SYSTEM->loadTranslation(lang, langCmd);
    RS_DEBUG->print("main: loading translation: OK");

    RS_DEBUG->print("main: creating main window..");
    QC_ApplicationWindow appWin;
    RS_DEBUG->print("main: setting caption");
    appWin.setWindowTitle(app.applicationName());

    RS_DEBUG->print("main: show main window");

    settings.beginGroup("Geometry");
    int windowWidth = settings.value("WindowWidth", 1024).toInt();
    int windowHeight = settings.value("WindowHeight", 1024).toInt();
    int windowX = settings.value("WindowX", 32).toInt();
    int windowY = settings.value("WindowY", 32).toInt();
    settings.endGroup();

    settings.beginGroup("Defaults");
    if( !settings.contains("UseQtFileOpenDialog")) {
#ifdef Q_OS_LINUX
        // on Linux don't use native file dialog
        // because of case insensitive filters (issue #791)
        settings.setValue("UseQtFileOpenDialog", QVariant(1));
#else
        settings.setValue("UseQtFileOpenDialog", QVariant(0));
#endif
    }
    settings.endGroup();

    if (!first_load)
        appWin.resize(windowWidth, windowHeight);

    appWin.move(windowX, windowY);

    bool maximize = settings.value("Startup/Maximize", 0).toBool();

    if (maximize || first_load)
        appWin.showMaximized();
    else
        appWin.show();

    RS_DEBUG->print("main: set focus");
    appWin.setFocus();
    RS_DEBUG->print("main: creating main window: OK");

    if (show_splash)
    {
        RS_DEBUG->print("main: updating splash");
        splash->raise();
        splash->showMessage(QObject::tr("Loading..."),
                Qt::AlignRight|Qt::AlignBottom, Qt::black);
        RS_DEBUG->print("main: processing events");
        qApp->processEvents();
        RS_DEBUG->print("main: updating splash: OK");
    }

    // Set LC_NUMERIC so that entering numeric values uses . as the decimal seperator
    setlocale(LC_NUMERIC, "C");

    RS_DEBUG->print("main: loading files..");
    bool files_loaded = false;
    for (QStringList::Iterator it = fileList.begin(); it != fileList.end(); ++it )
    {
        if (show_splash)
        {
            splash->showMessage(QObject::tr("Loading File %1..")
                    .arg(QDir::toNativeSeparators(*it)),
            Qt::AlignRight|Qt::AlignBottom, Qt::black);
            qApp->processEvents();
        }
        appWin.slotFileOpen(*it, RS2::FormatUnknown);
        files_loaded = true;
    }
    RS_DEBUG->print("main: loading files: OK");

    if (!files_loaded)
    {
        appWin.slotFileNewNew();
    }

    if (show_splash)
        splash->finish(&appWin);
    else
        delete splash;

    if (first_load)
        settings.setValue("Startup/FirstLoad", 0);

    RS_DEBUG->print("main: entering Qt event loop");

    int return_code = app.exec();

    RS_DEBUG->print("main: exited Qt event loop");

    return return_code;
}
Пример #15
0
int main ( int argc, char *argv[] ){
    QCoreApplication app( argc, argv );
    ut_rotate test;
    return QTest::qExec( &test, argc, argv );

}
Пример #16
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    app.setOrganizationName("ITI");
    app.setOrganizationDomain("myaircoach.eu");
    app.setApplicationName("myAirCoach");

    //---------
    //QTranslator qtTranslator;
   // qtTranslator.load("myAirCoach_" + QLocale::system().name(), ":/");
    //app.installTranslator(&qtTranslator);
    //---------

    qmlRegisterType<MyAdmob>("myadmob", 1, 0, "MyAdmob");
    qmlRegisterType<MyDevice>("mydevice", 1, 0, "MyDevice");
    qmlRegisterType<QMLObjectStore>("QMLObjectStore", 1, 0, "QMLObjectStore");
    qmlRegisterType<WaterfallItem>("hu.timur", 1, 0, "Waterfall");

    qmlRegisterType<Graph>("Graph", 1, 0, "Graph");
    //QQmlApplicationEngine engine;

    qmlRegisterType<WeatherData>("WeatherInfo", 1, 0, "WeatherData");
    qmlRegisterType<AppModel>("WeatherInfo", 1, 0, "AppModel");
    qmlRegisterType<AudioRecorder>("AudioRecorder", 1, 0, "AudioRecorder");
    qmlRegisterType<FPSText>("FPSText", 1, 0, "FPSText");
//! [0]
    qRegisterMetaType<WeatherData>();


    //AudioRecorder recorder;

    QQmlApplicationEngine* engine = new QQmlApplicationEngine();
    //engine->rootContext()->setContextProperty("recorder", &recorder);
    engine->load(QUrl(QStringLiteral("qrc:/qml/main.qml")));  //main1




    QQmlContext * rootContext = engine->rootContext();
    /*const QStringList & musicPaths = QStandardPaths::standardLocations(QStandardPaths::MusicLocation);
    const QUrl musicUrl = QUrl::fromLocalFile(musicPaths.isEmpty() ? QDir::homePath() : musicPaths.first());
    rootContext->setContextProperty(QStringLiteral("musicUrl"), musicUrl);

    const QStringList arguments = QCoreApplication::arguments();
    const QUrl commandLineUrl = arguments.size() > 1 ? QUrl::fromLocalFile(arguments.at(1)) : QUrl();
    rootContext->setContextProperty(QStringLiteral("url"), commandLineUrl);
*/

   // NotificationClient *notificationClient;
  //  rootContext->setContextProperty(QLatin1String("notificationClient"),
   //                                                  notificationClient);


    //view.setResizeMode(QQuickView::SizeRootObjectToView);


    QObject * root = engine->rootObjects().first();














#ifdef Q_OS_ANDROID
    QString hash = QString("myAirCoach");
    QString dirStorageString = QString("/sdcard/Android/data/com.qtproject.qtangled/");
    QDir dir;
    if( dir.mkpath(dirStorageString) )
    {
        engine->setOfflineStoragePath( dirStorageString );
        engine->load(QUrl(QStringLiteral("qrc:/qml/main.qml")));

        QString dbFileString = dirStorageString + hash + QString(".sqlite");
        QFile dbFile(dbFileString);
        if (dbFile.exists()) {
            QFile::setPermissions(dbFileString, QFile::WriteOwner | QFile::ReadOwner);
        }

        QFile iniFile( dir.path() + hash + QString(".ini") );
        iniFile.open( QIODevice::WriteOnly );
        iniFile.write( "[General]\nDescription=Catalog\nDriver=QSQLITE\nName=Catalog\nVersion=1.0" );
        iniFile.close();
    }
    else
    {
#endif
        //engine->load(QUrl(QStringLiteral("qrc:/qml/main.qml")));   //sos prosoxh velos h teleia
#ifdef Q_OS_ANDROID
    }
#endif


    return app.exec();
}
Пример #17
0
int main(int argc, char *argv[])
{
#ifdef QT_GUI_LIB
	QGuiApplication app(argc, argv);
#else
	QCoreApplication app(argc, argv);
#endif
	QCoreApplication::setApplicationName("Torkelnde Yamyams");
	QCoreApplication::setOrganizationName("Dominic Meiser");
	
	QCommandLineParser parser;
	parser.setApplicationDescription("34. BwInf Aufgabe 3 - Torkelnde Yamyams");
	parser.addHelpOption();
	QCommandLineOption fileOption(QStringList() << "f" << "file", "A file containing the description of a world.", "file");
	parser.addOption(fileOption);
	QCommandLineOption exampleOption(QStringList() << "e" << "example", "Use the given example from the BwInf.", "example");
	parser.addOption(exampleOption);
	parser.process(app);
	
	QString filename;
	if (parser.isSet(exampleOption))
		filename = ":/examples/" + parser.value(exampleOption);
	else if (parser.isSet(fileOption))
		filename = parser.value(fileOption);
	else
	{
		qCritical() << "No action specified. Use --help to display help.";
		return 1;
	}
	
	World *w = World::read(filename);
	if (!w)
	{
		qCritical() << "Failed to read world";
		return 1;
	}
	if (parser.isSet(fileOption))
	{
		QFileInfo info(filename);
		w->write(info.absoluteDir().absoluteFilePath(info.baseName() + ".orig.yyw"), false);
	}
	for (quint32 i = 0; i < w->height(); i++)
	{
		for (quint32 j = 0; j < w->width(); j++)
		{
			if (isatty(STDOUT_FILENO))
				printf("\033[%dm  \033[0m", colorCode(w->field(j, i)->type, World::UnknownState));
			else
				printf("%c ", static_cast<char>(w->field(j, i)->type));
		}
		printf("\n");
	}
	if (w->hasResult())
		qDebug() << "The loaded world already contains a solution";
	else
	{
		QTime t = QTime::currentTime();
		solveWorld(w);
		qDebug() << "solved the world in" << t.elapsed() << "ms";
	}
	for (quint32 i = 0; i < w->height(); i++)
	{
		for (quint32 j = 0; j < w->width(); j++)
		{
			if (isatty(STDOUT_FILENO))
				printf("\033[%dm  \033[0m", colorCode(w->field(j, i)->type, w->field(j, i)->state));
			else
				printf("%c ", static_cast<char>(w->field(j, i)->state == World::UnknownState ? w->field(j, i)->type : w->field(j, i)->state));
		}
		printf("\n");
	}
	if (parser.isSet(fileOption))
	{
		QFileInfo info(filename);
		w->write(info.absoluteDir().absoluteFilePath(info.baseName() + ".solved.yyw"), true);
#ifdef QT_GUI_LIB
		QImage *img = w->draw();
		if (img)
		{
			img->save(info.absoluteDir().absoluteFilePath(info.baseName()) + ".png", "PNG");
			delete img;
		}
#endif
	}
	
	return 0;
}
Пример #18
0
int main(int argc, char *argv[]) {
#ifdef _NEED_WIN_GENERATE_DUMP
	_oldWndExceptionFilter = SetUnhandledExceptionFilter(_exceptionFilter);
#endif

	InitOpenSSL _init;

	settingsParseArgs(argc, argv);
	for (int32 i = 0; i < argc; ++i) {
		if (string("-fixprevious") == argv[i]) {
			return psFixPrevious();
		} else if (string("-cleanup") == argv[i]) {
			return psCleanup();
		}
	}
	logsInit();

	Local::readSettings();
	if (cFromAutoStart() && !cAutoStart()) {
		psAutoStart(false, true);
		Local::stop();
		return 0;
	}

	DEBUG_LOG(("Application Info: Telegram started, test mode: %1, exe dir: %2").arg(logBool(cTestMode())).arg(cExeDir()));
	if (cDebug()) {
		LOG(("Application Info: Telegram started in debug mode"));
		for (int32 i = 0; i < argc; ++i) {
			LOG(("Argument: %1").arg(QString::fromLocal8Bit(argv[i])));
		}
        QStringList logs = psInitLogs();
        for (int32 i = 0, l = logs.size(); i < l; ++i) {
            LOG(("Init Log: %1").arg(logs.at(i)));
        }
    }
    psClearInitLogs();

	DEBUG_LOG(("Application Info: ideal thread count: %1, using %2 connections per session").arg(QThread::idealThreadCount()).arg(cConnectionsInSession()));

	psStart();
	int result = 0;
	{
		QByteArray args[] = { "-style=0" }; // prepare fake args
		static const int a_cnt = sizeof(args) / sizeof(args[0]);
		int a_argc = a_cnt + 1;
		char *a_argv[a_cnt + 1] = { argv[0], args[0].data() };

		Application app(a_argc, a_argv);
		if (!App::quiting()) {
			result = app.exec();
		}
	}
    psFinish();
	Local::stop();

	DEBUG_LOG(("Application Info: Telegram done, result: %1").arg(result));

	if (cRestartingUpdate()) {
		DEBUG_LOG(("Application Info: executing updater to install update.."));
		psExecUpdater();
	} else if (cRestarting()) {
		DEBUG_LOG(("Application Info: executing Telegram, because of restart.."));
		psExecTelegram();
	}

	logsClose();
	return result;
}
Пример #19
0
int main(int argc, char** argv)
{
	QApplication app(argc,argv);

	QStringList args = app.arguments();
	if (args.count() < 2)
	{
		qWarning() << "Usage: qtinspector <pid>|<program> (<args>...)";
		return -1;
	}

	QProcess process;
	int targetPid = args.at(1).toInt();

	// inject the helper library
	QScopedPointer<Injector> injector;
	if (targetPid != 0)
	{
#ifdef Q_OS_UNIX
		injector.reset(new GdbLibraryInjector);
#endif
		if (!injector->inject(targetPid, injectorLibPath(), "qtInspectorInit"))
		{
			return false;
		}
	}
	else
	{
#ifdef Q_OS_UNIX
		injector.reset(new PreloadInjector);
#endif
		QStringList programArgs;
		for (int i=2; i < args.count(); i++)
		{
			programArgs << args.at(i);
		}
		if (!injector->startAndInject(args.at(1),programArgs,injectorLibPath(),"qtInspectorInit",&targetPid))
		{
			return false;
		}
	}

	TargetApplicationProxy proxy;
	if (!proxy.connectToTarget(targetPid))
	{
		qWarning() << "Failed to inject helper library into process <pid>";
	}

	WidgetPicker* picker = new ExternalWidgetPicker(&proxy,0);

	WidgetInspector inspector(&proxy);
	inspector.setWidgetPicker(picker);
	inspector.show();

	int result = app.exec();

	if (process.state() == QProcess::Running && !process.waitForFinished())
	{
		qWarning() << "Failed to wait for process" << process.pid() << "to exit";
	}

	return result;
}
Пример #20
0
int main( int argc, char** argv )
{
    kvs::glut::Application app( argc, argv );
    Argument arg( app.argc(), app.argv() );
    p_arg = &arg;

    // for empty objects
    std::vector<kvs::Real32> coords;
    std::vector<kvs::UInt32> connections;
    std::vector<kvs::UInt8>  colors;
    std::vector<float>       values;
    std::vector<float>       eigenvalues;

    colors.push_back(255);
    colors.push_back(255);
    colors.push_back(255);
    for ( unsigned int i = 0; i < 3; i++ )
    {
        coords.push_back(0.0);
    }
    for ( unsigned int i = 0; i < 2; i ++ )
    {
        connections.push_back(0);
        values.push_back(0.0);
    }
    eigenvalues.push_back(0);

    // Volume 2 (Displacement)
    m_volume2 = new kvs::UnstructuredVolumeObject();
    m_volume2->setCellType( kvs::UnstructuredVolumeObject::Tetrahedra );
    m_volume2->setConnections( kvs::ValueArray<kvs::UInt32>( connections ) );
    m_volume2->setCoords( kvs::ValueArray<float>( coords ) );
    m_volume2->setValues( kvs::AnyValueArray( values ) );
    m_volume2->setNCells(0);
    m_volume2->setNNodes(0);

    // polygon (Empty External)
#ifdef WIN32
    std::string default_polygon( "D:\\Koron\\Dropbox\\Work\\Viz\\Hyperstreamline\\data\\engine\\v6engine_external_face.kvsml" );
#else
    std::string default_polygon( "../../data/engine/v6engine_external_face.kvsml" );
#endif
    if ( p_arg->hasOption( "polygon" ) )
    {
       kvs::PolygonObject* import_polygon = new kvs::PolygonImporter( p_arg->optionValue<std::string>("polygon") );
       m_polygon = new kvs::PolygonToPolygon( import_polygon );
    }
    else
    {
        kvs::PolygonObject* import_polygon = new kvs::PolygonImporter( default_polygon );
        m_polygon = new kvs::PolygonToPolygon( import_polygon );
    }

    if ( !m_polygon )
    {
        kvsMessageError( "Cannot create surface." );
        exit( EXIT_FAILURE );
    }
    m_polygon->setOpacity( opacity_polygon );
    m_polygon->setColor( kvs::RGBColor( 255,255,255 ) );

    const kvs::Vector3f min_coord = m_polygon->minExternalCoord();
    const kvs::Vector3f max_coord = m_polygon->maxExternalCoord();
    xmin = min_coord.x();
    ymin = min_coord.y();
    zmin = min_coord.z();
    xmax = max_coord.x();
    ymax = max_coord.y();
    zmax = max_coord.z();
    resx = 10;
    resy = 10;
    resz = 10;

    m_seed_point = new kvs::CubicPointObject();
    m_seed_point->reset_coordinates( resx, resy, resz, xmin, xmax, ymin, ymax, zmin, zmax );
    m_seed_point->updateMinMaxCoords();

    // streamlines (Empty LineObject)
    m_streamline = new kvs::HyperStreamline();
    m_streamline->setLineType( kvs::LineObject::Polyline );
    m_streamline->setColorType( kvs::LineObject::VertexColor );
    m_streamline->setCoords( kvs::ValueArray<kvs::Real32>( coords ) );
    m_streamline->setConnections( kvs::ValueArray<kvs::UInt32>( connections ) );
    m_streamline->setEigenValues( eigenvalues );
    m_streamline->setColors( kvs::ValueArray<kvs::UInt8>( colors ) );
    m_streamline->setSize( 1.0f );

    // main screen
    kvs::glut::Screen main_screen( &app );
    p_main_screen = &main_screen;
    //main_screen.background()->setColor( kvs::RGBAColor( 0, 0, 0, 1 ) );
    int interval = 30;
    kvs::glut::Timer timer( interval );
    TimerEvent timer_event;
    KeyPressEvent keypress_event;

    main_screen.addTimerEvent( &timer_event, &timer );
    main_screen.addKeyPressEvent( &keypress_event );
    main_screen.show();

    // renderer
#ifdef USE_KVS
    m_compositor = new kvs::glew::StochasticRenderingCompositor( &main_screen );
    m_compositor->enableLODControl();

    m_tfunc.adjustRange( m_volume2 );
    m_tfunc.setColorMap( kvs::RGBFormulae::AFMHot(256) );

    m_volume_renderer = new kvs::glew::StochasticTetrahedraEngine();
    m_volume_renderer->setTransferFunction( m_tfunc );
    m_volume_renderer->setShader( kvs::Shader::BlinnPhong() );
    m_volume_renderer->disableShading();
    m_volume_renderer->setEdgeSize( 2 );

    m_polygon_renderer = new kvs::glew::StochasticPolygonEngine();
    m_polygon_renderer->setShader( kvs::Shader::BlinnPhong() );
   
    m_point_renderer = new kvs::glew::StochasticPointEngine();
    m_point_renderer->disableShading();

    m_line_renderer = new kvs::glew::StochasticLineEngine();
    m_line_renderer->setShader( kvs::Shader::BlinnPhong() );
    m_line_renderer->setOpacity( opacity_line );

    m_compositor->registerObject( m_volume2, m_volume_renderer );
    m_compositor->registerObject( m_polygon, m_polygon_renderer );
    m_compositor->registerObject( m_seed_point, m_point_renderer );
    m_compositor->registerObject( m_streamline, m_line_renderer );
#else
    m_renderer = new kvs::glew::StochasticRenderer( 1 );
    m_renderer->enableLODControl();

    m_tfunc.adjustRange( m_volume2 );
    m_tfunc.setColorMap( kvs::RGBFormulae::AFMHot(256) );
    m_volume_renderer = new kvs::glew::StochasticVolumeRenderer( m_volume2 );
    m_volume_renderer->setTransferFunction( m_tfunc );
    m_volume_renderer->setShader( kvs::Shader::BlinnPhong() );
    m_volume_renderer->disableShading();
    m_volume_renderer->setEdgeSize( 2 );
    m_renderer->registerRenderer( m_volume_renderer );

    m_polygon_renderer = new kvs::glew::StochasticPolygonRenderer( m_polygon );
    m_polygon_renderer->setShader( kvs::Shader::BlinnPhong() );
    m_renderer->registerRenderer( m_polygon_renderer );

    m_point_renderer = new kvs::glew::StochasticPointRenderer( m_seed_point );
    m_point_renderer->disableShading();
    m_renderer->registerRenderer( m_point_renderer );

    m_line_renderer = new kvs::glew::StochasticLineRenderer( m_streamline );
    m_line_renderer->setShader( kvs::Shader::BlinnPhong() );
    m_line_renderer->setOpacity( opacity_line );
    m_renderer->registerRenderer( m_line_renderer );

    null = new::kvs::NullObject( m_seed_point );
    null->setName( "null" );
    main_screen.registerObject( null, m_renderer );
    main_screen.show();

#endif

    // tfunc editor
    //TransferFunctionEditor editor( &main_screen, m_renderer, m_volume_renderer );
    //editor.setVolumeObject( m_volume2 );
    //editor.show();


    //kvs::ControlScreen control_screen( &app );
    MouseMoveEvent mouse_move_event;
    kvs::glut::Screen control_screen( &app );
    //control_screen.addMouseMoveEvent( &mouse_move_event );
    control_screen.setMouseMoveEvent( &mouse_move_event );
    control_screen.setTitle( "kvs::ControlScreen" );
    control_screen.setGeometry( 512, 0, 600, 560 );

#ifdef USE_KVS
    //control_screen.attachMainScreen( p_main_screen, m_seed_point, m_compositor, m_point_renderer );
#else
    //control_screen.attachMainScreen( p_main_screen, m_seed_point, m_renderer, m_point_renderer );
#endif
    control_screen.show();

    PaintEvent paint_event;
    control_screen.addPaintEvent( &paint_event );

    const int width = control_screen.width();
    const int height = control_screen.height();
    const int ui_width = 240;

    PB_INFO pb_info( &control_screen );
    p_pb_info = &pb_info;
    pb_info.setX( width/6 );
    pb_info.setY( height - 40 );
    pb_info.setWidth( 400 );
    pb_info.setMargin( 5 );
    pb_info.setTextMargin( 5 );
    pb_info.setCaption("");
    //pb_info.deactivate();
    pb_info.show();


    PB00 pb00( &control_screen );
    p_pb00 = &pb00;
    pb00.setX( width - ui_width );
    pb00.setY( 10 );
    pb00.setWidth( 220 );
    pb00.setMargin( 5 );
    pb00.setTextMargin( 5 );
    pb00.setCaption("Read volume1(Stress)");
    pb00.show();

    PB01 pb01( &control_screen );
    p_pb01 = &pb01;
    pb01.setX( pb00.x() );
    pb01.setY( pb00.y() + pb00.height() );
    pb01.setWidth( 220 );
    pb01.setMargin( 5 );
    pb01.setTextMargin( 5 );
    pb01.setCaption("Read volume2(Displacement)");
    pb01.deactivate();
    pb01.show();

    PB02 pb02( &control_screen );
    p_pb02 = &pb02;
    pb02.setX( pb01.x() );
    pb02.setY( pb01.y() + pb01.height() );
    pb02.setWidth( 220 );
    pb02.setMargin( 5 );
    pb02.setTextMargin( 5 );
    pb02.setCaption("Hide Polygon");
    //pb02.deactivate();
    pb02.show();

    PB03 pb03( &control_screen );
    p_pb03 = &pb03;
    pb03.setX( pb02.x() );
    pb03.setY( pb02.y() + pb02.height() );
    pb03.setWidth( 220 );
    pb03.setMargin( 5 );
    pb03.setTextMargin( 5 );
    pb03.setCaption("Read CellTree(Optional)");
    //pb03.deactivate();
    pb03.show();

    SLD0 sld0( &control_screen );
    p_sld0 = &sld0;
    sld0.setX( pb03.x() );
    sld0.setY( pb03.y() + pb03.height() );
    sld0.setWidth( 220 );
    sld0.setMargin( 0 );
    sld0.setCaption("dx");
    //sld0.deactivate();
    sld0.show();

    SLD1 sld1( &control_screen );
    p_sld1 = &sld1;
    sld1.setX( sld0.x() );
    sld1.setY( sld0.y() + sld0.height() );
    sld1.setWidth( 220 );
    sld1.setMargin( 0 );
    sld1.setCaption("dy");
    //sld1.deactivate();
    sld1.show();

    SLD2 sld2( &control_screen );
    p_sld2 = &sld2;
    sld2.setX( sld1.x() );
    sld2.setY( sld1.y() + sld1.height() );
    sld2.setWidth( 220 );
    sld2.setMargin( 0 );
    sld2.setCaption("dz");
    //sld2.deactivate();
    sld2.show();

    SLD3 sld3( &control_screen );
    p_sld3 = &sld3;
    sld3.setX( sld2.x() );
    sld3.setY( sld2.y() + sld2.height() );
    sld3.setWidth( 220 );
    sld3.setMargin( 0 );
    sld3.setCaption("resx");
    //sld3.deactivate();
    sld3.show();

    SLD4 sld4( &control_screen );
    p_sld4 = &sld4;
    sld4.setX( sld3.x() );
    sld4.setY( sld3.y() + sld3.height() );
    sld4.setWidth( 220 );
    sld4.setMargin( 0 );
    sld4.setCaption("resy");
    //sld4.deactivate();
    sld4.show();

    SLD5 sld5( &control_screen );
    p_sld5 = &sld5;
    sld5.setX( sld4.x() );
    sld5.setY( sld4.y() + sld4.height() );
    sld5.setWidth( 220 );
    sld5.setMargin( 0 );
    sld5.setCaption("resz");
    //sld5.deactivate();
    sld5.show();

    PB04 pb04( &control_screen );
    p_pb04 = &pb04;
    pb04.setX( sld5.x() );
    pb04.setY( sld5.y() + sld5.height() );
    pb04.setWidth( 220 );
    pb04.setMargin( 15 );
    pb04.setTextMargin( 5 );
    pb04.setCaption("Update Streamline");
    //pb04.deactivate();
    pb04.show();

    PB05 pb05( &control_screen );
    p_pb05 = &pb05;
    pb05.setX( 10 );
    pb05.setY( pb04.y() + 10 );
    pb05.setWidth( 120 );
    pb05.setMargin( 5 );
    pb05.setTextMargin( 5 );
    pb05.setCaption("Buffer Line");
    //pb04.deactivate();
    pb05.show();

    PB06 pb06( &control_screen );
    p_pb06 = &pb06;
    pb06.setX( pb05.x() + pb05.width() );
    pb06.setY( pb05.y() );
    pb06.setWidth( 80 );
    pb06.setMargin( 5 );
    pb06.setTextMargin( 5 );
    pb06.setCaption("Clear");
    //pb04.deactivate();
    pb06.show();

    PB07 pb07( &control_screen );
    p_pb07 = &pb07;
    pb07.setX( pb06.x() + pb06.width() );
    pb07.setY( pb06.y() );
    pb07.setWidth( 160 );
    pb07.setMargin( 5 );
    pb07.setTextMargin( 5 );
    pb07.setCaption("Save CellTree.dat");
    //pb04.deactivate();
    pb07.show();

    RB00 rb00( &control_screen );
    rb00.setX( pb05.x() );
    rb00.setY( pb05.y() - pb05.height() );
    rb00.setWidth( 100 );
    rb00.setMargin( 15 );
    rb00.setCaption( "Principal" );
    rb00.setState( "true" );

    RB01 rb01( &control_screen );
    rb01.setX( rb00.x() + rb00.width() );
    rb01.setY( rb00.y() );
    rb01.setWidth( 130 );
    rb01.setMargin( 15 );
    rb01.setCaption( "Intermediate" );

    RB02 rb02( &control_screen );
    rb02.setX( rb01.x() + rb01.width() );
    rb02.setY( rb01.y() );
    rb02.setWidth( 100 );
    rb02.setMargin( 15 );
    rb02.setCaption( "Minor" );

    kvs::glut::RadioButtonGroup rbg0( &control_screen );
    rbg0.add( &rb00 );
    rbg0.add( &rb01 );
    rbg0.add( &rb02 );
    rbg0.show();

    CB00 cb00( &control_screen );
    cb00.setX( rb00.x() + rb00.width() );
    cb00.setY( rb00.y() - rb00.height() );
    cb00.setWidth( 100 );
    cb00.setMargin( 25 );
    cb00.setCaption( "Cache" );
    cb00.setState( true );
    cb00.show();

    kvs::ColorMap cmap;
    cmap.setRange( -127, 127 );
    cmap.create();

    kvs::glut::LegendBar legend_bar( &main_screen );
    legend_bar.setColorMap( cmap );
    legend_bar.show();

    return( app.run() );

}
Пример #21
0
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QCommandLineParser parser;
    parser.addPositionalArgument(QStringLiteral("WId"),
                                 QStringLiteral("window id for the window to take the icon from"),
                                 QStringLiteral("[WId]"));
    parser.addHelpOption();
    parser.process(app);

    QWidget window;
    QVBoxLayout *vbox = new QVBoxLayout(&window);

    bool ok = false;
    qulonglong id = parser.positionalArguments().first().toULongLong(&ok);
    if (!ok) {
        // try hex
        id = parser.positionalArguments().first().toULongLong(&ok, 16);
    }
    if (!ok) {
        return 1;
    }
    NETWinInfo info(QX11Info::connection(), id, QX11Info::appRootWindow(), NET::WMIcon, NET::WM2WindowClass | NET::WM2IconPixmap);
    auto addIcons = [&window, vbox, &id, &info] (const QString &name, int flag) {
        QLabel *title = new QLabel(name, &window);
        vbox->addWidget(title);
        QIcon icons;
        if (flag & KWindowSystem::NETWM) {
            const int *iconSizes = info.iconSizes();
            int index = 0;
            while (iconSizes[index] != 0 && iconSizes[index + 1] != 0) {
                const int width = iconSizes[index++];
                const int height = iconSizes[index++];
                NETIcon ni = info.icon(width, height);
                if (ni.data) {
                    QImage img((uchar *) ni.data, (int) ni.size.width, (int) ni.size.height, QImage::Format_ARGB32);
                    if (!img.isNull()) {
                        icons.addPixmap(QPixmap::fromImage(img));
                    }
                }
            }
        }

        if (flag & KWindowSystem::WMHints) {
            icons.addPixmap(KWindowSystem::icon(id, 0, 0, false, KWindowSystem::WMHints, &info));
        }

        if (flag & KWindowSystem::ClassHint) {
            icons = QIcon::fromTheme(QString::fromUtf8(info.windowClassClass()).toLower());
        }
        if (flag & KWindowSystem::XApp) {
            icons = QIcon::fromTheme(QLatin1String("xorg"));
        }
        if (icons.isNull()) {
            return;
        }
        QHBoxLayout *layout = new QHBoxLayout();
        const auto sizes = icons.availableSizes();
        for (auto it = sizes.begin(); it != sizes.end(); ++it) {
            const QSize &s = *it;
            QVBoxLayout *v = new QVBoxLayout();
            QLabel *l = new QLabel(QStringLiteral("%1/%2").arg(s.width()).arg(s.height()), &window);
            v->addWidget(l);
            QLabel *p = new QLabel(&window);
            p->setPixmap(icons.pixmap(s));
            v->addWidget(p);
            layout->addLayout(v);
        }
        vbox->addLayout(layout);
    };
    addIcons(QStringLiteral("NetWM"), KWindowSystem::NETWM);
    addIcons(QStringLiteral("WMHints"), KWindowSystem::WMHints);
    addIcons(QStringLiteral("ClassHint"), KWindowSystem::ClassHint);
    addIcons(QStringLiteral("XApp"), KWindowSystem::XApp);

    window.setLayout(vbox);
    window.show();

    return app.exec();
}
Пример #22
0
int main(int argc, char** argv)
{
	SC_TerminalClient app("sclang");
	return app.run(argc, argv);
}
Пример #23
0
int main(int argc, char* argv[])
{
#ifdef Q_OS_WIN
    _setmode(1, _O_BINARY);
    _setmode(2, _O_BINARY);
#endif

    // Suppress debug output from Qt if not started with -v
    bool suppressQtDebugOutput = true;
    for (int i = 1; i < argc; ++i) {
        if (!qstrcmp(argv[i], "-v")) {
            suppressQtDebugOutput = false;
            break;
        }
    }

    // Has to be done before QApplication is constructed in case
    // QApplication itself produces debug output.
    if (suppressQtDebugOutput)
        qInstallMessageHandler(messageHandler);

    WebKit::QtTestSupport::initializeTestFonts();

    QApplication::setStyle(QStyleFactory::create(QLatin1String("windows")));
    QApplication::setDesktopSettingsAware(false);

    QApplication app(argc, argv);
    app.setQuitOnLastWindowClosed(false);

    QCoreApplication::setAttribute(Qt::AA_Use96Dpi, true);

    WTFInstallReportBacktraceOnCrashHook();

    QStringList args = app.arguments();
    if (args.count() < (!suppressQtDebugOutput ? 3 : 2)) {
        printUsage();
        exit(1);
    }

    // Remove the first arguments, it is application name itself
    args.removeAt(0);

    DumpRenderTree dumper;

    int index = args.indexOf(QLatin1String("--stdout"));
    if (index != -1) {
        QString fileName = takeOptionValue(args, index);
        dumper.setRedirectOutputFileName(fileName);
        if (fileName.isEmpty() || !freopen(qPrintable(fileName), "w", stdout)) {
            fprintf(stderr, "STDOUT redirection failed.");
            exit(1);
        }
    }
    index = args.indexOf(QLatin1String("--stderr"));
    if (index != -1) {
        QString fileName = takeOptionValue(args, index);
        dumper.setRedirectErrorFileName(fileName);
        if (!freopen(qPrintable(fileName), "w", stderr)) {
            fprintf(stderr, "STDERR redirection failed.");
            exit(1);
        }
    }
    index = args.indexOf("--pixel-tests");
    if (index == -1)
        index = args.indexOf("-p");
    if (index != -1) {
        dumper.setShouldDumpPixelsForAllTests();
        args.removeAt(index);
    }

    QWebDatabase::removeAllDatabases();

    index = args.indexOf(QLatin1String("--timeout"));
    if (index != -1) {
        int timeout = takeOptionValue(args, index).toInt();
        dumper.setTimeout(timeout);
    }

    index = args.indexOf(QLatin1String("--no-timeout"));
    if (index != -1) {
        dumper.setShouldTimeout(false);
        args.removeAt(index);
    }

    index = args.indexOf(QLatin1String("-"));
    if (index != -1) {
        args.removeAt(index);

        // Continue waiting in STDIN for more test case after process one test case
        QObject::connect(&dumper, SIGNAL(ready()), &dumper, SLOT(readLine()), Qt::QueuedConnection);   

        // Read and only read the first test case, ignore the others 
        if (args.size() > 0) { 
            // Process the argument first
            dumper.processLine(args[0]);
        } else
           QTimer::singleShot(0, &dumper, SLOT(readLine()));
    } else {
        // Go into standalone mode
        // Standalone mode need at least one test case
        if (args.count() < 1) {
            printUsage();
            exit(1);
        }
        dumper.processArgsLine(args);
    }
    return app.exec();
}
Пример #24
0
QWidget *image_format_param_t::do_create_widgets()
{
    QWidget *top = new QWidget();

    menu_ = new QComboBox( top);
    QSize s = menu_->sizeHint();

    QLabel *label = new QLabel( top);
    label->move( 0, 0);
    label->resize( app().ui()->inspector().left_margin() - 5, s.height());
    label->setAlignment( Qt::AlignRight | Qt::AlignVCenter);
    label->setText( name().c_str());

    menu_->setFocusPolicy( Qt::NoFocus);

    for( int i = 0; i < image::format_t::presets().size(); ++i)
        menu_->addItem( image::format_t::presets()[i].first.c_str());

    menu_->addItem( "Custom");

    image::format_t format( get_value<image::format_t>( *this));

    menu_->move( app().ui()->inspector().left_margin(), 0);
    menu_->setCurrentIndex( format.preset_index());
    menu_->setEnabled( enabled());
    connect( menu_, SIGNAL( currentIndexChanged( int)), this, SLOT( preset_picked(int)));
    int h = s.height() + 5;

    width_input_ = new ui::double_spinbox_t( top);
    width_input_->setRange( 16, app().preferences().max_image_width());
    width_input_->setDecimals( 0);
    width_input_->setTrackMouse( false);
    width_input_->setValue( value().cast<image::format_t>().width);
    width_input_->move( app().ui()->inspector().left_margin(), h);
    width_input_->setMinimum( 16);
    width_input_->setValue( format.width);
    width_input_->setEnabled( enabled());
    connect( width_input_, SIGNAL( valueChanged( double)), this, SLOT( set_new_format( double)));
    s = width_input_->sizeHint();

    height_input_ = new ui::double_spinbox_t( top);
    height_input_->setRange( 16, app().preferences().max_image_height());
    height_input_->setDecimals( 0);
    height_input_->setValue( value().cast<image::format_t>().height);
    height_input_->setTrackMouse( false);
    height_input_->setEnabled( enabled());
    height_input_->move( app().ui()->inspector().left_margin() + s.width() + 5, h);
    height_input_->setMinimum( 16);
    height_input_->setValue( format.height);
    connect( height_input_, SIGNAL( valueChanged( double)), this, SLOT( set_new_format(double)));

    aspect_input_ = new ui::double_spinbox_t( top);
    aspect_input_->setValue( 1);
    aspect_input_->setTrackMouse( false);
    aspect_input_->setEnabled( enabled());
    aspect_input_->setValue( format.aspect);
    aspect_input_->setDecimals( 3);
    aspect_input_->setMinimum( 0.1);
    aspect_input_->setSingleStep( 0.05);
    aspect_input_->move( app().ui()->inspector().left_margin() + ( 2 * s.width()) + 10, h);
    connect( aspect_input_, SIGNAL( valueChanged( double)), this, SLOT( set_new_format(double)));
    h += s.height() + 5;

    int w = ( width_input_->sizeHint().width() * 2) + aspect_input_->sizeHint().width() + 10;
    menu_->resize( w, menu_->sizeHint().height());

    top->setMinimumSize( app().ui()->inspector().width(), h);
    top->setMaximumSize( app().ui()->inspector().width(), h);
    top->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed);
    return top;
}
Пример #25
0
main()
{
    QApplication app();
    QDBusConnection conn = QDBusConnection::systemBus();
}
Пример #26
0
std::wstring torrent_details::to_wstring(size_t index)
{
	switch (index)
	{
	case name_e: return name_;
	case state_e: return state_;

	case progress_e: return (wform(L"%1$.2f%%") % (completion_*100)).str(); 
	case speed_down_e: return to_bytes_size(speed_.first, true);
	case speed_up_e: return to_bytes_size(speed_.second, true);

	case distributed_copies_e: 
		{
		float copies = distributed_copies_;
		
		if (copies < 0)
			return L"Seeding"; 
		else
			return (hal::wform(L"%1$.2f") % copies).str();	
		}

	case remaining_e: 
		{
		return to_bytes_size(total_wanted_-total_wanted_done_, false); //(wform(L"%1$.2fMB") % (static_cast<float>()/(1024*1024))).str(); 
		}

	case completed_e: return to_bytes_size(total_wanted_done_, false); //(wform(L"%1$.2fMB") % (static_cast<float>(total_wanted_done_)/(1024*1024))).str();

	case total_wanted_e: 
		{
		return to_bytes_size(total_wanted_, false); //(wform(L"%1$.2fMB") % (static_cast<float>(total_wanted_)/(1024*1024))).str(); 
		}

	case uploaded_e: 
		{
		return to_bytes_size(total_payload_uploaded_, false); //(wform(L"%1$.2fMB") % (static_cast<float>(total_payload_uploaded_)/(1024*1024))).str(); 
		}

	case downloaded_e: 
		{
		return to_bytes_size(total_payload_downloaded_, false); //(wform(L"%1$.2fMB") % (static_cast<float>(total_payload_downloaded_)/(1024*1024))).str(); 
		}

	case peers_e: return (wform(L"%1% (%2%)") % connected_peers_ % peers_).str(); 
	case seeds_e: return (wform(L"%1% (%2%)") % connected_seeds_ % seeds_).str(); 

	case ratio_e: 
		{
			float ratio = (total_payload_downloaded_) 
				? static_cast<float>(total_payload_uploaded_)
					/ static_cast<float>(total_payload_downloaded_)
				: 0;
			
			return (wform(L"%1$.2f") % ratio).str(); 
		}

	case eta_e: 
		{ 
		if (!estimated_time_left_.is_special())
			return hal::from_utf8(
				boost::posix_time::to_simple_string(estimated_time_left_));
		else
			return app().res_wstr(HAL_INF);		
		}	

	case tracker: return currentTracker_;

	case update_tracker_in_e:		
		{ 
		if (!update_tracker_in_.is_special())
			return from_utf8(
				boost::posix_time::to_simple_string(update_tracker_in_));
		else
			return app().res_wstr(HAL_INF);		
		}	

	case active_time_e: 
		{
		if (!active_.is_special())
			return from_utf8(
				boost::posix_time::to_simple_string(active_));
		else
			return app().res_wstr(HAL_INF);		
		}

	case seeding_time_e: 
		{ 
		if (!seeding_.is_special())
			return from_utf8(
				boost::posix_time::to_simple_string(seeding_));
		else
			return app().res_wstr(HAL_INF);
		}	

	case start_time_e: 
		{ 
		if (!start_time_.is_special())
			return from_utf8(
				boost::posix_time::to_simple_string(start_time_));
		else
			return app().res_wstr(IDS_NA);
		}		

	case finish_time_e: 		
		{ 
		if (!finish_time_.is_special())
			return from_utf8(
				boost::posix_time::to_simple_string(finish_time_));
		else
			return app().res_wstr(IDS_NA);	
		}		

	case queue_position_e: 
		{
			if (queue_position_ != -1)
				return (wform(L"%1%") % queue_position_).str(); 
			else
				return app().res_wstr(IDS_NA);		
		}

	case managed_e: return managed_ ?  L"Yes" : L"No";

	case uuid_e: 
		{
			std::wstringstream ss;
			ss << uuid_;

			return ss.str();
		}
		
	case hash_e: return hash_;

	default: return L"(Undefined)"; // ???
	};
}
Пример #27
0
int main(int argc, char* argv[])
{
#ifdef Q_WS_X11
    FcInit();
    FcConfig *config = FcConfigCreate();
    QByteArray fontDir = getenv("WEBKIT_TESTFONTS");
    if (fontDir.isEmpty() || !QDir(fontDir).exists()) {
        fprintf(stderr,
                "\n\n"
                "--------------------------------------------------------------------\n"
                "WEBKIT_TESTFONTS environment variable is not set correctly.\n"
                "This variable has to point to the directory containing the fonts\n"
                "you can checkout from svn://labs.trolltech.com/svn/webkit/testfonts\n"
                "--------------------------------------------------------------------\n"
);
        exit(1);
    }
    char currentPath[PATH_MAX+1];
    getcwd(currentPath, PATH_MAX);
    QByteArray configFile = currentPath;
    configFile += "/WebKitTools/DumpRenderTree/qt/fonts.conf";
    if (!FcConfigParseAndLoad (config, (FcChar8*) configFile.data(), true))
        qFatal("Couldn't load font configuration file");
    if (!FcConfigAppFontAddDir (config, (FcChar8*) fontDir.data()))
        qFatal("Couldn't add font dir!");
    FcConfigSetCurrent(config);
#endif
    QApplication app(argc, argv);
#ifdef Q_WS_X11
    QX11Info::setAppDpiY(0, 96);
    QX11Info::setAppDpiX(0, 96);
#endif

    QFont f("Sans Serif");
    f.setPointSize(9);
    f.setWeight(QFont::Normal);
    f.setStyle(QFont::StyleNormal);
    app.setFont(f);
    app.setStyle(QLatin1String("Plastique"));


    signal(SIGILL, crashHandler);    /* 4:   illegal instruction (not reset when caught) */
    signal(SIGTRAP, crashHandler);   /* 5:   trace trap (not reset when caught) */
    signal(SIGFPE, crashHandler);    /* 8:   floating point exception */
    signal(SIGBUS, crashHandler);    /* 10:  bus error */
    signal(SIGSEGV, crashHandler);   /* 11:  segmentation violation */
    signal(SIGSYS, crashHandler);    /* 12:  bad argument to system call */
    signal(SIGPIPE, crashHandler);   /* 13:  write on a pipe with no reader */
    signal(SIGXCPU, crashHandler);   /* 24:  exceeded CPU time limit */
    signal(SIGXFSZ, crashHandler);   /* 25:  exceeded file size limit */

    QStringList args = app.arguments();
    if (args.count() < 2) {
        qDebug() << "Usage: DumpRenderTree [-v] filename";
        exit(0);
    }

    // supress debug output from Qt if not started with -v
    if (!args.contains(QLatin1String("-v")))
        qInstallMsgHandler(messageHandler);

    WebCore::DumpRenderTree dumper;

    if (args.last() == QLatin1String("-")) {
        dumper.open();
    } else {
        if (!args.last().startsWith("/")
            && !args.last().startsWith("file:")
            && !args.last().startsWith("http:")
            && !args.last().startsWith("https:")) {
            QString path = QDir::currentPath();
            if (!path.endsWith('/'))
                path.append('/');
            args.last().prepend(path);
        }
        dumper.open(QUrl(args.last()));
    }
    return app.exec();
#ifdef Q_WS_X11
    FcConfigSetCurrent(0);
#endif
}
Пример #28
0
int main(int argc, char *argv[])
{

#if RUBY_API_VERSION_MAJOR && RUBY_API_VERSION_MAJOR==2
  ruby_sysinit(&argc, &argv);
  {
    RUBY_INIT_STACK;
    ruby_init();
  }
#endif


#if _DEBUG || (__GNUC__ && !NDEBUG)
  openstudio::Logger::instance().standardOutLogger().setLogLevel(Debug);
  openstudio::FileLogSink fileLog(openstudio::toPath(logfilepath));
  fileLog.setLogLevel(Debug);
#else
  openstudio::Logger::instance().standardOutLogger().setLogLevel(Warn);
#endif

  bool cont = true;
  while(cont) {
    cont = false;



    std::vector<std::string> modules;
    modules.push_back("openstudioutilitiescore");
    modules.push_back("openstudioutilitiesbcl");
    modules.push_back("openstudioutilitiesidd");
    modules.push_back("openstudioutilitiesidf");
    modules.push_back("openstudioutilities");
    modules.push_back("openstudiomodel");
    modules.push_back("openstudiomodelcore");
    modules.push_back("openstudiomodelsimulation");
    modules.push_back("openstudiomodelresources");
    modules.push_back("openstudiomodelgeometry");
    modules.push_back("openstudiomodelhvac");
    modules.push_back("openstudioenergyplus");
    modules.push_back("openstudioruleset");

    //try {
    // Initialize the embedded Ruby interpreter
    boost::shared_ptr<openstudio::detail::RubyInterpreter> rubyInterpreter(
        new openstudio::detail::RubyInterpreter(openstudio::getOpenStudioRubyPath(),
          openstudio::getOpenStudioRubyScriptsPath(),
          modules));

    // Initialize the argument getter
    QSharedPointer<openstudio::ruleset::RubyUserScriptArgumentGetter> argumentGetter(
        new openstudio::ruleset::detail::RubyUserScriptArgumentGetter_Impl<openstudio::detail::RubyInterpreter>(rubyInterpreter));

    openstudio::OpenStudioApp app(argc, argv, argumentGetter);
    openstudio::Application::instance().setApplication(&app);

    try {
      return app.exec();
    } catch (const std::exception &e) {
      LOG_FREE(Fatal, "OpenStudio", "An unhandled exception has occurred: " << e.what());
      cont = true;
      QMessageBox msgBox;
      msgBox.setWindowTitle("Unhandled Exception");
      msgBox.setIcon(QMessageBox::Critical);
      msgBox.setText("An unhandled exception has occurred.");
      msgBox.setInformativeText(e.what());
      msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
      msgBox.button(QMessageBox::Retry)->setText("Relaunch");
      if (msgBox.exec() == QMessageBox::Close) {
        cont = false;
      }
    } catch (...) {
      LOG_FREE(Fatal, "OpenStudio", "An unknown exception has occurred.");
      cont = true;
      QMessageBox msgBox;
      msgBox.setWindowTitle("Unknown Exception");
      msgBox.setIcon(QMessageBox::Critical);
      msgBox.setText("An unknown exception has occurred.");
      msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
      msgBox.button(QMessageBox::Retry)->setText("Relaunch");
      if (msgBox.exec() == QMessageBox::Close) {
        cont = false;
      }
    }
  }
}
Пример #29
0
/*
  Iterates over pages of labelsets in shadow memory.
  Applies app(pa, page), where pa is base address of the page in guest
  physical memory and "page" is a pointer to the SdPage struct for that
  shadow page.
  "stuff2" is a ptr to something the app fn needs
*/
static SB_INLINE void __shad_dir_page_iter_64
     (SdDir64 *shad_dir,
      int (*app)(uint64_t pa, SdPage *page, void *stuff1),
      void *stuff2) {
  SD_PAGE_ITER(
	  { int iter_finished;
	    iter_finished =
	      app(page_base_addr, page, stuff2);
	    if (iter_finished != 0) return; }
	   )
}


/*
  iterates over every entry in every page in shad_dir.
  calls app on every (addr, labelset) pair within every page
  app should return 0 if iteration is to continue.
  "stuff2" is a ptr to something the app fn needs
*/
void shad_dir_iter_64
     (SdDir64 *shad_dir,
      int (*app)(uint64_t addr, LabelSet *labels, void *stuff1),
      void *stuff2) {
Пример #30
0
void time_controls_t::set_autokey( bool b)
{
	app().document().composition().set_autokey( b);
}