Posts

Showing posts from May, 2014

Qt Signals and Slots, Connecting and Disconnecting

Image
Slots, slots everywhere... by Ramon Talavera Qt connects widgets by means of a nice designed scheme based on the idea that objectS may send signalS of different typeS to a single object instance: This is a screenshot of the example code running. The main application creates dialogs A and B and then connects the signal from A to the signal slot in B. I cannot believe I have clicked it 100 times to show you that it works... Declaring the signal:  A declares to be able to send signals of type ' somebodyClicked ': class ObjectADialog : public QDialog { Q_OBJECT public: explicit ObjectADialog(QWidget *parent = 0); ~ObjectADialog(); signals:      void somebodyClicked(QString who); protected: void closeEvent(QCloseEvent *event); private slots: void on_pushButton_clicked(); private: Ui::ObjectADialog *ui; }; Declaring the slot: B declares to contain a slot method for signals to connect to:   class ObjectBDialog : public QDialog

Generate a Finite Plane of a Given Size and Orientation Using its Normal Vector. OpenGL, Open Scene Graph.

*) Given a Plane with equation Ax+By+Cz+D=0 find two director vectors. *) Once obtained, vectors VD1 and VD2, find a third vector in the same plane VP that is perpendicular to VD1 plane ecuation: Ax+By+Cz+D=0, being (A,B,C) the director vector of the plane Getting two points in the plane: Given x=0, y=0 => Cz+D=0 -> Cz=-D/C ==> PointA=(0,0,-D/C) Given x=1, y=0 => A+Cz+D=0 -> Cz= -D-A -> z= (-D-A)/C   ==> PointB=(1,0,(-D-A)/C) Given x=0, y=1 => B+Cz+D=0 -> Cz= -D-B -> z= (-D-B)/C   ==> PointC=(0,1,(-D-B)/C) This was wrong, check code comments, solved there directorVectorOne= VectorFromPointAToPointB= (1,0, ((-D-A)/C)-(-D/C) ) = (1,0, (-D-A+D)/C ) = (1,0,-A/C) ) directorVectorTwo= VectorFromPointAToPointC= (0,1, ((-D-B)/C)-(-D/C) ) = (0,1, (-D-B+D)/C ) = (0,1, -B/C) ) TestVector_BC=(-1,1,(-D-B)/C-(-D-A)/C)) = (-1,1,(-B+A)/C) Example: 2x+y+8z-21=0 A=2 B=1 C=8  : Plane Normal Vector= (2