Compare commits
2 Commits
3af983a955
...
8a01ee7f40
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a01ee7f40 | ||
|
|
03a3130855 |
3
.vscode/gdb_wrapper.sh
vendored
Executable file
3
.vscode/gdb_wrapper.sh
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
export DISPLAY=:1001.0
|
||||
/home/share/micromamba/bin/micromamba run -n uLib /usr/bin/gdb "$@"
|
||||
31
.vscode/launch.json
vendored
Normal file
31
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "gcompose",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/build/app/gcompose/gcompose",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [
|
||||
{ "name": "DISPLAY", "value": ":1001.0" }
|
||||
],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
],
|
||||
"preLaunchTask": "Build gcompose",
|
||||
"miDebuggerPath": "${workspaceFolder}/.vscode/gdb_wrapper.sh"
|
||||
}
|
||||
]
|
||||
}
|
||||
17
.vscode/tasks.json
vendored
Normal file
17
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Build gcompose",
|
||||
"type": "shell",
|
||||
"command": "/home/share/micromamba/bin/micromamba run -n uLib cmake --build build --target gcompose -j$(nproc)",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -17,3 +17,5 @@ dependencies:
|
||||
- ccache
|
||||
- OpenMP
|
||||
- Geant4
|
||||
- gdb
|
||||
- valgrind
|
||||
|
||||
@@ -37,14 +37,17 @@ int main() {
|
||||
BEGIN_TESTING(vtk ContainerBox Test);
|
||||
|
||||
ContainerBox box;
|
||||
box.Scale(Vector3f(1_m,5_m,1_m));
|
||||
box.SetPosition(Vector3f(0,1_m,0));
|
||||
Vtk::vtkContainerBox v_box(&box);
|
||||
v_box.SetRepresentation(Vtk::Puppet::Surface);
|
||||
v_box.SetOpacity(0.5);
|
||||
v_box.SetSelectable(true);
|
||||
box.Scale(Vector3f(1_m,2_m,1_m));
|
||||
box.SetPosition(Vector3f(0,0,0));
|
||||
|
||||
box.findOrAddSignal(&ContainerBox::Updated)->connect([&box](){
|
||||
Vtk::vtkContainerBox v_box(&box);
|
||||
v_box.Update();
|
||||
|
||||
// v_box.SetRepresentation(Vtk::Puppet::Surface);
|
||||
// v_box.SetOpacity(0.5);
|
||||
// v_box.SetSelectable(true);
|
||||
|
||||
box.findOrAddSignal(&Object::Updated)->connect([&box](){
|
||||
std::cout << "box updated: " << box.GetWorldPoint(HPoint3f(1,1,1)) << std::endl;
|
||||
});
|
||||
|
||||
|
||||
@@ -51,14 +51,12 @@ struct ContainerBoxData {
|
||||
vtkSmartPointer<vtkActor> m_Cube;
|
||||
vtkSmartPointer<vtkActor> m_Axes;
|
||||
vtkSmartPointer<vtkAssembly> m_VtkAsm;
|
||||
vtkSmartPointer<vtkMatrix4x4> m_Affine;
|
||||
uLib::Connection m_UpdateSignal;
|
||||
|
||||
|
||||
ContainerBoxData() : m_Cube(vtkSmartPointer<vtkActor>::New()),
|
||||
m_Axes(vtkSmartPointer<vtkActor>::New()),
|
||||
m_VtkAsm(vtkSmartPointer<vtkAssembly>::New()),
|
||||
m_Affine(vtkSmartPointer<vtkMatrix4x4>::New()) {}
|
||||
m_VtkAsm(vtkSmartPointer<vtkAssembly>::New()) {}
|
||||
~ContainerBoxData() {
|
||||
}
|
||||
};
|
||||
@@ -87,14 +85,13 @@ void vtkContainerBox::Update() {
|
||||
RecursiveMutex::ScopedLock lock(this->m_UpdateMutex);
|
||||
if (!m_Content) return;
|
||||
|
||||
vtkProp3D* root = vtkProp3D::SafeDownCast(this->GetProp());
|
||||
if (root) {
|
||||
// Apply local full matrix (TRS * LocalBox) so that nested assemblies work correctly
|
||||
Matrix4f fullLocal = m_Content->GetMatrix() * m_Content->GetLocalMatrix();
|
||||
vtkNew<vtkMatrix4x4> m;
|
||||
Matrix4fToVtk(fullLocal, m);
|
||||
root->SetUserMatrix(m);
|
||||
root->Modified();
|
||||
vtkProp3D* prop = vtkProp3D::SafeDownCast(this->GetProp());
|
||||
if (prop) {
|
||||
// Apply the full volume matrix (TRS * m_LocalT)
|
||||
vtkNew<vtkMatrix4x4> m;
|
||||
Matrix4fToVtk(m_Content->GetMatrix(), m);
|
||||
prop->SetUserMatrix(m);
|
||||
prop->Modified();
|
||||
}
|
||||
|
||||
// Delegate rest of update (appearance, render, etc)
|
||||
@@ -103,6 +100,8 @@ void vtkContainerBox::Update() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void vtkContainerBox::SyncFromVtk() {
|
||||
RecursiveMutex::ScopedLock lock(this->m_UpdateMutex);
|
||||
if (!m_Content) return;
|
||||
@@ -112,18 +111,11 @@ void vtkContainerBox::SyncFromVtk() {
|
||||
|
||||
// VTK -> Model: Extract new world TRS from proxy, which matches the model's TRS center
|
||||
vtkMatrix4x4* rootMat = root->GetUserMatrix();
|
||||
// if (rootMat) {
|
||||
// std::cout << "[vtkContainerBox::SyncFromVtk] Read Proxy UserMatrix:" << std::endl;
|
||||
// rootMat->Print(std::cout);
|
||||
// }
|
||||
|
||||
Matrix4f vtkWorld = VtkToMatrix4f(rootMat);
|
||||
|
||||
// Synchronize TRS property members from the updated local matrix
|
||||
m_Content->FromMatrix(vtkWorld);
|
||||
|
||||
// std::cout << "[vtkContainerBox::SyncFromVtk] New Model WorldMatrix:" << std::endl << m_Content->GetWorldMatrix() << std::endl;
|
||||
|
||||
// Since we modified the model, notify observers, but block the loop back to VTK
|
||||
// ConnectionBlock blocker(d->m_UpdateSignal);
|
||||
m_Content->Updated();
|
||||
@@ -172,11 +164,10 @@ void vtkContainerBox::InstallPipe() {
|
||||
d->m_VtkAsm->AddPart(d->m_Axes);
|
||||
this->SetProp(d->m_VtkAsm);
|
||||
|
||||
vtkProp3D* root = d->m_VtkAsm;
|
||||
if (root) {
|
||||
d->m_Affine = Matrix4fToVtk(m_Content->GetMatrix());
|
||||
root->SetUserMatrix(d->m_Affine);
|
||||
}
|
||||
// vtkProp3D* root = d->m_VtkAsm;
|
||||
// if (root) {
|
||||
// this->ApplyPuppetTransform(root);
|
||||
// }
|
||||
this->Update();
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@ public:
|
||||
|
||||
~PuppetData() {
|
||||
// No manual Delete needed for smart pointers
|
||||
|
||||
}
|
||||
|
||||
Puppet *m_Puppet;
|
||||
@@ -112,9 +113,10 @@ public:
|
||||
vtkSmartPointer<vtkCubeAxesActor> m_CubeAxesActor;
|
||||
vtkSmartPointer<vtkActor> m_HighlightActor;
|
||||
|
||||
// Display properties
|
||||
bool m_ShowBoundingBox;
|
||||
bool m_ShowScaleMeasures;
|
||||
int m_Representation;
|
||||
int m_Representation; // 0: Points, 1: Wireframe, 2: Surface, 3: SurfaceWithEdges, 4: Volume, 5: Outline, 6: Slice
|
||||
Vector3d m_Color;
|
||||
double m_Opacity;
|
||||
|
||||
@@ -179,7 +181,6 @@ public:
|
||||
|
||||
void UpdateHighlight() {
|
||||
if (m_Selected) {
|
||||
// Find first polydata in assembly to highlight
|
||||
vtkPolyData* polydata = nullptr;
|
||||
if (vtkActor *actor = vtkActor::SafeDownCast(m_Prop)) {
|
||||
if (actor->GetMapper()) {
|
||||
|
||||
@@ -64,7 +64,8 @@ class Puppet : public uLib::Object {
|
||||
|
||||
uLibTypeMacro(Puppet, uLib::Object)
|
||||
|
||||
public : Puppet();
|
||||
public:
|
||||
Puppet();
|
||||
virtual ~Puppet();
|
||||
|
||||
virtual vtkProp *GetProp();
|
||||
@@ -149,9 +150,9 @@ protected:
|
||||
|
||||
void RemoveProp(vtkProp *prop);
|
||||
|
||||
void ApplyAppearance(vtkProp *prop);
|
||||
void ApplyTransform(vtkProp3D *p3d);
|
||||
void ApplyPuppetTransform(vtkProp3D *p3d);
|
||||
virtual void ApplyAppearance(vtkProp *prop);
|
||||
virtual void ApplyTransform(vtkProp3D *p3d);
|
||||
virtual void ApplyPuppetTransform(vtkProp3D *p3d);
|
||||
|
||||
std::vector<uLib::PropertyBase *> m_DisplayProperties;
|
||||
mutable uLib::RecursiveMutex m_UpdateMutex;
|
||||
@@ -167,6 +168,10 @@ private:
|
||||
} // namespace Vtk
|
||||
} // namespace uLib
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// DISPLAY PROPERTIES SERIALIZE
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
Reference in New Issue
Block a user