[vtkusers] Problem with creating a UI using KWWidgets
Amy Squillacote
amy.squillacote at kitware.com
Tue Oct 17 08:17:20 EDT 2006
Hi Sharwari,
In the VTK that you're using with KWWidgets, did you turn on both of the
following CMake variables: VTK_USE_RENDERING and VTK_WRAP_TCL? Both of
them are required in order for vtkTkRenderWidget to be built.
- Amy
Sharwari Mavalankar wrote:
> hi all,
> I am working on creating a UI using KWWidgets.
> I want to display a 3D volume in this UI from 2D BMP slices.
> The volume rendering is working fine without the UI.But I seem to have
> some problem with the UI.
> It displays the UI window, but I cannot see the 3D volume inside it.
> Addionally on running the program I get the following error on the
> vtkoutput window.
>
> ERROR: In C:\Program
> Files\KWWidgets\KWWidgets-HEAD-cvs\vtkKWTkUtilities.cxx, line 221
> vtkKWApplication (0x03414370):
> Script:
> vtkTkRenderWidget .1.10.18.21.22.25.100.102.104.107.108 -rw Addr=03428710
> Returned Error on line 1:
> invalid command name "vtkTkRenderWidget"
> Stack trace:
> invalid command name "vtkTkRenderWidget"
> while executing
> "vtkTkRenderWidget .1.10.18.21.22.25.100.102.104.107.108 -rw
> Addr=03428710"
>
>
> ERROR: In C:\Program
> Files\KWWidgets\KWWidgets-HEAD-cvs\vtkKWWidget.cxx, line 301
> vtkKWCoreWidget (0x03428990): Error creating the widget
> .1.10.18.21.22.25.100.102.104.107.108 of type vtkTkRenderWidget:
> invalid command name "vtkTkRenderWidget"
>
> ERROR: In C:\Program
> Files\KWWidgets\KWWidgets-HEAD-cvs\vtkKWTkUtilities.cxx, line 221
> vtkKWApplication (0x03414370):
> Script:
> grid .1.10.18.21.22.25.100.102.104.107.108 -row 0 -column 0 -sticky nsew
> Returned Error on line 1:
> bad window path name ".1.10.18.21.22.25.100.102.104.107.108"
> Stack trace:
> bad window path name ".1.10.18.21.22.25.100.102.104.107.108"
> while executing
> "grid .1.10.18.21.22.25.100.102.104.107.108 -row 0 -column 0 -sticky nsew"
>
>
> ERROR: In C:\Program
> Files\KWWidgets\KWWidgets-HEAD-cvs\vtkKWApplication.cxx, line 999
> vtkKWApplication (0x03414370): TclTk error: Object named: vtkTemp44,
> could not find requested method: ConfigureCallback
> or the method was called with incorrect arguments.
>
> Object named: vtkTemp44, could not find requested method:
> ConfigureCallback
> or the method was called with incorrect arguments.
>
> while executing
> "vtkTemp44 ConfigureCallback 900 668"
> (command bound to event)
>
> Here is my code
>
> //The following code includes the vtk code and the KWWidgets code for
> the user interface.
> #include "vtkRenderer.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkBMPReader.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkActor.h"
> #include "vtkActor2D.h"
> #include "vtkImageActor.h"
> #include "vtkOutlineFilter.h "
> #include "vtkCamera.h"
> #include "vtkProperty.h"
> #include "vtkPolyDataNormals.h"
> #include "vtkContourFilter.h"
> #include "vtkDataSetMapper.h"
> #include " vtkImageMapper.h"
> #include "vtkVolumeMapper.h"
> #include "vtkVolumeRayCastMapper.h"
> #include "vtkVolumeRayCastCompositeFunction.h"
> #include "vtkPiecewiseFunction.h"
> #include "vtkVolumeProperty.h"
> #include "vtkColorTransferFunction.h"
> #include "vtkLight.h"
> #include "vtkFixedPointVolumeRayCastMapper.h"
> #include "vtkKWApplication.h "
> #include "vtkKWWindowBase.h"
> #include "vtkKWRenderWidget.h"
> #include "vtkKWWindow.h"
> #include "vtkKWFrame.h"
>
> int main(int argc, char *argv[])
> {
>
> // Initialize Tcl.This is required otherwise the program crashes.
>
> Tcl_Interp *interp = vtkKWApplication::InitializeTcl(argc, argv, &cerr);
> if (!interp)
> {
> cerr << "Error: InitializeTcl failed" << endl ;
> return 1;
> }
>
>
> //using bmp to read gray image
> vtkBMPReader *reader = vtkBMPReader::New();
> reader->SetFilePattern("%s%d.bmp");
>
> reader->SetFilePrefix("C:\\Images\\PositionCReal\\Depth5mm\\slice");
>
>
> reader->SetDataExtent(0, 310, 0, 310, 1, 8);
> reader->SetDataSpacing(1.0,1.0,20.0);
> reader->SetDataOrigin(0.0, 0.0, 0.0);
> reader->Update();
>
>
> //vtkImageData *finalImg = reader->GetOutput();
>
>
> vtkPiecewiseFunction *tfun = vtkPiecewiseFunction::New();
>
> //The following lines of code displays the copper target for position
> A and C
> tfun->AddPoint(128,0.009);
> tfun->AddPoint(180,1.0);
> tfun->AddPoint(200,1.0);
> tfun->AddPoint(255,0.0009);
>
> vtkFixedPointVolumeRayCastMapper *volumeMapper =
> vtkFixedPointVolumeRayCastMapper::New();
>
> //volumeMapper->SetSampleDistance(1.0);
>
> //volumeMapper->SetInput(finalImg);
> volumeMapper->SetInput(reader->GetOutput());
>
> vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
>
> //show gray volume
> volumeProperty->IndependentComponentsOff();
> volumeProperty->SetScalarOpacity(tfun);
>
>
>
> vtkVolume *newvol = vtkVolume::New();
> newvol->SetMapper(volumeMapper);
> newvol->SetProperty(volumeProperty);
>
> vtkOutlineFilter *outline = vtkOutlineFilter::New();
> outline->SetInput((vtkDataSet *) reader->GetOutput());
>
> vtkPolyDataMapper *outlineMapper = vtkPolyDataMapper::New();
> outlineMapper->SetInput(outline->GetOutput());
>
> vtkActor *outlineActor = vtkActor::New();
> outlineActor->SetMapper(outlineMapper);
> outlineActor->GetProperty()->SetColor(1,1,1);
>
>
>
> //Create a KWWidgets Application
> vtkKWApplication *app = vtkKWApplication::New();
> app->SetRegistryLevel(0);
> app->PromptBeforeExitOff();
>
>
> vtkKWTopLevel *top = vtkKWTopLevel::New();
> top->SetApplication(app);
> top->Create();
>
>
> //Add a window for the application
> vtkKWWindow *win = vtkKWWindow::New();
> app->AddWindow(win);
> win->SecondaryPanelVisibilityOff();
> win->MainPanelVisibilityOff();
> win->Create();
>
>
> vtkKWRenderWidget *renderwidget = vtkKWRenderWidget::New();
> renderwidget->SetParent(win->GetViewFrame());
> renderwidget->Create();
> renderwidget->AddViewProp(newvol);
> renderwidget->CornerAnnotationVisibilityOn();
> app->Script("pack %s -expand y -fill both -anchor c -expand
> y",renderwidget->GetWidgetName());
>
> win->Display();
> app->Start();
>
>
>
> win->Display();
> app->Start();
>
>
> return(0);
>
> }
>
> Can someone please help me out.
>
> Thanks
>
> Sharwari
>
>
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061017/22e278aa/attachment.htm>
More information about the vtkusers
mailing list