mirror of
https://github.com/OpenFOAM/ThirdParty-6.git
synced 2025-12-08 06:57:43 +00:00
ParaView-5.0.1: Added the source-tree to ThirdParty-dev and patched as described in the README file
Resolves bug-report http://bugs.openfoam.org/view.php?id=2098
This commit is contained in:
@ -0,0 +1,85 @@
|
||||
cmake_minimum_required(VERSION 2.8.8)
|
||||
if(POLICY CMP0020)
|
||||
cmake_policy(SET CMP0020 NEW)
|
||||
endif()
|
||||
if(POLICY CMP0025)
|
||||
cmake_policy(SET CMP0025 NEW) # CMake 3.0
|
||||
endif()
|
||||
if(POLICY CMP0043)
|
||||
cmake_policy(SET CMP0043 NEW) # CMake 3.0
|
||||
endif()
|
||||
if(POLICY CMP0053)
|
||||
cmake_policy(SET CMP0053 NEW) # CMake 3.1
|
||||
endif()
|
||||
project( GraphicsView )
|
||||
|
||||
find_package(OpenGL)
|
||||
|
||||
find_package(VTK COMPONENTS
|
||||
vtkCommonCore
|
||||
vtkGUISupportQt
|
||||
vtkGUISupportQtOpenGL
|
||||
vtkIOInfovis
|
||||
vtkViewsInfovis
|
||||
)
|
||||
include(${VTK_USE_FILE})
|
||||
|
||||
if("${VTK_QT_VERSION}" STREQUAL "")
|
||||
message(FATAL_ERROR "VTK was not built with Qt")
|
||||
endif()
|
||||
|
||||
set( Srcs
|
||||
main.cpp
|
||||
OpenGLScene.cpp
|
||||
TreeRingViewItem.cpp
|
||||
GraphLayoutViewItem.cpp
|
||||
WebView.cpp
|
||||
)
|
||||
|
||||
set( Hdrs
|
||||
GraphicsView.hpp
|
||||
OpenGLScene.hpp
|
||||
QBoolAnimation.h
|
||||
TreeRingViewItem.h
|
||||
GraphLayoutViewItem.h
|
||||
WebView.h
|
||||
)
|
||||
|
||||
set( MOC_Hdrs
|
||||
OpenGLScene.hpp
|
||||
QBoolAnimation.h
|
||||
WebView.h
|
||||
)
|
||||
|
||||
set( QRCs
|
||||
GraphicsView.qrc
|
||||
)
|
||||
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
if(VTK_QT_VERSION VERSION_GREATER "4")
|
||||
find_package(Qt5 COMPONENTS WebKitWidgets REQUIRED QUIET)
|
||||
|
||||
qt5_add_resources(QRC_Srcs ${QRCs} )
|
||||
|
||||
add_executable(qtgraphicsview MACOSX_BUNDLE
|
||||
${Srcs} ${Hdrs} ${MOC_Hdrs} ${QRC_Srcs})
|
||||
qt5_use_modules(qtgraphicsview Core Gui Widgets
|
||||
WebKit WebKitWidgets OpenGL OpenGLExtensions)
|
||||
target_link_libraries(qtgraphicsview ${VTK_LIBRARIES})
|
||||
else()
|
||||
find_package(Qt4 REQUIRED)
|
||||
set(QT_USE_QTOPENGL 1)
|
||||
set(QT_USE_QTWEBKIT 1)
|
||||
include(${QT_USE_FILE})
|
||||
if (NOT QT_QTWEBKIT_FOUND OR QT_VERSION_MINOR LESS 6)
|
||||
message(STATUS "VTK isn't configured to use QtOpenGL, QtWebKit wasn't found, or Qt 4.6 wasn't found. GraphicsView example is disabled.")
|
||||
else()
|
||||
qt4_add_resources(QRC_Srcs ${QRCs})
|
||||
qt4_wrap_cpp(MOC_Srcs ${MOC_Hdrs})
|
||||
|
||||
add_executable(qtgraphicsview ${Srcs} ${Hdrs} ${MOC_Hdrs} ${QRC_Srcs})
|
||||
target_link_libraries(qtgraphicsview ${QT_LIBRARIES} ${VTK_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
@ -0,0 +1,83 @@
|
||||
|
||||
#include "GraphLayoutViewItem.h"
|
||||
#include "vtkGraphLayoutView.h"
|
||||
#include "vtkGenericOpenGLRenderWindow.h"
|
||||
#include "QVTKInteractor.h"
|
||||
#include "vtkXMLTreeReader.h"
|
||||
#include "vtkRenderedTreeAreaRepresentation.h"
|
||||
#include "vtkStringArray.h"
|
||||
#include "vtkIdTypeArray.h"
|
||||
#include "vtkDataSetAttributes.h"
|
||||
#include "vtkRenderedGraphRepresentation.h"
|
||||
#include "vtkStringToNumeric.h"
|
||||
#include "vtkViewTheme.h"
|
||||
#include "vtkTextProperty.h"
|
||||
#include <QFile>
|
||||
|
||||
GraphLayoutViewItem::GraphLayoutViewItem(QGLContext* ctx, QGraphicsItem* p)
|
||||
: QVTKGraphicsItem(ctx, p)
|
||||
{
|
||||
GraphLayoutView.TakeReference(vtkGraphLayoutView::New());
|
||||
GraphLayoutView->SetRenderWindow(this->GetRenderWindow());
|
||||
|
||||
QFile f1(":/Data/treetest.xml");
|
||||
f1.open(QIODevice::ReadOnly);
|
||||
QByteArray f1_data = f1.readAll();
|
||||
|
||||
vtkSmartPointer<vtkXMLTreeReader> reader = vtkSmartPointer<vtkXMLTreeReader>::New();
|
||||
reader->SetXMLString(f1_data.data());
|
||||
reader->SetMaskArrays(true);
|
||||
reader->Update();
|
||||
vtkTree* t = reader->GetOutput();
|
||||
vtkSmartPointer<vtkStringArray> label = vtkSmartPointer<vtkStringArray>::New();
|
||||
label->SetName("edge label");
|
||||
vtkSmartPointer<vtkIdTypeArray> dist = vtkSmartPointer<vtkIdTypeArray>::New();
|
||||
dist->SetName("distance");
|
||||
for (vtkIdType i = 0; i < t->GetNumberOfEdges(); i++)
|
||||
{
|
||||
dist->InsertNextValue(i);
|
||||
switch (i % 3)
|
||||
{
|
||||
case 0:
|
||||
label->InsertNextValue("a");
|
||||
break;
|
||||
case 1:
|
||||
label->InsertNextValue("b");
|
||||
break;
|
||||
case 2:
|
||||
label->InsertNextValue("c");
|
||||
break;
|
||||
}
|
||||
}
|
||||
t->GetEdgeData()->AddArray(dist);
|
||||
t->GetEdgeData()->AddArray(label);
|
||||
|
||||
vtkSmartPointer<vtkStringToNumeric> numeric = vtkSmartPointer<vtkStringToNumeric>::New();
|
||||
numeric->SetInputConnection(reader->GetOutputPort());
|
||||
|
||||
GraphLayoutView->DisplayHoverTextOn();
|
||||
GraphLayoutView->SetLayoutStrategyToCircular();
|
||||
GraphLayoutView->SetVertexLabelArrayName("name");
|
||||
GraphLayoutView->VertexLabelVisibilityOn();
|
||||
GraphLayoutView->SetVertexColorArrayName("size");
|
||||
GraphLayoutView->ColorVerticesOn();
|
||||
GraphLayoutView->SetRepresentationFromInputConnection(numeric->GetOutputPort());
|
||||
GraphLayoutView->SetEdgeColorArrayName("distance");
|
||||
GraphLayoutView->ColorEdgesOn();
|
||||
GraphLayoutView->SetEdgeLabelArrayName("edge label");
|
||||
GraphLayoutView->EdgeLabelVisibilityOn();
|
||||
vtkRenderedGraphRepresentation* rep =
|
||||
vtkRenderedGraphRepresentation::SafeDownCast(GraphLayoutView->GetRepresentation());
|
||||
rep->SetVertexHoverArrayName("name");
|
||||
rep->SetEdgeHoverArrayName("edge label");
|
||||
|
||||
GraphLayoutView->SetHideVertexLabelsOnInteraction(1);
|
||||
GraphLayoutView->SetHideEdgeLabelsOnInteraction(1);
|
||||
|
||||
GraphLayoutView->ResetCamera();
|
||||
|
||||
}
|
||||
|
||||
GraphLayoutViewItem::~GraphLayoutViewItem()
|
||||
{
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
|
||||
#ifndef GraphLayoutViewItem_h
|
||||
#define GraphLayoutViewItem_h
|
||||
|
||||
#include "QVTKGraphicsItem.h"
|
||||
class vtkGraphLayoutView;
|
||||
|
||||
class GraphLayoutViewItem : public QVTKGraphicsItem
|
||||
{
|
||||
public:
|
||||
GraphLayoutViewItem(QGLContext* ctx, QGraphicsItem* p=0);
|
||||
~GraphLayoutViewItem();
|
||||
|
||||
protected:
|
||||
vtkSmartPointer<vtkGraphLayoutView> GraphLayoutView;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,67 @@
|
||||
|
||||
#ifndef GraphicsView_hpp
|
||||
#define GraphicsView_hpp
|
||||
|
||||
#include <QGraphicsView>
|
||||
#include <QResizeEvent>
|
||||
#include "QVTKWidget2.h"
|
||||
#include "OpenGLScene.hpp"
|
||||
#include "vtkGenericOpenGLRenderWindow.h"
|
||||
#include "vtkRenderer.h"
|
||||
#include "vtkTextActor3D.h"
|
||||
|
||||
class GraphicsView : public QGraphicsView
|
||||
{
|
||||
public:
|
||||
GraphicsView()
|
||||
{
|
||||
mCtx = new QGLContext(QGLFormat());
|
||||
mWidget = new QVTKWidget2(mCtx);
|
||||
this->setViewport(mWidget);
|
||||
this->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||
this->setScene(new OpenGLScene(mCtx, this));
|
||||
vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New();
|
||||
ren->SetBackground(0,0,0);
|
||||
ren->SetBackground2(1,1,1);
|
||||
ren->SetGradientBackground(1);
|
||||
vtkSmartPointer<vtkTextActor3D> textActor = vtkSmartPointer<vtkTextActor3D>::New();
|
||||
textActor->SetInput("Qt & VTK!!");
|
||||
ren->AddViewProp(textActor);
|
||||
ren->ResetCamera();
|
||||
mWidget->GetRenderWindow()->AddRenderer(ren);
|
||||
mWidget->GetRenderWindow()->SetSwapBuffers(0); // don't let VTK swap buffers on us
|
||||
mWidget->setAutoBufferSwap(true);
|
||||
}
|
||||
~GraphicsView()
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void drawBackground(QPainter* p, const QRectF& vtkNotUsed(r))
|
||||
{
|
||||
#if QT_VERSION >= 0x040600
|
||||
p->beginNativePainting();
|
||||
#endif
|
||||
mWidget->GetRenderWindow()->PushState();
|
||||
mWidget->GetRenderWindow()->OpenGLInitState();
|
||||
mWidget->GetRenderWindow()->Render();
|
||||
mWidget->GetRenderWindow()->PopState();
|
||||
#if QT_VERSION >= 0x040600
|
||||
p->endNativePainting();
|
||||
#endif
|
||||
}
|
||||
|
||||
void resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
// give the same size to the scene that his widget has
|
||||
if (scene())
|
||||
scene()->setSceneRect(QRect(QPoint(0, 0), event->size()));
|
||||
QGraphicsView::resizeEvent(event);
|
||||
mWidget->GetRenderWindow()->SetSize(event->size().width(), event->size().height());
|
||||
}
|
||||
QGLContext* mCtx;
|
||||
QVTKWidget2* mWidget;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,7 @@
|
||||
<RCC>
|
||||
<qresource prefix="/Data" >
|
||||
<file>treetest.xml</file>
|
||||
<file>vtkclasses.xml</file>
|
||||
<file>vtklibrary.xml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
160
ParaView-5.0.1/VTK/Examples/GUI/Qt/GraphicsView/OpenGLScene.cpp
Normal file
160
ParaView-5.0.1/VTK/Examples/GUI/Qt/GraphicsView/OpenGLScene.cpp
Normal file
@ -0,0 +1,160 @@
|
||||
|
||||
#include "OpenGLScene.hpp"
|
||||
#include "TreeRingViewItem.h"
|
||||
#include "GraphLayoutViewItem.h"
|
||||
#include "WebView.h"
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QGraphicsLinearLayout>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QSignalTransition>
|
||||
#include <QPropertyAnimation>
|
||||
#include "QBoolAnimation.h"
|
||||
|
||||
OpenGLScene::OpenGLScene(QGLContext* ctx, QObject* p)
|
||||
: QGraphicsScene(p), mContext(ctx)
|
||||
{
|
||||
int sz = 128;
|
||||
int gap = 10;
|
||||
QRectF activeRect(sz+2*gap, gap, 512, 512);
|
||||
|
||||
mGraphLayoutView = new GraphLayoutViewItem(ctx);
|
||||
this->addItem(mGraphLayoutView);
|
||||
|
||||
mTreeRingView = new TreeRingViewItem(ctx);
|
||||
this->addItem(mTreeRingView);
|
||||
|
||||
QGraphicsProxyWidget* tmp = new QGraphicsProxyWidget;
|
||||
tmp->setWidget(new WebView);
|
||||
mWebView = tmp;
|
||||
tmp->setOpacity(0.8);
|
||||
this->addItem(mWebView);
|
||||
|
||||
|
||||
QState* state1 = new QState(&machine);
|
||||
QState* state2 = new QState(&machine);
|
||||
QState* state3 = new QState(&machine);
|
||||
QState* state4 = new QState(&machine);
|
||||
|
||||
machine.setInitialState(state3);
|
||||
CurrentState = 2;
|
||||
|
||||
// states
|
||||
state1->assignProperty(mGraphLayoutView, "geometry", activeRect);
|
||||
state1->assignProperty(mGraphLayoutView, "enabled", true);
|
||||
state1->assignProperty(mTreeRingView, "geometry", QRectF(gap,2*gap+sz,sz,sz));
|
||||
state1->assignProperty(mTreeRingView, "enabled", false);
|
||||
state1->assignProperty(mWebView, "geometry", QRectF(gap,4*gap+sz+sz,sz,sz));
|
||||
state1->assignProperty(mWebView, "enabled", false);
|
||||
|
||||
state2->assignProperty(mGraphLayoutView, "geometry", QRectF(gap,gap,sz,sz));
|
||||
state2->assignProperty(mGraphLayoutView, "enabled", false);
|
||||
state2->assignProperty(mTreeRingView, "geometry", activeRect);
|
||||
state2->assignProperty(mTreeRingView, "enabled", true);
|
||||
state2->assignProperty(mWebView, "geometry", QRectF(gap,4*gap+sz+sz,sz,sz));
|
||||
state2->assignProperty(mWebView, "enabled", false);
|
||||
|
||||
state3->assignProperty(mGraphLayoutView, "geometry", QRectF(gap,gap,sz,sz));
|
||||
state3->assignProperty(mGraphLayoutView, "enabled", false);
|
||||
state3->assignProperty(mTreeRingView, "geometry", QRectF(gap,2*gap+sz,sz,sz));
|
||||
state3->assignProperty(mTreeRingView, "enabled", false);
|
||||
state3->assignProperty(mWebView, "geometry", activeRect);
|
||||
state3->assignProperty(mWebView, "enabled", true);
|
||||
|
||||
state4->assignProperty(mGraphLayoutView, "geometry", QRectF(gap,gap,sz,sz));
|
||||
state4->assignProperty(mGraphLayoutView, "enabled", false);
|
||||
state4->assignProperty(mTreeRingView, "geometry", QRectF(gap,2*gap+sz,sz,sz));
|
||||
state4->assignProperty(mTreeRingView, "enabled", false);
|
||||
state4->assignProperty(mWebView, "geometry", QRectF(gap,4*gap+sz+sz,sz,sz));
|
||||
state4->assignProperty(mWebView, "enabled", false);
|
||||
|
||||
// transitions
|
||||
QAbstractTransition* trans;
|
||||
|
||||
// 1 -> 3
|
||||
trans = state1->addTransition(this, SIGNAL(enterState3()), state3);
|
||||
trans->addAnimation(new QPropertyAnimation(mGraphLayoutView, "geometry"));
|
||||
trans->addAnimation(new QPropertyAnimation(mWebView, "geometry"));
|
||||
trans->addAnimation(new QBoolAnimation(1.0, mWebView, "enabled")); // enable at end of transition
|
||||
|
||||
// 1 -> 2
|
||||
trans = state1->addTransition(this, SIGNAL(enterState2()), state2);
|
||||
trans->addAnimation(new QPropertyAnimation(mGraphLayoutView, "geometry"));
|
||||
trans->addAnimation(new QPropertyAnimation(mTreeRingView, "geometry"));
|
||||
trans->addAnimation(new QBoolAnimation(1.0, mTreeRingView, "enabled")); // enable at end of transition
|
||||
|
||||
// 2 -> 3
|
||||
trans = state2->addTransition(this, SIGNAL(enterState3()), state3);
|
||||
trans->addAnimation(new QPropertyAnimation(mTreeRingView, "geometry"));
|
||||
trans->addAnimation(new QPropertyAnimation(mWebView, "geometry"));
|
||||
trans->addAnimation(new QBoolAnimation(1.0, mWebView, "enabled")); // enable at end of transition
|
||||
|
||||
// 2 -> 1
|
||||
trans = state2->addTransition(this, SIGNAL(enterState1()), state1);
|
||||
trans->addAnimation(new QPropertyAnimation(mTreeRingView, "geometry"));
|
||||
trans->addAnimation(new QPropertyAnimation(mGraphLayoutView, "geometry"));
|
||||
trans->addAnimation(new QBoolAnimation(1.0, mGraphLayoutView, "enabled")); // enable at end of transition
|
||||
|
||||
// 3 -> 1
|
||||
trans = state3->addTransition(this, SIGNAL(enterState1()), state1);
|
||||
trans->addAnimation(new QPropertyAnimation(mWebView, "geometry"));
|
||||
trans->addAnimation(new QPropertyAnimation(mGraphLayoutView, "geometry"));
|
||||
trans->addAnimation(new QBoolAnimation(1.0, mGraphLayoutView, "enabled")); // enable at end of transition
|
||||
|
||||
// 3 -> 2
|
||||
trans = state3->addTransition(this, SIGNAL(enterState2()), state2);
|
||||
trans->addAnimation(new QPropertyAnimation(mWebView, "geometry"));
|
||||
trans->addAnimation(new QPropertyAnimation(mTreeRingView, "geometry"));
|
||||
trans->addAnimation(new QBoolAnimation(1.0, mTreeRingView, "enabled")); // enable at end of transition
|
||||
|
||||
// non animated transitions
|
||||
trans = state1->addTransition(this, SIGNAL(enterState4()), state4);
|
||||
trans = state2->addTransition(this, SIGNAL(enterState4()), state4);
|
||||
trans = state3->addTransition(this, SIGNAL(enterState4()), state4);
|
||||
trans = state4->addTransition(this, SIGNAL(enterState1()), state1);
|
||||
trans = state4->addTransition(this, SIGNAL(enterState2()), state2);
|
||||
trans = state4->addTransition(this, SIGNAL(enterState3()), state3);
|
||||
|
||||
machine.start();
|
||||
|
||||
}
|
||||
|
||||
OpenGLScene::~OpenGLScene()
|
||||
{
|
||||
}
|
||||
|
||||
void OpenGLScene::mousePressEvent(QGraphicsSceneMouseEvent* e)
|
||||
{
|
||||
QGraphicsScene::mousePressEvent(e);
|
||||
|
||||
// See if its under one our our deactivated items.
|
||||
#if QT_VERSION >= 0x050000
|
||||
// The transform is just the identity matrix.
|
||||
QGraphicsItem* item = itemAt(e->scenePos(),QTransform());
|
||||
#else
|
||||
QGraphicsItem* item = itemAt(e->scenePos());
|
||||
#endif
|
||||
|
||||
if(item == mGraphLayoutView && CurrentState != 0)
|
||||
{
|
||||
e->accept();
|
||||
CurrentState = 0;
|
||||
emit enterState1();
|
||||
}
|
||||
else if(item == mTreeRingView && CurrentState != 1)
|
||||
{
|
||||
e->accept();
|
||||
CurrentState = 1;
|
||||
emit enterState2();
|
||||
}
|
||||
else if(item == mWebView && CurrentState != 2)
|
||||
{
|
||||
e->accept();
|
||||
CurrentState = 2;
|
||||
emit enterState3();
|
||||
}
|
||||
else if(!item)
|
||||
{
|
||||
CurrentState = 3;
|
||||
emit enterState4();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
|
||||
#ifndef OpenGLScene_hpp
|
||||
#define OpenGLScene_hpp
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include <QtOpenGL/QGLContext>
|
||||
#include <QStateMachine>
|
||||
#include "vtkSmartPointer.h"
|
||||
class vtkGenericOpenGLRenderWindow;
|
||||
class vtkRenderer;
|
||||
class QVTKInteractor;
|
||||
class QVTKInteractorAdapter;
|
||||
class vtkEventQtSlotConnect;
|
||||
|
||||
class OpenGLScene : public QGraphicsScene
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OpenGLScene(QGLContext* ctx, QObject* p=0);
|
||||
~OpenGLScene();
|
||||
|
||||
Q_SIGNALS:
|
||||
void enterState1();
|
||||
void enterState2();
|
||||
void enterState3();
|
||||
void enterState4();
|
||||
|
||||
protected:
|
||||
QGLContext* mContext;
|
||||
QStateMachine machine;
|
||||
QGraphicsWidget* mGraphLayoutView;
|
||||
QGraphicsWidget* mTreeRingView;
|
||||
QGraphicsWidget* mWebView;
|
||||
int CurrentState;
|
||||
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent* e);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,28 @@
|
||||
|
||||
#ifndef QBoolAnimation_h
|
||||
#define QBoolAnimation_h
|
||||
|
||||
#include "QPropertyAnimation"
|
||||
|
||||
class QBoolAnimation : public QPropertyAnimation
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QBoolAnimation(double tipping_point, QObject* target, const QByteArray & prop, QObject * p = 0 )
|
||||
: QPropertyAnimation(target, prop, p), mTippingPoint(tipping_point)
|
||||
{}
|
||||
protected:
|
||||
QVariant interpolated(const QVariant& from, const QVariant& to, qreal progress) const
|
||||
{
|
||||
double f = from.toDouble();
|
||||
double t = to.toDouble();
|
||||
double i = QPropertyAnimation::interpolated(f, t, progress).toDouble();
|
||||
|
||||
if(f < t)
|
||||
return i >= mTippingPoint;
|
||||
return i <= mTippingPoint;
|
||||
}
|
||||
double mTippingPoint;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,82 @@
|
||||
|
||||
#include "TreeRingViewItem.h"
|
||||
#include "vtkTreeRingView.h"
|
||||
#include "vtkGenericOpenGLRenderWindow.h"
|
||||
#include "QVTKInteractor.h"
|
||||
#include "vtkXMLTreeReader.h"
|
||||
#include "vtkRenderedTreeAreaRepresentation.h"
|
||||
#include "vtkViewTheme.h"
|
||||
#include "vtkTextProperty.h"
|
||||
#include "vtkRenderer.h"
|
||||
#include <QFile>
|
||||
|
||||
TreeRingViewItem::TreeRingViewItem(QGLContext* ctx, QGraphicsItem* p)
|
||||
: QVTKGraphicsItem(ctx, p)
|
||||
{
|
||||
QPalette pal = this->palette();
|
||||
pal.setColor(QPalette::Window, QColor(255,255,255,250));
|
||||
this->setPalette(pal);
|
||||
|
||||
TreeRingView.TakeReference(vtkTreeRingView::New());
|
||||
TreeRingView->SetRenderWindow(this->GetRenderWindow());
|
||||
|
||||
QFile f1(":/Data/vtkclasses.xml");
|
||||
f1.open(QIODevice::ReadOnly);
|
||||
QByteArray f1_data = f1.readAll();
|
||||
|
||||
QFile f2(":/Data/vtklibrary.xml");
|
||||
f2.open(QIODevice::ReadOnly);
|
||||
QByteArray f2_data = f2.readAll();
|
||||
|
||||
vtkSmartPointer<vtkXMLTreeReader> reader1 = vtkSmartPointer<vtkXMLTreeReader>::New();
|
||||
reader1->SetXMLString(f1_data.data());
|
||||
reader1->SetEdgePedigreeIdArrayName("graph edge");
|
||||
reader1->GenerateVertexPedigreeIdsOff();
|
||||
reader1->SetVertexPedigreeIdArrayName("id");
|
||||
|
||||
vtkSmartPointer<vtkXMLTreeReader> reader2 = vtkSmartPointer<vtkXMLTreeReader>::New();
|
||||
reader2->SetXMLString(f2_data.data());
|
||||
reader2->SetEdgePedigreeIdArrayName("tree edge");
|
||||
reader2->GenerateVertexPedigreeIdsOff();
|
||||
reader2->SetVertexPedigreeIdArrayName("id");
|
||||
|
||||
reader1->Update();
|
||||
reader2->Update();
|
||||
|
||||
TreeRingView->DisplayHoverTextOn();
|
||||
TreeRingView->SetTreeFromInputConnection(reader2->GetOutputPort());
|
||||
TreeRingView->SetGraphFromInputConnection(reader1->GetOutputPort());
|
||||
|
||||
TreeRingView->SetAreaColorArrayName("VertexDegree");
|
||||
|
||||
// Uncomment for edge colors
|
||||
//TreeRingView->SetEdgeColorArrayName("graph edge");
|
||||
//TreeRingView->SetColorEdges(true);
|
||||
|
||||
// Uncomment for edge labels
|
||||
//TreeRingView->SetEdgeLabelArrayName("graph edge");
|
||||
//TreeRingView->SetEdgeLabelVisibility(true);
|
||||
|
||||
TreeRingView->SetAreaLabelArrayName("id");
|
||||
TreeRingView->SetAreaLabelVisibility(true);
|
||||
TreeRingView->SetAreaHoverArrayName("id");
|
||||
TreeRingView->SetAreaSizeArrayName("VertexDegree");
|
||||
vtkRenderedTreeAreaRepresentation::SafeDownCast(TreeRingView->GetRepresentation())->SetGraphHoverArrayName("graph edge");
|
||||
|
||||
vtkViewTheme* const theme = vtkViewTheme::CreateMellowTheme();
|
||||
theme->SetLineWidth(1);
|
||||
theme->GetPointTextProperty()->ShadowOn();
|
||||
TreeRingView->ApplyViewTheme(theme);
|
||||
theme->Delete();
|
||||
|
||||
this->TreeRingView->GetRenderer()->SetGradientBackground(0);
|
||||
this->TreeRingView->GetRenderer()->SetBackground(0.1,0.1,0.1);
|
||||
|
||||
TreeRingView->ResetCamera();
|
||||
|
||||
|
||||
}
|
||||
|
||||
TreeRingViewItem::~TreeRingViewItem()
|
||||
{
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
|
||||
#ifndef TreeRingView_h
|
||||
#define TreeRingView_h
|
||||
|
||||
#include "QVTKGraphicsItem.h"
|
||||
class vtkTreeRingView;
|
||||
|
||||
class TreeRingViewItem : public QVTKGraphicsItem
|
||||
{
|
||||
public:
|
||||
TreeRingViewItem(QGLContext* ctx, QGraphicsItem* p=0);
|
||||
~TreeRingViewItem();
|
||||
|
||||
protected:
|
||||
vtkSmartPointer<vtkTreeRingView> TreeRingView;
|
||||
};
|
||||
|
||||
#endif
|
||||
48
ParaView-5.0.1/VTK/Examples/GUI/Qt/GraphicsView/WebView.cpp
Normal file
48
ParaView-5.0.1/VTK/Examples/GUI/Qt/GraphicsView/WebView.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
#include "WebView.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QToolButton>
|
||||
#include <QLineEdit>
|
||||
#include <QStyle>
|
||||
|
||||
WebView::WebView(QWidget* p)
|
||||
: QFrame(p)
|
||||
{
|
||||
QVBoxLayout* l = new QVBoxLayout(this);
|
||||
QHBoxLayout* hl = new QHBoxLayout;
|
||||
|
||||
QToolButton* left = new QToolButton(this);
|
||||
left->setIcon(left->style()->standardIcon(QStyle::SP_ArrowLeft));
|
||||
QToolButton* right = new QToolButton(this);
|
||||
right->setIcon(right->style()->standardIcon(QStyle::SP_ArrowRight));
|
||||
mAddress = new QLineEdit(this);
|
||||
|
||||
mWebView = new QWebView(this);
|
||||
mWebView->load(QUrl("http://www.google.com"));
|
||||
hl->addWidget(left);
|
||||
hl->addWidget(right);
|
||||
hl->addWidget(mAddress);
|
||||
l->addLayout(hl);
|
||||
l->addWidget(mWebView);
|
||||
|
||||
QObject::connect(left, SIGNAL(clicked()), mWebView, SLOT(back()));
|
||||
QObject::connect(right, SIGNAL(clicked()), mWebView, SLOT(forward()));
|
||||
QObject::connect(mAddress, SIGNAL(editingFinished()), this, SLOT(go()));
|
||||
QObject::connect(mWebView, SIGNAL(urlChanged(const QUrl&)), this, SLOT(updateUrl(const QUrl&)));
|
||||
}
|
||||
|
||||
WebView::~WebView()
|
||||
{
|
||||
}
|
||||
|
||||
void WebView::go()
|
||||
{
|
||||
mWebView->load(QUrl(mAddress->text()));
|
||||
}
|
||||
|
||||
void WebView::updateUrl(const QUrl& url)
|
||||
{
|
||||
QString s = url.toString();
|
||||
mAddress->setText(s);
|
||||
}
|
||||
31
ParaView-5.0.1/VTK/Examples/GUI/Qt/GraphicsView/WebView.h
Normal file
31
ParaView-5.0.1/VTK/Examples/GUI/Qt/GraphicsView/WebView.h
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
#ifndef WebView_h
|
||||
#define WebView_h
|
||||
|
||||
#include <QFrame>
|
||||
#include <QWebView>
|
||||
#include <QLineEdit>
|
||||
|
||||
class WebView : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
WebView(QWidget* p=0);
|
||||
~WebView();
|
||||
|
||||
QWebView* webview();
|
||||
|
||||
public Q_SLOTS:
|
||||
void go();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void updateUrl(const QUrl& str);
|
||||
|
||||
protected:
|
||||
QWebView* mWebView;
|
||||
QLineEdit* mAddress;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
14
ParaView-5.0.1/VTK/Examples/GUI/Qt/GraphicsView/main.cpp
Normal file
14
ParaView-5.0.1/VTK/Examples/GUI/Qt/GraphicsView/main.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include "GraphicsView.hpp"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
GraphicsView view;
|
||||
view.show();
|
||||
|
||||
view.resize(800, 600);
|
||||
return app.exec();
|
||||
}
|
||||
17
ParaView-5.0.1/VTK/Examples/GUI/Qt/GraphicsView/treetest.xml
Normal file
17
ParaView-5.0.1/VTK/Examples/GUI/Qt/GraphicsView/treetest.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<vertex name="root">
|
||||
root.1
|
||||
<vertex size="6" name="child 1">1.1</vertex>
|
||||
root.2
|
||||
<vertex size="6" name="child 2"/>
|
||||
<vertex size="4" name="child 3"/>
|
||||
<vertex name="child 4">
|
||||
4.1
|
||||
<vertex size="9" name="child 4.1"/>
|
||||
<vertex size="2" name="child 4.2"/>
|
||||
<vertex size="4" name="child 4.3"/>
|
||||
</vertex>
|
||||
<vertex size="2" name="child 5"/>
|
||||
<vertex size="2" name="child 6"/>
|
||||
<vertex size="1" name="child 7"/>
|
||||
root.3
|
||||
</vertex>
|
||||
2686
ParaView-5.0.1/VTK/Examples/GUI/Qt/GraphicsView/vtkclasses.xml
Normal file
2686
ParaView-5.0.1/VTK/Examples/GUI/Qt/GraphicsView/vtkclasses.xml
Normal file
File diff suppressed because it is too large
Load Diff
2724
ParaView-5.0.1/VTK/Examples/GUI/Qt/GraphicsView/vtklibrary.xml
Normal file
2724
ParaView-5.0.1/VTK/Examples/GUI/Qt/GraphicsView/vtklibrary.xml
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user