
Wed, 08/24/2011 - 10:33
Hello There,
is there anyway of passing a TopoDS_Shape as a signal and slot argument.
I have been trying to no success.
when i call emit finishshape( myshape) the connected SLOTS are not called, i switch the signature of my SIGNAL AND SLOT to work with an int and it works, so it seems like the SIGNAL and SLOT mechanism in QT works only with standard types and QObject types, or i could be mistaken.
is this connected to the fact the TopoDS_Shape doesnt have a == operator and or its const & definition? ---> dont quote me on any of this, im not a computer scientist, so i dont understand most of these concepts.
my last resort will be to make a simple QObject wrapper that contains a TopoDS_Shape and use it as a message object.
I am trying to avoid this option, hopefully the solution could be solve with a typedef.
Best,
AlexP
**************************************
this is my class:
#pragma once
#include
#include
class booleanthread : public QThread
{
Q_OBJECT
public:
booleanthread(QObject *parent = 0,TopoDS_Shape& sh1 = TopoDS_Shape(),TopoDS_Shape& sh2 = TopoDS_Shape())
: QThread(parent),theshape1(sh1),theshape2(sh2)
{
int nullcount = 0;
if(sh1.IsNull()) nullcount++;
if(sh2.IsNull()) nullcount++;
theshape1 = sh1;
theshape2 = sh2;
if(theshape1.IsNull()) nullcount++;
if(theshape2.IsNull()) nullcount++;
inputs
};
~booleanthread(void);
signals:
void finishedshape(TopoDS_Shape newval);
protected:
void run();
private:
TopoDS_Shape& theshape1;
TopoDS_Shape& theshape2;
QList
};
#include "booleanthread.h"
#include
#include
booleanthread::~booleanthread(void)
{
}
void booleanthread::run()
{
//BRepAlgoAPI_BooleanOperation* myop = new BRepAlgoAPI_BooleanOperation(obj1, obj2, BOP_COMMON);
//myop->Build();
//TopoDS_Shape result = myop->Shape();
//int counter = 0;
// if(theshape1.IsNull()) return;
// if(theshape2.IsNull()) return;
//BRepAlgoAPI_Common* bcom = new BRepAlgoAPI_Common(theshape1,theshape2);
TopoDS_Shape intcrv = hsf::move(theshape1,gp_Vec(0,0,10));
emit finishedshape(intcrv);
/*try{ const TopoDS_Shape & result = bcom->Shape();
emit finishedshape(result);
} catch(...) {
int errorstat = bcom->ErrorStatus();
qDebug()
}
*/
//while(!bcom->IsDone())
// {
//
//
// }
/*const TopoDS_Shape & result = bcom->Shape();*/
//int nbp;
//TopoDS_Shape result = hsf::AddNewIntersectionPointMulti(obj1,obj2);
};
**************************************************
// i am calling from this other code on the main function.
booleanthread* bt = new booleanthread(this,shapelist[0],EOS);
threadlist
connect(threadlist.last(),SIGNAL(finishedshape( TopoDS_Shape )),this,SLOT(appendtolist( TopoDS_Shape )));
threadlist.last()->start();
Wed, 08/24/2011 - 11:59
Hi,
perhaps the type has to be marshaled. Have a look at:
http://doc.qt.nokia.com/latest/qmetatype.html#details
I had to
Q_DECLARE_METATYPE(TopoDS_Shape);
to use TopoDS_Shape with QVariant
Regards
SK
Wed, 08/24/2011 - 13:08
Alex,
Use const TopoDS_Shape& and not TopoDS_Shape. This will avoid unnecessary copying. No Qt declaration is required.
HTH.
Roman
Wed, 08/24/2011 - 16:04
Thank you very much Roman. will test this immediately.
Best
AlexP
Wed, 08/24/2011 - 16:02
Thanks spam killer!
Wed, 08/24/2011 - 18:09
Maybe its just me, but wouldn't it make sense to access the TopoDS_Shape by handle, then you could use something like a simple pointer to a Handle_TopoDS_Shape to pass the object pointer in the signal, which you could de-ref in the slot. I've successfully tried this in the past.
Pete
Sat, 08/27/2011 - 03:41
Dear Peter,
Thanks for the tip, didn't know you could make a handle of the TopoDS_Shape, nice to know.
Best,
AlexP
Sat, 08/27/2011 - 13:36
Apologies - its the TopoDS_TShape that can be accessed by handle.
Pete
Sat, 08/27/2011 - 13:47
... Although there is a handle wrapper class as well TopoDS_HShape.
Fri, 08/26/2011 - 18:50
Hello Alex,
to use a new type in signal/slot BETWEEN THREAD (it's not needed if it's not between thread), you need to register the argument with Qt first, like this:
qRegisterMetaType("TopoDS_Shape");
Good Luck,
Francois.
Sat, 08/27/2011 - 03:39
Dear Francois,
Thank You very much, will try this one out right now, im new to threading! thanks for the tip.
Best,
AlexP