[vtkusers] Problem with creating a UI using KWWidgets
Ashish Singh
mrasingh at gmail.com
Wed Oct 18 13:07:37 EDT 2006
Hi Sharwari,
I was able to get rid of that error, it's because of some subsytem settings
in linker configuration in visual studio 2005.
Now I can see the widget, but my volume doesn't show up in it.
Here's my code:
----
#include "vtkRenderWindow.h"
#include "vtkCamera.h"
#include "vtkActor.h"
#include "vtkImageActor.h"
#include "vtkOutlineFilter.h"
#include "vtkProperty.h"
#include "vtkPolyDataNormals.h"
#include "vtkContourFilter.h"
#include "vtkDataSetMapper.h"
#include "vtkImageMapper.h"
#include "vtkPiecewiseFunction.h"
#include "vtkVolumeProperty.h"
#include "vtkRenderer.h"
#include "conio.h"
#include "vtkDICOMImageReader.h"
#include "vtkImageViewer2.h"
#include "vtkJPEGReader.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkVolumeMapper.h"
#include "vtkActor2D.h"
#include "vtkPolyDataMapper.h"
#include "vtkVolumeRayCastCompositeFunction.h"
#include "vtkFixedPointVolumeRayCastMapper.h"
#include "vtkColorTransferFunction.h"
#include "vtkLookupTable.h"
#include "vtkImageData.h"
#include "vtkImageMapToColors.h"
#include "vtkImageActor.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;
}
//my old volume render code
// vtkRenderer *arenderer = vtkRenderer::New();
// vtkRenderWindow *renwin = vtkRenderWindow::New();
vtkDICOMImageReader *img1=vtkDICOMImageReader::New();
img1->SetDirectoryName("D:\\testimages\\dicomset\\SE1");
img1->Update();
vtkPiecewiseFunction *opacityTransferFunction
=vtkPiecewiseFunction::New();
//opacityTransferFunction->AddPoint(20.0,0.0);
//opacityTransferFunction->AddPoint(255.0,0.2);
opacityTransferFunction->AddPoint(100.0,0.0);
opacityTransferFunction->AddPoint(200.0,1.0);
opacityTransferFunction->AddPoint(500.0,1.0);
opacityTransferFunction->AddPoint(510.0,0.0);
//opacityTransferFunction->AddPoint(300,0.4);
//opacityTransferFunction->AddPoint(350,0.4);
vtkColorTransferFunction * color = vtkColorTransferFunction::New();
color->AddRGBPoint(100.0, 1.0, 0.16, 0.18);
color->AddRGBPoint(200.0, 1.0, 0.94, 0.85);
color->AddRGBPoint(500.0, 1.0, 0.8, 0.98);
color->AddRGBPoint(510.0, 1.0, 0.63, 0.27);
vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
volumeProperty->SetScalarOpacity(opacityTransferFunction);
//volumeProperty->SetColor(color);
//volumeProperty->ShadeOn();
vtkVolume *vol=vtkVolume::New();
vtkFixedPointVolumeRayCastMapper *volumemapper =
vtkFixedPointVolumeRayCastMapper::New();
//vtkVolumeRayCastCompositeFunction
*rcf=vtkVolumeRayCastCompositeFunction::New();
//volumemapper->SetVolumeRayCastFunction(rcf);
volumemapper->SetInput(img1->GetOutput());
vol->SetProperty(volumeProperty);
vol->SetMapper(volumemapper);
vtkCamera *cam=vtkCamera::New();
cam->SetViewUp(0,0,-1);
cam->SetPosition(0,1,0);
cam->SetFocalPoint(0,0,0);
cam->ComputeViewPlaneNormal();
//cam->ParallelProjectionOn();
cam->Dolly(1.5);
// my old code till here
//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(vol);
renderwidget->CornerAnnotationVisibilityOn();
app->Script("pack %s -expand y -fill both -anchor c -expand
y",renderwidget->GetWidgetName());
win->Display();
app->Start();
return(0);
}
-------
Most of it is the same as yours, except for my dicom volume generation part.
Can you figure out what is wrong here?
Thanks,
Ashish
On 10/18/06, Sharwari Mavalankar <sharwari at gmail.com> wrote:
>
> hi Ashish,
> I dont think it's because of the cmakelist.txt file.
> I dont know what is causing this error.
> How does your code look?
> Sharwari
>
>
> On 10/18/06, Ashish Singh <mrasingh at gmail.com> wrote:
> >
> > Hi Sharwari,
> >
> > The errors I am getting are:
> >
> > Linking...
> > Creating library Debug\mygui.lib and object Debug\mygui.exp
> >
> > MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain at 16 referenced in function ___tmainCRTStartup
> >
> > Debug\mygui.exe : fatal error LNK1120: 1 unresolved externals
> >
> > Is it because of the cmakelist.txt file?
> >
> > Thanks,
> > Ashish
> >
> > On 10/17/06, Sharwari Mavalankar <sharwari at gmail.com > wrote:
> > >
> > > hi Ashish,
> > > What exactly was the error?
> > > Sharwari
> > >
> > >
> > > On 10/17/06, Ashish Singh <mrasingh at gmail.com > wrote:
> > > >
> > > > Hi Sharwari,
> > > >
> > > > I have these variables set to ON. I have already build vtk and
> > > > kwwidgets with TCL,TK options set to ON and tested it with examples. They
> > > > run fine.
> > > >
> > > > I think I didnt put the question correctly. What I was asking was
> > > > how does the cmakelist.txt file look like for the code you posted
> > > > here. I am making a GUI for my dicom volume rendering based on the code you
> > > > posted and when I build this GUI code that gives me linker error. So I was
> > > > thinking that maybe I am doing something wrong there. Can you please tell me
> > > > how the cmaklist.txt file look like for kwwidget GUI code?
> > > >
> > > >
> > > > Thanks,
> > > > Ashish
> > > >
> > > > On 10/17/06, Sharwari Mavalankar < sharwari at gmail.com > wrote:
> > > > >
> > > > > hi Ashish,
> > > > > The cmake file (for vtk) should have the following two variables
> > > > > set to ON.
> > > > > VTK_USE_TK and
> > > > > VTK_WRAP_TCL
> > > > > So try and build vtk again using these two cmake variables to ON
> > > > > and then build KWWidgets again.
> > > > > Let me know if it helps.
> > > > > Thanks
> > > > > Sharwari
> > > > >
> > > > >
> > > > >
> > > > > On 10/17/06, Ashish Singh <mrasingh at gmail.com > wrote:
> > > > > >
> > > > > > Hi Sharwari, I am getting a linker error for my dicom volume GUI
> > > > > > code (using KWWidgets) which is exactly similar to ur code above. I am not
> > > > > > sure if my cmakelist file is right. Can you plz. tell me what goes in the
> > > > > > cmakelist file?
> > > > > >
> > > > > > Thanks,
> > > > > > Ashish
> > > > > >
> > > > > > On 10/17/06, Ashish Singh <mrasingh at gmail.com > wrote:
> > > > > > >
> > > > > > > Hi Sharwari,
> > > > > > > How does the cmake file for your code look like? What all
> > > > > > > things need to go in the cmake file? is there an example you are following?
> > > > > > > So soes your volume finally show up ?
> > > > > > > I got Qt working with VTK but am stuck again with transfering
> > > > > > > data between Qt and vtk.
> > > > > > >
> > > > > > > Thanks,
> > > > > > > Ashish
> > > > > > >
> > > > > > >
> > > > > > > On 10/17/06, Amy Squillacote < amy.squillacote at kitware.com >
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > Hi Sharwari,
> > > > > > > >
> > > > > > > > I'm copying this back to the vtkusers list so other people
> > > > > > > > can see the resolution of your problem.
> > > > > > > >
> > > > > > > > - Amy
> > > > > > > >
> > > > > > > > Sharwari Mavalankar wrote:
> > > > > > > >
> > > > > > > > hi Amy,
> > > > > > > > Thanks for your email.
> > > > > > > > yes I have turned both the CMAKE variables to bool value
> > > > > > > > =ON.
> > > > > > > > But I realized that there were some .dll and .lib files that
> > > > > > > > had to be updated.
> > > > > > > > I did that and now that error is gone.
> > > > > > > > but thanks anyways!
> > > > > > > > Sharwari
> > > > > > > >
> > > > > > > > On 10/17/06, Amy Squillacote < amy.squillacote at kitware.com>
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > > > 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
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > > _______________________________________________
> > > > > > > > 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/20061018/b89eafff/attachment.htm>
More information about the vtkusers
mailing list