void RendererImplementationBase3D::activate(t_QVTKWidget & qvtkWidget) { RendererImplementation::activate(qvtkWidget); initialize(); // make sure to reuse the existing render window interactor m_renderWindow->SetInteractor(qvtkWidget.GetInteractorBase()); // pass my render window to the qvtkWidget qvtkWidget.SetRenderWindow(m_renderWindow); qvtkWidget.GetInteractorBase()->SetInteractorStyle(m_interactorStyle); assignInteractor(); m_cursorCallback->setQWidget(&qvtkWidget); renderView().setInfoTextCallback([this] () -> QString { m_pickerHighlighter->requestPickedInfoUpdate(); return m_pickerHighlighter->pickedInfo(); }); updateAxisLabelFormat(renderView().currentCoordinateSystem()); }
/* Create a new resource in the database */ static void createPost() { if (updateRec(createRec("post", params()))) { flash("inform", "New post Created"); renderView("post/post-list"); } else { flash("error", "Cannot Create Post"); renderView("post/post-edit"); } }
void Scene::updatePos() { for (MovingObject *object: movingObjects_) { object->updatePos(); } update(); emit renderView(); }
void RendererImplementationBase3D::applyCurrentCoordinateSystem(const CoordinateSystemSpecification & spec) { const auto contents = renderView().visualizations(); for (auto visualization : contents) { auto rendered = static_cast<RenderedData *>(visualization); rendered->setDefaultCoordinateSystem(spec); } updateAxisLabelFormat(spec); updateBounds(); for (unsigned int i = 0; i < renderView().numberOfSubViews(); ++i) { resetCamera(true, i); } }
std::unique_ptr<AbstractVisualizedData> RendererImplementationBase3D::requestVisualization(DataObject & dataObject) const { auto rendered = dataObject.createRendered(); const auto & coordinateSystem = renderView().currentCoordinateSystem(); if (coordinateSystem.isValid()) { rendered->setDefaultCoordinateSystem(coordinateSystem); } return std::move(rendered); }
void renderMap() { //Set up sample colours, and output shadings const WORD colors[] = { 0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F, 0xA1, 0xB2, 0xC3, 0xD4, 0xE5, 0xF6 }; //Render what the parts of the map the camera can see. renderView(); }
/* Update an existing resource in the database If "id" is not defined, this is the same as a create Also we tunnel delete here if the user clicked delete */ static void updatePost() { if (smatch(param("submit"), "Delete")) { removePost(); } else { if (updateFields("post", params())) { flash("inform", "Post Updated Successfully"); redirect("list"); } else { flash("error", "Cannot Update Post"); renderView("post/post-edit"); } } }
void RendererImplementationBase3D::updateAxisLabelFormat(const CoordinateSystemSpecification & spec) { static const auto degreeLabel = (QString("%g") + QChar(0x00B0)).toUtf8(); const auto label = spec.type == CoordinateSystemType::geographic ? degreeLabel // latitude/longitude : "%g km"; // Northing/Easting for (unsigned i = 0; i < renderView().numberOfSubViews(); ++i) { auto axes = axesActor(i); axes->SetPrintfAxisLabelFormat(0, label.data()); axes->SetPrintfAxisLabelFormat(1, label.data()); } }
/*! \~english Renders the template of the action \a action with the layout \a layout. \~japanese レイアウト \a layout を適用し、アクション \a action のテンプレートを描画する */ bool TActionController::render(const QString &action, const QString &layout) { T_TRACEFUNC(""); if (rendered) { tWarn("Has rendered already: %s", qPrintable(className() + '#' + activeAction())); return false; } rendered = true; // Creates view-object and displays it TDispatcher<TActionView> viewDispatcher(viewClassName(action)); setLayout(layout); response.setBody(renderView(viewDispatcher.object())); return !response.isBodyNull(); }
/*! \~english Renders the text \a text with the layout \a layout. \~japanese レイアウト \a layout を適用し、テキストを描画する */ bool TActionController::renderText(const QString &text, bool layoutEnable, const QString &layout) { T_TRACEFUNC(""); if (rendered) { tWarn("Has rendered already: %s", qPrintable(className() + '#' + activeAction())); return false; } rendered = true; // Creates TTextView object and displays it setLayout(layout); setLayoutEnabled(layoutEnable); TTextView *view = new TTextView(text); response.setBody(renderView(view)); delete view; return (!response.isBodyNull()); }
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr TSDFVolumeOctree::renderColoredView (const Eigen::Affine3d& trans, int downsampleBy) const { pcl::PointCloud<pcl::PointNormal>::Ptr grayscale = renderView (trans, downsampleBy); pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr colored (new pcl::PointCloud<pcl::PointXYZRGBNormal> (grayscale->width, grayscale->height)); colored->is_dense = false; #pragma omp parallel for for (size_t i = 0; i < colored->size(); ++i) { pcl::PointXYZRGBNormal& pt = colored->at(i); pt.getVector3fMap() = grayscale->at(i).getVector3fMap(); pt.getNormalVector3fMap() = grayscale->at(i).getNormalVector3fMap(); if (pcl_isnan (pt.z)) continue; Eigen::Vector3f v_t = trans.cast<float> () * pt.getVector3fMap(); const OctreeNode* voxel = octree_->getContainingVoxel (v_t (0), v_t (1), v_t (2)); if (!voxel) continue; voxel->getRGB (pt.r, pt.g, pt.b); } return (colored); }
void RendererImplementationBase3D::dataVisibilityChanged(RenderedData * rendered, unsigned int subViewIndex) { assert(rendered); if (rendered->isVisible()) { addToBounds(rendered, subViewIndex); connect(&rendered->dataObject(), &DataObject::boundsChanged, this, &RendererImplementationBase3D::updateBounds); } else { removeFromBounds(rendered, subViewIndex); disconnect(&rendered->dataObject(), &DataObject::boundsChanged, this, &RendererImplementationBase3D::updateBounds); } // If the object is currently removed, it's not yet removed from the list const auto && currentObjects = renderView().dataObjects(); const bool isEmpty = currentObjects.isEmpty() || (!rendered->isVisible() && currentObjects.size() == 1 && currentObjects.front() == &rendered->dataObject()); m_pickerHighlighter->SetEnabled(!isEmpty); if (rendered->isVisible()) { // If there isn't any selected target and rendered is visible, use rendered as the currently // active object. This is the one the user most recently worked with. if (!selection().visualization) { m_renderView.setVisualizationSelection(VisualizationSelection(rendered)); } } else if (selection().visualization == rendered) { // If the current object is selected but not visible anymore, clear the selection m_renderView.clearSelection(); } onDataVisibilityChanged(rendered, subViewIndex); renderer(subViewIndex)->ResetCamera(); }
/*! \~english Renders the template given by \a templateName with the layout \a layout. \~japanese レイアウト \a layout を適用し、テンプレート \a templateName を描画する */ bool TActionController::renderTemplate(const QString &templateName, const QString &layout) { T_TRACEFUNC(""); if (rendered) { tWarn("Has rendered already: %s", qPrintable(className() + '#' + activeAction())); return false; } rendered = true; // Creates view-object and displays it QStringList names = templateName.split("/"); if (names.count() != 2) { tError("Invalid patameter: %s", qPrintable(templateName)); return false; } TDispatcher<TActionView> viewDispatcher(viewClassName(names[0], names[1])); setLayout(layout); response.setBody(renderView(viewDispatcher.object())); return (!response.isBodyNull()); }
void RendererImplementationBase3D::initialize() { if (m_isInitialized) { return; } // -- lights -- m_lightKit = vtkSmartPointer<vtkLightKit>::New(); m_lightKit->SetKeyLightIntensity(1.0); // -- render (window) -- m_renderWindow = vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New(); m_viewportSetups.resize(renderView().numberOfSubViews()); for (unsigned int subViewIndex = 0; subViewIndex < renderView().numberOfSubViews(); ++subViewIndex) { auto & viewport = m_viewportSetups[subViewIndex]; auto renderer = vtkSmartPointer<vtkRenderer>::New(); renderer->SetBackground(1, 1, 1); renderer->RemoveAllLights(); m_lightKit->AddLightsToRenderer(renderer); viewport.renderer = renderer; m_renderWindow->AddRenderer(renderer); auto titleWidget = vtkSmartPointer<vtkTextWidget>::New(); viewport.titleWidget = titleWidget; titleWidget->SetDefaultRenderer(viewport.renderer); titleWidget->SetCurrentRenderer(viewport.renderer); auto titleRepr = vtkSmartPointer<vtkTextRepresentation>::New(); auto titleActor = titleRepr->GetTextActor(); titleActor->GetTextProperty()->SetColor(0, 0, 0); titleActor->GetTextProperty()->SetVerticalJustificationToTop(); FontHelper::configureTextProperty(*titleActor->GetTextProperty()); titleRepr->GetPositionCoordinate()->SetValue(0.2, .85); titleRepr->GetPosition2Coordinate()->SetValue(0.6, .10); titleRepr->GetBorderProperty()->SetColor(0.2, 0.2, 0.2); titleWidget->SetRepresentation(titleRepr); titleWidget->SetTextActor(titleActor); titleWidget->SelectableOff(); viewport.axesActor = createAxes(); renderer->AddViewProp(viewport.axesActor); } // -- interaction -- m_interactorStyle = vtkSmartPointer<CameraInteractorStyleSwitch>::New(); m_interactorStyle->SetCurrentRenderer(m_viewportSetups.front().renderer); m_interactorStyle->addStyle("InteractorStyleTerrain", vtkSmartPointer<InteractorStyleTerrain>::New()); m_interactorStyle->addStyle("InteractorStyleImage", vtkSmartPointer<InteractorStyleImage>::New()); // correctly show axes and labels based on the interaction style and resulting camera setup m_interactorStyle->AddObserver(InteractorStyleSwitch::StyleChangedEvent, this, &RendererImplementationBase3D::updateAxes); m_pickerHighlighter = vtkSmartPointer<PickerHighlighterInteractorObserver>::New(); connect(m_pickerHighlighter, &PickerHighlighterInteractorObserver::pickedInfoChanged, &m_renderView, &AbstractRenderView::showInfoText); connect(m_pickerHighlighter, &PickerHighlighterInteractorObserver::dataPicked, [this] (const VisualizationSelection & selection) { if (selection.isEmpty()) { m_renderView.clearSelection(); } else { m_renderView.setVisualizationSelection(selection); } }); connect(m_pickerHighlighter, &PickerHighlighterInteractorObserver::geometryChanged, this, &RendererImplementation::render); m_cursorCallback = std::make_unique<RenderWindowCursorCallback>(); m_cursorCallback->setRenderWindow(m_renderWindow); m_isInitialized = true; }
/* List the resources in this group */ static void listPost() { renderView("post/post-list"); }
/* Initialize a new resource for the client to complete */ static void initPost() { httpTrace(getConn(), "INIT POST", "context", NULL); createRec("post", 0); httpTrace(getConn(), "RENDER VIEW", "context", NULL); renderView("post/post-edit"); }
int main(int argc, char **argv) { QString fileName{ "C:/develop/$sync/GFZ/data/VTK XML data/Volcano 2 topo.vtp" }; auto data = Loader::readFile(fileName); QApplication app(argc, argv); QMainWindow window; window.show(); DataSetHandler dataSetHandler; DataMapping dataMapping(dataSetHandler); RenderView renderView(dataMapping, -1); window.addDockWidget(Qt::TopDockWidgetArea, renderView.dockWidgetParent()); app.setActiveWindow(&renderView); RenderConfigWidget renderConfig; renderConfig.setCurrentRenderView(&renderView); renderConfig.show(); RendererConfigWidget rendererConfig; rendererConfig.setCurrentRenderView(&renderView); rendererConfig.show(); ColorMappingChooser colorMapping; colorMapping.setCurrentRenderView(&renderView); colorMapping.show(); GlyphMappingChooser glyphs; glyphs.setCurrentRenderView(&renderView); glyphs.show(); QPushButton button; button.connect(&button, &QPushButton::clicked, [&renderView, &data] (){ QList<DataObject *> incomp; renderView.showDataObjects({ data.get() }, incomp); }); button.show(); QPushButton exitButton("quit"); exitButton.connect(&exitButton, &QPushButton::clicked, &app, &QApplication::quit); exitButton.show(); return app.exec(); /*auto renderer = vtkSmartPointer<vtkRenderer>::New(); renderer->SetBackground(0.7, 0.7, 0.7); QScopedPointer<RenderedData> rendered{ data->createRendered() }; rendered->viewProps()->InitTraversal(); while (auto && it = rendered->viewProps()->GetNextProp()) { renderer->AddViewProp(it); } auto renderWindow = vtkSmartPointer<vtkRenderWindow>::New(); renderWindow->AddRenderer(renderer); auto rwInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New(); rwInteractor->SetRenderWindow(renderWindow); rwInteractor->Start(); return 0;*/ }
/* Get a resource */ static void getPost() { readRec("post", param("id")); renderView("post/post-edit"); }
//=========================================================================== bool cViewport::render() { lastActiveViewport = this; bool result = renderView(); return (result); }