VTK – Reverse PolyData’s Normals

vtkReverseSense can help us to reverse the direction of point normals and cell normals. The following code shows a simple example which display vertexes’ normals by cones in a sphere. Here is its original geometric states. #include <iostream> #include <vtkSmartPointer.h> #include <vtkSphereSource.h> #include <vtkActor.h> #include <vtkConeSource.h> #include <vtkRenderer.h> #include <vtkRenderWindow.h> Read more…

QT – Common Setting For Window

Borderless window: setWindowFlags( Qt::FramelessWindowHint ); Set background color: QPalette pal = mainWin->Getui().qvtkWidget->palette(); pal.setColor( QPalette::Background, Qt::black ); setAutoFillBackground( true ); this->setPalette( pal ); Make window stay on the top level: setWindowFlags(Qt::WindowStaysOnTopHint) Remove maximize button in widget: setWindowFlags( this->windowFlags() & ~Qt::WindowMaximizeButtonHint ); Definite buttons on title bar: setWindowFlags( Qt::CustomizeWindowHint | Qt::WindowMaximizeButtonHint); //Only Read more…

QT – QTest event, QSignalSpy and installEventFilter

The interfaces can imitate users’ operations. QTest::keyClick QTest::keyPress QTest::mouseClick QSignalSpy listens for signal emission, it is a list of QVariant lists. It will not shield off signal to make slot invalid. QCheckBox *box = …; QSignalSpy spy(box, SIGNAL(clicked(bool))); //… QList arguments = spy.takeFirst(); // take the first signal QVERIFY(arguments.at(0).toBool() == Read more…

Unit Test Based On QT

Simple Unit Test Project Let’s create a new unit test project firstly. Write our test functions in feild private Q_SLOTS for the class. tst_string.cpp: #include <QString> #include <QtTest> class String : public QObject { Q_OBJECT public: String(); private Q_SLOTS: void toUpper(); }; String::String() { } void String::toUpper() { QVERIFY2(true, “Failure”); Read more…

VTK – Update Different Views When Selections Changed

The article shows how to use vtkViewUpdater to update different views when the selections changed. Relevant development environment: VTK-8.1.1; Qt 5.11.2 (x86_64-little_endian-lp64 shared (dynamic) release build; Clang 8.1.0 (clang-802.0.42) (Apple)) on “cocoa”; macOS 10.14 [darwin version 18.5.0]; #include <QApplication> #include <qsurfaceformat.h> #include <QVTKOpenGLWidget.h> #include <vtkRandomGraphSource.h> #include <vtkDataObjectToTable.h> #include <vtkQtTableView.h> #include Read more…

Content Summary
: Input your strings, the tool can get a brief summary of the content for you.

X