For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Calling TPrsStd_AISViewer::New(..) causes segfault

Björn Hagemeier's picture
Forums: 

Hello all,

I have trouble displaying anything in an V3d_View. As soon as I call

TPrsStd_AISViewer::New(document->Main(), myViewer);

the app crashes. Unfortunately the debugger has no more information about what methods are called below this level. The libs do not contain any debug info:-(
Does anyone have any idea what I could have done wrong when initializing the TDocStd_Document document?

Regards,

Björn

Patrik Müller's picture

Hi,

look if both handles (the document and the viewer) are ok.

regards,

Patrik Müller

Björn Hagemeier's picture

Dear Patrik,

thanks for your reply. For some reason I had commented out the initialization of the Viewer.
However, now the error occurs when calling V3d_View::FitAll() after inserting an object in the OCAF data structure.
As far as I can see, I'm doing almost everything the same way as the Sample apps shipping with OCC4.0 except I have a much cleaner class decomposition:-)

Björn

Patrik Müller's picture

Hi again,

look at this at the sample:

it would be easier for me if you show your initialization.

Patrik

Patrik Mueller's picture

Written to fast :-))

show me your initialisation. Perhaps it is easier seeing where the problem is.

Patrik

Björn Hagemeier's picture

Hi Patrik,

some explanation:

Every document (using my own class here) has a vector of windows containing views and, of course, a Handle(TDocStd_Document) document.
After adding a Box (methods for other objects look just the same) I want to call FitAll on all the views. Currently there's only one view per document, but that will change in the future.
One strange thing is:
A couple of minutes ago I commented out the automatic call to FitAll and everything worked fine when i called FitAll from a different location later.

Maybe you have an idea.

Adding a Box:

void PM_Document_t::createBox(void) {

document->NewCommand();
PadMesh::ShapeDrivers::ShapeCreator_t shapeCreator(document->Main());

TDF_Label L = shapeCreator.createBox(.0, .0, .0, .1, .1, .1);

Handle(TPrsStd_AISPresentation) prs = TPrsStd_AISPresentation::Set(
L, TNaming_NamedShape::GetID());

prs->SetColor(Quantity_NOC_GOLDENROD);
prs->Display(1);

// update all views here
for (vector::iterator p = docWindows->begin();
p != docWindows->end();
p++)
{
int i = 0;
((PM_MDIWindow_t*) p)->fitView();
#ifdef DEBUG
cout #endif
}

#ifdef DEBUG
cout #endif

TDataStd_Integer::Set(L, 1);
myCtx->UpdateCurrentViewer();

document->CommitCommand();

#ifdef DEBUG
printOCAFTree();
#endif
}

Initialization of the view (being called on first paint-Event):

void PM_View_t::init(
void)
{
#ifdef DEBUG
cout #endif

// myView = myCtx->CurrentViewer()->CreateView();
myView = document->getViewer()->CreateView();

int windowHandle = (int) winId();
short hi, lo;
lo = (short) windowHandle;
hi = (short) (windowHandle >> 16);

Handle(Xw_Window) hWnd = new Xw_Window(Handle(Graphic3d_GraphicDevice)::
DownCast(myCtx->CurrentViewer()->
Device()),
(int) hi, (int) lo,
Xw_WQ_3DQUALITY, Quantity_NOC_BLACK);

myView->SetWindow(hWnd);
if (!hWnd->IsMapped()) hWnd->Map();
myView->MustBeResized();
}

Patrik Mueller's picture

I do it this way:

for (this->GetViewer()->InitActiveViews();
this->GetViewer()->MoreActiveViews();
this->GetViewer()->NextActiveViews())
{
this->GetViewer()->ActiveView()->FitAll();

GetViewer() gives me the V3d_Viewer handle.

try that in Debug mode and look where it crashes.

HTH,
Patrik

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.