本文整理汇总了C++中GlMainWidget::centerScene方法的典型用法代码示例。如果您正苦于以下问题:C++ GlMainWidget::centerScene方法的具体用法?C++ GlMainWidget::centerScene怎么用?C++ GlMainWidget::centerScene使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlMainWidget
的用法示例。
在下文中一共展示了GlMainWidget::centerScene方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
// A QApplication must always be declared at the beginning of the main function if you intend to
// use the tulip-gui library
// This must be done before calling tlp::initTulipSoftware()
QApplication app(argc, argv);
// Initialize the library and load all plugins
tlp::initTulipSoftware();
Graph *g = nullptr;
if (QApplication::arguments().size() == 2) {
// Load the file passed as first argument into a graph.
// This method will select the default Tulip algorithm plugin (TLP)
QString filename = QApplication::arguments()[1];
if (!((filename.endsWith(".tlp")) || (filename.endsWith(".tlp.gz")))) {
cout << "File " << QStringToTlpString(filename)
<< " not compatible. Use a tlp file or a tlp.gz file" << endl;
exit(EXIT_FAILURE);
}
g = tlp::loadGraph(QStringToTlpString(filename));
} else {
// If no arguments were given to the command, create a complete tree of depth 5
// and degree 2 for demo purpose
g = createCompleteTree(5, 2);
// Set some visual properties in order to visualize the tree
setTreeVisualProperties(g);
}
// Creates the main widget that will display our graph
GlMainWidget *mainWidget = new GlMainWidget(nullptr);
// Adds a layer to the scene
GlLayer *mainLayer = mainWidget->getScene()->createLayer("Main");
// Adds the graph to this layer
mainLayer->addGraph(g, "graph");
// Sets some rendering parameters on the graph to visualize
setGraphRenderingParameters(mainWidget->getScene()->getGlGraphComposite());
// Display the widget
mainWidget->show();
// Flush event loop in order to let paint events pass through in order for the scene to be
// initialized.
QApplication::processEvents();
// Center the camera and draw the graph
mainWidget->centerScene();
mainWidget->draw();
// Adds Zoom and pan navigation to the widget
mainWidget->installEventFilter(new MouseNKeysNavigator);
return app.exec();
}
示例2: main
int main(int argc, char **argv) {
/*
A QApplication must always be declared at the beginning of the main function in order for Tulip to work.
This must be done before calling tlp::initTulipSoftware()
*/
QApplication app(argc, argv);
/*
Initialize the library, load plugins and set application runtime pathes accordingly to the host
operating system
This method should always be called if you intend to use plugins in your application.
*/
tlp::initTulipSoftware();
/*
Load the file passed as first argument into a graph.
This method will select the default Tulip algorithm plugin (TLP)
*/
// Graph* g = tlp::loadGraph(argv[1]);
Graph *g = newGraph();
TulipProject *_project = TulipProject::openProject(QString::fromLatin1(argv[1]));
// std::cout << QString::fromLatin1(argv[1]) << std::endl;
if (_project->exists("/data/graphs/0/graph.tlp")) {
std::cout << "pouet pouet" << std::endl;
DataSet data;
data.set<std::string>("file::filename",
QStringToTlpString(_project->toAbsolutePath("/data/graphs/0/graph.tlp")));
g = tlp::importGraph("TLP Import", data);
std::cout << g << std::endl;
}
// Creates the main widget that will display our graph
GlMainWidget *mainWidget = new GlMainWidget();
// Adds a layer to the scene
GlLayer *mainLayer = mainWidget->getScene()->createLayer("Main");
// Adds the graph to this layer
mainLayer->addGraph(g, "graph");
// Display the widget
mainWidget->show();
// Flush event loop in order to let paint events pass through in order for the scene to be
// initialized.
QApplication::processEvents();
// Center the camera and draw the graph
mainWidget->centerScene();
mainWidget->draw();
// Adds Zoom and pan navigation to the widget
mainWidget->installEventFilter(new MouseNKeysNavigator);
return app.exec();
}
示例3: main
int main(int argc, char **argv) {
/*
A QApplication must always be declared at the beginning of the main function in order for Tulip to work.
This must be done before calling tlp::initTulipSoftware()
*/
QApplication app(argc, argv);
/*
Initialize the library, load plugins and set application runtime pathes accordingly to the host
operating system
This method should always be called if you intend to use plugins in your application.
*/
tlp::initTulipSoftware();
// Creates the main widget that will display our graph
GlMainWidget *mainWidget = new GlMainWidget();
// Adds a layer to the scene
GlLayer *mainLayer = mainWidget->getScene()->createLayer("Main");
Coord center1(-1, -1, -1);
Coord center2(1, 1, 1);
Size size(1, 1, 1);
Color whiteOpaque(255, 255, 255, 255);
Color blackOpaque(0, 0, 0, 255);
GlBox *node1 = new GlBox(center1, size, whiteOpaque, blackOpaque);
GlBox *node2 = new GlBox(center2, size, whiteOpaque, blackOpaque);
mainLayer->addGlEntity(node1, "Gl Tutorial 1: Node 1");
mainLayer->addGlEntity(node2, "Gl Tutorial 1: Node 2");
Coord centerBox(0, 0, 0);
Size sizeBox(3.001, 3.001, 3.001);
Color purpleTrans(155, 0, 155, 50);
GlBox *box = new GlBox(centerBox, sizeBox, purpleTrans, blackOpaque);
mainLayer->addGlEntity(box, "Gl Tutorial 2: Box");
// Display the widget
mainWidget->show();
// Flush event loop in order to let paint events pass through in order for the scene to be
// initialized.
QApplication::processEvents();
// Center the camera and draw the graph
mainWidget->centerScene();
mainWidget->draw();
// Adds Zoom and pan navigation to the widget
mainWidget->installEventFilter(new MouseNKeysNavigator);
return app.exec();
}