[Paraview] can not drag object in TestPVSynchronizedRenderWindows
Utkarsh Ayachit
utkarsh.ayachit at kitware.com
Fri Mar 18 10:42:43 EDT 2011
Call the following after the view is created.
void setupCameraManipulators(vtkSMProxy* view)
{
vtkSMProxyManager* pxm = vtkSMProxyManager::GetProxyManager();
vtkIdType cid = view->GetConnectionID();
vtkSMProxy* manip = pxm->NewProxy("cameramanipulators",
"TrackballRotate");
vtkSMPropertyHelper(manip, "Button").Set(1);
vtkSMPropertyHelper(manip, "ManipulatorName").Set("Rotate");
manip->UpdateVTKObjects();
vtkSMPropertyHelper(view, "CameraManipulators").Add(manip);
manip->Delete();
manip = pxm->NewProxy("cameramanipulators",
"TrackballZoom");
vtkSMPropertyHelper(manip, "Button").Set(3);
vtkSMPropertyHelper(manip, "ManipulatorName").Set("Zoom");
manip->UpdateVTKObjects();
vtkSMPropertyHelper(view, "CameraManipulators").Add(manip);
manip->Delete();
manip = pxm->NewProxy("cameramanipulators",
"TrackballPan1");
vtkSMPropertyHelper(manip, "Button").Set(2);
vtkSMPropertyHelper(manip, "ManipulatorName").Set("Pan");
manip->UpdateVTKObjects();
vtkSMPropertyHelper(view, "CameraManipulators").Add(manip);
manip->Delete();
}
On Fri, Mar 18, 2011 at 5:58 AM, Gil Wertz <gilwertz at hotmail.com> wrote:
> I did take a look to BasicApp, but it doesn't implement Client / Server,
> with non build in server.
>
> I'm not sur to understand, can I with a pqServer and an pqObjectBuilder ask
> to a distant server to open a file by giving the path ( the file is in the
> server side ) and show the rendered window on the client side ?
>
>
> The code I made for having it work in TestPVSynchronizedRenderWindows, but
> as I said, I cannot drag the object, only rotate and zoom.
>
> /********************************** code
> ***************************************/
>
>
> #include "vtkInitializationHelper.h"
> #include "vtkProcessModule.h"
> #include "vtkPVOptions.h"
> #include "vtkPVRenderView.h"
> #include "vtkSMPropertyHelper.h"
> #include "vtkSMProxy.h"
> #include "vtkSMProxyManager.h"
> #include "vtkSmartPointer.h"
>
> #include <QApplication>
> #include <QMainWindow>
> #include "QVTKWidget.h"
> #include <QHBoxLayout>
> #include <QVBoxLayout>
> #include <QFile>
>
> // returns vtk proxy
> vtkSMProxy* addVTK(vtkSMProxy* view, QString fileName)
> {
>
> vtkSMProxy* loaded_object;
>
> vtkSMProxyManager* pxm = vtkSMProxyManager::GetProxyManager();
>
> /************************************ VTK
> ********************************/
> loaded_object = pxm->NewProxy("sources", "LegacyVTKFileReader");
> loaded_object->SetConnectionID(view->GetConnectionID());
>
> vtkSMPropertyHelper(loaded_object,
> "FileNames").Set(fileName.toStdString().c_str());//"can.ex2"
> loaded_object->UpdateVTKObjects();
>
>
> vtkSMProxy* repr = pxm->NewProxy("representations",
> "GeometryRepresentation"); // AxesRepresentation //
> GeometryRepresentation // UnstructuredGridRepresentation
> repr->SetConnectionID(view->GetConnectionID());
> vtkSMPropertyHelper(repr, "Input").Set(loaded_object);
> repr->UpdateVTKObjects();
>
> vtkSMPropertyHelper(view, "Representations").Add(repr);
> view->UpdateVTKObjects();
>
> loaded_object->Delete();
> repr->Delete();
> return loaded_object;
> }
>
>
> // returns exodusII proxy
> vtkSMProxy* addEX2(vtkSMProxy* view, QString fileName)
> {
>
> vtkSMProxy* loaded_object;
>
> vtkSMProxyManager* pxm = vtkSMProxyManager::GetProxyManager();
>
> /************************************* ExodusII
> ****************************/
> loaded_object = pxm->NewProxy("sources", "ExodusIIReader");
> loaded_object->SetConnectionID(view->GetConnectionID());
>
> vtkSMPropertyHelper(loaded_object,
> "FileName").Set(fileName.toStdString().c_str());//"can.ex2"
> loaded_object->UpdateVTKObjects();
>
>
> vtkSMProxy* repr = pxm->NewProxy("representations",
> "SurfaceRepresentation"); // AxesRepresentation //
> GeometryRepresentation // UnstructuredGridRepresentation
> repr->SetConnectionID(view->GetConnectionID());
> vtkSMPropertyHelper(repr, "Input").Set(loaded_object);
> repr->UpdateVTKObjects();
>
> vtkSMPropertyHelper(view, "Representations").Add(repr);
> view->UpdateVTKObjects();
>
> loaded_object->Delete();
> repr->Delete();
> return loaded_object;
> }
>
> int main(int argcc, char** argvv)
> {
> //creating my own argc to ba able to make a widget without main function
> and argument
> int argc = 1;
> const char* executable = ""; //TestPVSynchronizedRenderWindows
> char* arg = new char[strlen(executable)+1];
> strcpy(arg, executable);
>
> //my argv
> char** argv = &arg;
>
> //the vtkPVOptions that I don't know how to remove ( I have no options
> to set -_- )
> vtkSmartPointer<vtkPVOptions> newoptions =
> vtkSmartPointer<vtkPVOptions>::New();
>
> // ?
> vtkInitializationHelper::Initialize(argc, argv, newoptions);
>
> QApplication app(argc, argv);
>
> QMainWindow mainWindow;
> mainWindow.resize(400, 400);
> mainWindow.show();
> QApplication::processEvents();
>
> // the process module
> vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
>
> // Connect to the server, local server for the moment ( I launch pvserver by
> side )
> vtkIdType connectionID = pm->ConnectToRemote("localhost", 11111);
>
> // Create a view and connect it
> vtkSMProxy* viewProxy =
> vtkSMProxyManager::GetProxyManager()->NewProxy("views",
> "RenderView"); // RenderViewBase // RenderView
> viewProxy->SetConnectionID(connectionID);
> viewProxy->UpdateVTKObjects();
>
> // Create the widget to show the view, I'm don't know why we don't use a
> pqRenderView witch is a QWidget
> vtkPVRenderView* rv =
> vtkPVRenderView::SafeDownCast(viewProxy->GetClientSideObject());
> QVTKWidget* qwidget = new QVTKWidget(&mainWindow);
> qwidget->SetRenderWindow(rv->GetRenderWindow());
>
> // I add a proxy who read a ex2 file on server side and add it to the view
> vtkSMProxy* loaded_object = addEX2(viewProxy,"can.ex2");
>
> mainWindow.setCentralWidget(qwidget);
>
> viewProxy->InvokeCommand("StillRender");
> viewProxy->InvokeCommand("ResetCamera");
>
> int ret = app.exec();
>
> viewProxy->Delete();
>
> vtkInitializationHelper::Finalize();
> return ret;
> }
>
>
>
> /****************************** / code
> *******************************************/
>
>
> I know this code is not beautiful like my argc and argv but I didn't know
> how to do that in an other way...
>
> I also funded this list : http://www.vtk.org/Wiki/ProxyXMLName
> but all the object are not recognised and I didn't funded all their
> function. ( I suppose that using ObjectBuilder will help but not sure... ).
>
> Thanks to comment what I did wrong and maybe give some solutions ( more you
> comment even if it's bag the bether it is, I'm still learning and not afraid
> of making mistake. )
>
>
> ________________________________
>
> Wertz Gil
>
> gilwertz at hotmail.com
>
> ________________________________
>
>
>
>> Date: Thu, 17 Mar 2011 09:31:41 -0400
>> Subject: Re: [Paraview] can not drag object in
>> TestPVSynchronizedRenderWindows
>> From: utkarsh.ayachit at kitware.com
>> To: gilwertz at hotmail.com
>> CC: paraview at paraview.org
>>
>> I wouldn't recommend using TestPVSynchronizedRenderWindows as the
>> basis for any code. It was an executable built specifically to test
>> some functionality being developed at that time and will be removed in
>> future. Look at BasicApp.cxx instead.
>>
>> Utkarsh
>>
>> On Thu, Mar 17, 2011 at 4:05 AM, Gil Wertz <gilwertz at hotmail.com> wrote:
>> > Hello, I'm new paraview code user and I tried some stuff in
>> > "TestPVSynchronizedRenderWindows" but when run , I can only rotate and
>> > zoom,
>> > but I would like to move object with the 3 mouse button. ( like when I
>> > use
>> > vtkRenderWindow with vtkRenderWindowInteractor ).
>> >
>> > In TestPVSynchronizedRenderWindows we use Proxy and I didn't find how to
>> > add
>> > the drag on it.
>> >
>> > My proxy are :
>> >
>> > vtkSMProxy* repr =
>> > pxm->NewProxy("representations","GeometryRepresentation");
>> > vtkSMProxy* viewProxy =
>> > vtkSMProxyManager::GetProxyManager()->NewProxy("views", "RenderView");
>> >
>> > Thanks
>> >
>> > ________________________________
>> >
>> > Wertz Gil
>> >
>> > gilwertz at hotmail.com
>> >
>> > ________________________________
>> >
>> >
>> > _______________________________________________
>> > Powered by www.kitware.com
>> >
>> > Visit other Kitware open-source projects at
>> > http://www.kitware.com/opensource/opensource.html
>> >
>> > Please keep messages on-topic and check the ParaView Wiki at:
>> > http://paraview.org/Wiki/ParaView
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > http://www.paraview.org/mailman/listinfo/paraview
>> >
>> >
>
More information about the ParaView
mailing list