PDA

View Full Version : Qpainter function on a QFrame problem



impeteperry
21st January 2008, 22:58
i am doing a total re-write of a Qt3 program in Qt4
I am using Kubuntu 7.10 distro.
I have a QFrame area "frameA" that I want to use for my drawing (QpaintEvent ).
My Code:
void BaseForm::paintEvent ( QPaintEvent * event )
{
QString k, h;
double angle;
int n, xs, xe, ys, ye, xc, yc;
bool ok;
QPainter p ( this );

QPen pen;
QFont f;

if ( paintSupportLines.count () > 0 )
{
f.setFamily ( "Courier" );
f.setPointSize ( dwgScaleFactor );
p.setFont ( f );
pen.setBrush ( Qt::blue );
p.setPen ( pen );
p.setViewport ( viewportRect );
p.setWindow ( windowRect );

if ( clearWindow == "erase" ) { p.eraseRect ( windowRect ); clearWindow = "cancel erase"; }
else
{
for ( n = 0; n < paintSupportLines.count(); ++n )
{
p.setClipRect ( clippingRect );
k = paintSupportLines[n];
tempList = k.split ( "," );
xs = tempList[0].toInt ( &ok );
ys = tempList[1].toInt ( &ok );
xe = tempList[2].toInt ( &ok );
ye = tempList[3].toInt ( &ok );
p.drawLine ( xs, ys, xe, ye );
etc. I can single step thru the program, all values seem correct.,
Since I want to have my graphics in the "frameA" area of the screen I thought maybe I should change line #7 to "QPainter p( frameA )". but this did not help.

The code samples in "The Book of Qt 4" uses separate classes for their "QPaintEvent"s
Do I have to do that?

I would appreciate some help as I am at a total loss.

thanks

jpn
22nd January 2008, 10:18
If you want to draw on frameA, you must reimplement its paintEvent() instead of some other widget's paintEvent(), here BaseForm. In other words, you must implement paintEvent() of the widget you draw on.

impeteperry
22nd January 2008, 17:21
Thanks,
I am not sure on how to "reimplement its paintEvent()
I have
void BaseForm::slotSetPaintItems ( QStringList list )
{
QString k;
int n ;

for ( n = 0; n < list.count(); ++n )
{
tempList = list[n].split ( "|" ); /// split the list into types of stringLists
k = tempList[0]; /// get the type of element to draw
if(k == "erase") clearWindow = "erase";
else
{
tempList.removeFirst(); /// remove the element with the code
if(k == "supports") paintSupportLines = tempList; ///
else if (k == "columns") paintColumns = tempList;
else if(k == "erase") clearWindow = "true";
}
}
BaseForm::update(); /// now update it.
}Is this where I would do it if I knew How??
My original "frameA"
frameA = new QFrame ( this );
frameA->setFrameShape ( QFrame::StyledPanel );
frameA->setAutoFillBackground ( true );
frameA->setPalette ( QColor ( 255, 255, 235 ) );
frameA->setFrameShadow ( QFrame::Raised );
Again I would appreciate your help
pete

jpn
22nd January 2008, 17:34
Just like BaseForm does it. Subclass QFrame and reimplement paintEvent(). Again, BaseForm cannot paint on QFrame when BaseForm happens to receive a paint event. QFrame must do painting itself whenever it receives a paint event.

impeteperry
22nd January 2008, 18:14
Thanks again, but I am a very old tired frustrated engineer. Please give me the code to do this as everytime I try the program locks up.
thanks

Hold up I think I found what you are talking about. I will let you know how I make out.

impeteperry
24th January 2008, 18:47
I'm back.
I have not been able to make any headway. I have loaded examples from "Programming with Qt4", "The Book of Qt4". I have added all kinds of widgets to my QFrame frameA.
I have QPainter p( to all kinds of stuff ) .I can change size, add colors etc. But NO LINES!!
In Qt3 I had no trouble, even rendering solids, but not in Qt4.

I know it must be a very simple thing, but if you don't know it.......

I would love to see a simple working example that shows exactly what is necessary for drawing a line on a QFrame widget.

thanks

jpn
24th January 2008, 19:12
I have QPainter p( to all kinds of stuff )
You just can't paint on whatever widget you like to. You can't write

QPainter p(someOtherWidgetSomewhere);
but you make the some other widget somewhere do

QPainter p(this);
in its own paintEvent().



I would love to see a simple working example that shows exactly what is necessary for drawing a line on a QFrame widget.
As I said, you must subclass QFrame and reimplement paintEvent()


class MyCustomFrame : public QFrame
{
...
protected:
void paintEvent(QPaintEvent* event); // <-- a reimplemented method
};

MyCustomFrame::paintEvent(QPaintEvent* event)
{
QPainter painter(this); // <-- look, i can paint on myself
...
}

impeteperry
25th January 2008, 13:42
Hi, I have
#ifndef MYCUSTOMFRAME_H
#define MYCUSTOMFRAME_H

#include "baseform.h"
#include <qframe.h>
#include <qpainter.h>


class MyCustomFrame : public QFrame
{
Q_OBJECT

protected:
void paintEvent(QPaintEvent* event);
};

void MyCustomFrame::paintEvent(QPaintEvent* event)
{
QPainter painter(this);
painter.drawLine(0, 0, 200, 150);
}

#endif // MYCUSTOMFRAME_H
and it compiles with out errors or warnings.
I have 2 quentions:
1. How do I access it from the body of my program as I was required to remove "#include "mycustomframe.h" from "baseform.cpp"?

2. I have a class "drawingfunctions.h" where I would like to do the painting. If I read you correctly, I need to change the class name from
class DrawingFunctions : public QWidget
{
Q_OBJECT

public:
to
class DrawingFunctions : public QFrame
{
Q_OBJECT

public:
DrawingFunctions( QWidget *parent = 0 );
and i think the "parent = 0" is wrong.
And what do I need to change here?
DrawingFunctions::DrawingFunctions( QWidget *parent ) : QWidget(parent)As you can tell, i have no clear understanding of whats going on. I am able to use QTextEdit widgets on my base QFrame, but not the QPainter.
(These "uncontrolled" events of Qt4 are driving me up a wall.)

I really appreciate your patience with me.

impeteperry
27th January 2008, 19:14
I never have had as much trouble with anything I can remember.
As you suggested I setup a new class "MyDrawingFrame" and implemented it as best as I could. It compiles without any warnings
#ifndef MYDRAWINGFRAME_H
#define MYDRAWINGFRAME_H

#include "baseform.h"
#include <qframe.h>
#include <qpainter.h>

class MyDrawingFrame : public QFrame
{
Q_OBJECT

public:

public slots:

protected:
void paintEvent(QPaintEvent * event);

protected slots:

private:
QStringList tempList;
QStringList paintSupportLines;
QStringList paintColumns;
QString clearWindow;

QRect viewportRect;
QRect windowRect;
QRect clippingRect;
double pi;
int activeLevel;
int functionNumber;
int dwgScaleFactor;
int count;
int num;
int n;
int o1;

bool ok;

private slots:

signals:

};

void MyDrawingFrame::paintEvent(QPaintEvent * event)
{
QString k, h;
double angle;
int n, xs, xe, ys, ye, xc, yc;
bool ok;

QPainter p(this);
QPen pen;
QFont f;

if ( paintSupportLines.count () > 0 )
{
f.setFamily ( "Courier" );
f.setPointSize ( dwgScaleFactor );
p.setFont ( f );
pen.setBrush ( Qt::blue );
p.setPen ( pen );
p.setViewport ( viewportRect );
p.setWindow ( windowRect );

if ( clearWindow == "erase" ) { p.eraseRect ( windowRect ); clearWindow = "cancel erase"; }
else
{
for ( n = 0; n < paintSupportLines.count(); ++n )
{
//teErrorMessages->setText("F5 key clicked");
p.setClipRect ( clippingRect );
k = paintSupportLines[n];
tempList = k.split ( "," );
xs = tempList[0].toInt ( &ok );
ys = tempList[1].toInt ( &ok );
xe = tempList[2].toInt ( &ok );
ye = tempList[3].toInt ( &ok );
p.drawLine ( 10, 10 * n, 200, 200 );
p.drawLine ( xs, ys, xe, ye );
/// start of labeling.
if ( tempList[4] == "true" )
{
p.setClipRect ( windowRect );
xc = ( xs + xe ) / 2;
yc = ( ys + ye ) / 2;
if ( xs == xe ) angle = pi/2.0;
else if ( ys == ye ) angle = 0.0;
else
{
// angle = atan((double)(ye-ys)/(xe-xs)); /// Why did Qt 4 drop trig functions????
angle = ( double ) ( ye-ys ) / ( xe-xs ); /// hope this works!!!
angle /= 2.0 * pi ;
}
angle = ( angle * 180.0 ) / pi;
p.save();
p.translate ( xc, yc );
p.rotate ( angle ); //teErrorMessages->setText("F5 key clicked");
p.scale ( 1, -1 );
k = "S" + h.setNum ( n + 1 );
p.drawText ( 0, 0, k );
p.restore();
}
}
}
if ( paintColumns.count() > 0 )
{
p.setViewport ( viewportRect );
p.setWindow ( windowRect );
p.setClipRect ( windowRect );
for ( n = 0; n < paintColumns.count(); ++n )
{
k = paintColumns[n];
tempList = k.split ( "," );
xs = tempList[0].toInt ( &ok );
ys = tempList[1].toInt ( &ok );
xe = tempList[2].toInt ( &ok );
ye = tempList[3].toInt ( &ok );
angle = tempList[4].toInt ( &ok );
p.save();
p.translate ( xs, ys );
p.rotate ( angle );
p.fillRect ( -xe/2, -ye/2, xe, ye, Qt::black );
if ( tempList[5] == "true" )
{
f.setFamily ( "Courier" );
f.setPointSize ( ( int ) ( .8 * dwgScaleFactor ) );
p.setFont ( f );
pen.setBrush ( Qt::black );
p.setPen ( pen );
p.rotate ( -angle + 25 );
p.scale ( 1, -1 );
k = "---C" + h.setNum ( n + 1 );
p.drawText ( 0, 0, k );
}
p.restore();
}
}
}
}
#endif // MYDRAWINGFRAME_H
Great, but how do I access it to set the values of the variables and activate the paint event itself??. If I "#include "mydrawingframe.h" in my "baseframe.cpp" or anyplace else for that matter I get an
/home/pete/Desktop/pm-straight-C/pm/mydrawingframe.h:65: multiple definition of `MyDrawingFrame::paintEvent(QPaintEvent*)'
baseform.o:/home/pete/Desktop/pm-straight-C/pm/mydrawingframe.h:65: first defined here
collect2: ld returned 1 exit status
make: *** [pm] Error 1

I have also tried setting up a "mydrawingframe.cpp" but I could not get a "MyDrawingFrame::MydrawingFrame( Q??? *parent ) : Q???
t(parent) that did not give an error when compiling.
Sorry to be so long winded, but I am desperate. What in H--- am I missing??? All I want to do is draw some lines of a QFrame widget!!!!!

wysota
27th January 2008, 19:57
Have you seen this thread?

http://www.qtcentre.org/forum/f-qt-designer-3/t-promoting-qlabel-11504.html

Especially take a look at how the line is drawn depending on the size of the widget.

impeteperry
28th January 2008, 05:43
Thanks Mysota It was a great help.My big problem I forgot the line under the "public;" when defining the class. What ever you do, don't get old (I'm 81).

Now all I have to do is figure out how to set the size of the frame, but I"m going to bed it's 12:30.

Thanks again.

ashukla
28th January 2008, 05:54
Thanks Mysota It was a great help.My big problem Please mention the name correctly as Wysota, Qt Guru.

impeteperry
29th January 2008, 19:48
Wysots, Qi Guru, I'm sorry about the name. It was late and I don't see to well.
I have made some progress. I can draw some lines, so I am back at setting up my scaling functions.
I do have a question. In the distant past I wrote to a "pixmap". is there any advantage to that now with the paintEvent functionallity?
Thanks

impeteperry
30th January 2008, 19:02
Hi
I now have my painter working on my laptop whereI compiled the program.
It also runs on my desk computer as long as I don't re-compile it there. If I re-compile the same source code there it locks up the computer on the first "p.drawText" command. I have single stepped the program on both computers. Everything is the same. There is no problem with the "p.drawLine" command. If I option out the single p.drawText(x, y, "text"); line 16, the program runs fine.
p.drawLine ( xs, ys, xe, ye );
/// start of labeling.
if ( tempList[4] == "true" )
{
xc = ( xs + xe ) / 2;
yc = ( ys + ye ) / 2;
if ( xs == xe ) angle = pi/2.0;
else if ( ys == ye ) angle = 0.0;
else angle = atan((double)(ye - ys) / (double)(xe - xs));
angle = ( angle * 180.0 ) / pi;
p.save();
p.translate ( xc, yc );
p.rotate ( angle );
p.scale ( 1, -1 );
k = "S" + h.setNum ( n + 1 );
p.drawText ( 0, 0, k );
p.restore();
}
I am using the same Kubuntu 7.10 on each computer.
I am sorry to be such a pest.
Thanks for help.

wysota
30th January 2008, 20:51
What exactly is the widget supposed to display?

impeteperry
30th January 2008, 22:25
I have a bunch of lines and i label them with their number. the text I want to display is "S1" See attachment. These are "Grid" lines are used for locating building columns and other elements.
Except for the screen size the data is identical on the two computers. The lines draw correctly so the "viewWindow" and "viewPort" are set correctly. If I take the compiled program from the second machine, it runes fine on the firsrt machine.

In essense, the program compiled on the first computer runs fine on both computers
The program compiled on the second computer locks it up when run, but runs fine on the first computer.

wysota
30th January 2008, 22:44
Why don't you use QGraphicsView to make the visualization?

impeteperry
31st January 2008, 04:12
QGraphicsView was add in Qt4.2. I was unaware of its existance
Thanks, I will take a look at it.

impeteperry
31st January 2008, 05:18
I took a quick look at your QGraphicView and found
By default, the items are drawn onto the viewport by using a regular QPainter, and using default render hints.What would be the advantage using this when I already have the geometry and am already using the "painter" to draw items onto the "viewPort"?

wysota
31st January 2008, 09:19
Ease of handling. I don't say you should take that approach, but that if you have problems with one mechanism, try using another.

impeteperry
31st January 2008, 14:39
Well said.
I am still confused why a program compiled on one computer won't run on that computer, but will run on another one, I may try reinstalling Qt. but for now I will continue with the development of my program.
Thanks for your help and suggestions. Don't you ever sleep?
pete

impeteperry
1st February 2008, 20:01
I re-installed Qt-4 and all works now. Onward ever onword.
Thank you for your patience
pete

impeteperry
12th February 2008, 05:29
Hi, on the same subject.
My drawing is fine, but now I want to open a frame with a textEdit in it on top of the drawing with out the drawing showing through (help info) and when the frame is closed the drawinig is back. I thought Qt-4's "double buffering" took care of this.
Thanks

jpn
12th February 2008, 08:31
It's a matter of passing the QTextEdit widget a proper parent.

impeteperry
12th February 2008, 14:23
Thanks, it came to me last night what I was doing wrong.

impeteperry
24th March 2008, 18:28
I am still having problems which I have narrowed down to maybe a Qt problem.
I want to "show" a "help" box on a "QPainter" drawinq. I want to "toggle" this "box" by means of the keyboard "F1" key.
Line #4 in the following code activates a HelpFunction class to do this as has been suggested and line #5 does this in the painter function itself.
The first thumbnail just shows the drawing. The second shows the HelpFunction class "help box" after pressing the "F1" key.. The third shows the "help box" when generate by the painter itself.

///----------------------------------------------------------------------------Pb1
void BaseForm::slotPb1()
{
emit activate();
paintList.append("help");
emit displayErectionDrawing(paintList, helpFlag);
}
The code below is for the HelpFunction class. Below the horizontal line controls the toggle function.
Line 23 displays the status of the toggle so I can tell if the "F1" keystroke was received.

HelpFunction::HelpFunction(QWidget *parent) : QWidget(parent)
{
frameH = new QFrame();
frameH->setAutoFillBackground ( true );
frameH->setFrameShape ( QFrame::Box );
frameH->setPalette ( QColor ( 200, 200, 200 ) );
teHBox = new QTextEdit ( frameH );
teHBox->setAutoFillBackground(true);
teHBox->setPalette(QColor ( 210, 255, 255 ));
teHBox->setReadOnly ( true );
}
void HelpFunction::slotActivate()
{
emit getDrawingFrameSize ( &W, &H );
emit getTextListItem(2, &k);
frameH->setGeometry ( W - 350, H - 420, 350, 430 );
teHBox->setGeometry ( 10, 10, 330, 410 );
teHBox->setPlainText ( k );
emit showHelpFrame(frameH);
//--------------------------------------------------------------------------
if(helpFlag == false) k = "false";
else k = "true";
emit setMessageBox("help 15 helpFlag = " + k);
if(helpFlag == true) helpFlag = false;
else if(helpFlag == false) helpFlag = true;
else helpFlag = true;
}
There are several problems
1. the first time the "F1" key was pressed, the HelpFunction "help box" was displayed as shown in the second thumbnail.
2. After that, pressing the "F1" key had no effect.
3. Clicking anywhere on the screen with the left mouse button closed the HelpFunction "help box" and left the "painter" help box displayed.
4. Now the "F1" key toggled the "painter" help box.
5, If I changed line #3 of the HelpFunction class to "frameH = new QFrame(this);", the toggle worked fine for the "painter" box thumbnail #2.
6. CONCLUSION: When the "Help Function" box was displayed, the "F1" key was DEACTIVATED.

If we get problem #6 corrected, I would much prefer the "Box" to look like the "painter" box, but with scroll bars and the functionality of the QTextEdit widget.
If I am doing somthing wrong, I am including the pb1 and fk1clicked items which have worked flawlessly up to now.

connect ( Pb1, SIGNAL ( clicked() ), this, SLOT ( slotPb1() ) );
///--------------------------------------------------------Function Keys
connect ( this, SIGNAL ( fk1clicked() ), this, SLOT ( slotPb1() ) );

[/CODE]
void BaseForm::keyPressEvent ( QKeyEvent *k )
{
int n;
QString h;
n = k->key();
h = h.setNum ( n );
if ( k->key() == 16777264 && Pb1->text() != "-" ) emit fk1clicked();
if ( k->key() == 16777265 && Pb2->text() != "-" ) emit fk2clicked();

Thank you very much

impeteperry
29th March 2008, 03:04
Ok, I don't blame you all if you are fed up with me, but please give me a answer

Can I do what I want to in Qt4?

Thanks

wysota
30th March 2008, 20:10
You see... the problem is we are not seeing your problem :) I suggest you forget about F keys and all that stuff and focus on implementing a widget with properties that allow you to modify the behaviour of the widget. When you have that done, start thinking about function keys.

impeteperry
31st March 2008, 15:08
Thanks for your suggestion, but I'm afraid you are missing the point of my program.
I am an engineer and innovator in the building industry. I have had 2 growing problems with the computer industry over the past 35 years. The complexity of the user interface (look at Blender) and the CAD programs in principle

This may not be the proper forum for a discussion of this type. Please let me know if it is oK or suggest another Qt forum .

Thasks
pete perry

wysota
31st March 2008, 15:19
Thanks for your suggestion, but I'm afraid you are missing the point of my program.

I'm not. You're missing the point of your problem. You have problems with drawing, not with input events. That's why I say to make your widget draw in a predictable, reproducable and desirable way and only then add value to it, not the other way round.


I am an engineer and innovator in the building industry. I have had 2 growing problems with the computer industry over the past 35 years. The complexity of the user interface (look at Blender) and the CAD programs in principle

This may not be the proper forum for a discussion of this type. Please let me know if it is oK or suggest another Qt forum .

Please don't insult us. You know nothing of us or problems we are dealing with. At the same time you are asking for help with your problem, not the other way round.

As for one of your questions - switching to Qt4 is a good idea in general, especially that it will probably force or encourage you to do it the right way - using QGraphicsView and not drawing directly inside a frame. You should have used QCanvas...

Your code cries: refactor me! But what do I know.... I'm not dealing with problems complex enough to know anything about yours...

impeteperry
31st March 2008, 20:11
Sir, I am not insulting you, Qt or anybody else. I appreciate your effort to help me. so enough of that!

I thought the forum was for help on my problems using your product rather then the other way around.

The use of the "function/accelerator keys" for program control rather then the mouse is part and parcel of what I am trying to develop, right or wrong.

My problem is "I can show a "Help widget" on a painter by pressing a function key, but I can't delete it by pressing a function key". My Question is "what code to I need to add to my "help Widget to correct this problem"?

I see that Qt 4 no longer lists QCanvas, however I shall go back to square one, look at QGraphicView and see if I an do in Qt what I did in DOS.

Again, I am sorry if I offended you in any way, sometimes I don't express myself to well.

Thanks

I went to "examples" for QGraphicview and found collindingmice. Oh what a delightful examole!!!
I see there is layering there. Let you know how I make out.

Thanks again,

wysota
31st March 2008, 21:21
The use of the "function/accelerator keys" for program control rather then the mouse is part and parcel of what I am trying to develop, right or wrong.
But that's not the issue here. If you have other things working, adding accelerators is trivial. If something doesn't work, it means the problem is elsewhere.


My problem is "I can show a "Help widget" on a painter by pressing a function key, but I can't delete it by pressing a function key". My Question is "what code to I need to add to my "help Widget to correct this problem"?
You need to implement a paint event correctly, so that it takes into consideration the help widget. I'd add a property holding the help text to show and when the text is empty, hide the help and otherwise render the text. Something like:


class MyClass: public ... {
Q_OBJECT
Q_PROPERTY(QString helpText READ helpText WRITE setHelpText)
public:
//...
const QString &helpText() const { return m_helpText; }
public slots:
void setHelpText(const QString &txt) {
if(txt==m_helpText) return;
m_helpText = txt;
update();
}
void clearHelpText() { setHelpText(QString::null); }
protected:
void paintEvent(...){
QPainter p(this);
//...
if(!m_helpText.isEmpty()){
p.save();
//...
p.drawRect(...);
p.drawText(...);
p.restore();
}
}
};

Actually I'd use QCanvas or QGraphicsView...

impeteperry
31st March 2008, 22:01
Taking your advice, I am looking at QGraphicView-scene. As I said, I would start from scratch. This looks promising.

Being a bit mentally retarded at 82 and in need of an eye operation it will take a bit of time.

I am a little leery of QCanvas as it is no longer listed in the Qt documentation under "all classes". (I did some stuff with it under Qt 3).

wysota
31st March 2008, 22:34
QCanvas and QGraphicsView are very similar. There's even an article written by Andreas on QQ on porting QCanvas applications to Graphics View.

impeteperry
31st March 2008, 22:50
I'm confused. If QCanvas is not listed Qt4, do you mean go back to Qt3 or that If I worked in QCanvas in Qt3, I should not have any problem with QGraphicsview in Qt 4?

wysota
31st March 2008, 22:54
I mean use Qt4 and GV.

impeteperry
9th September 2008, 05:40
I'm back with another very confusing problem.
I have 2 versions of the same program. Call them A & B. I use
void MyDrawingFrame::slotSetPaintItems ( QStringList list )
{
int n;
for(n = 0; n < list.count(); ++n )
{
tempList = list[n].split("|"); /// split the list into types of stringLists
k = tempList[0]; /// get the type of element to draw
if(k == "erase") clearWindow = "erase";
else
{
tempList.removeFirst(); /// remove the element with the code
clearWindow = "false";
if(k=="supports")
paintSupportLines=tempList;
else if(k=="columns")
paintColumns=tempList;
else if(k=="help")
paintDrawHelpWindow=tempList;
else if(k=="erase")
clearWindow="true";
}
}
emit getDrawingFrameSize (&W,&H);
k = actionList.last();
tempList = k.split(",");
if(tempList[1] == "4") setGeometry (10,10,W ,H);
else setGeometry (10,10,0,0);
update();
}for both versions and as near as I can tell the same data. There are two stages. The first just displays the "support lines" and the second displays both the "support lines" and the "colums".(see attachments from version B) Version A is fine for just the support lines, but when trying to display both the program crashes with the following statement which I don't understand at all.
{ Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::operator[]", "index out of range");
detach(); return reinterpret_cast<Node *>(p.at(i))->t(); } I have replaced the "update" with "redraw" but same problem. I don't think the problem is in the "paint event" itself,

As usual I would appreciate any help you can give me.
thanks.

wysota
9th September 2008, 20:48
I'd say tempList has no items and so tempList[0] fails. Or it can have one value and tempList[1] fails.

Could you explain what is preventing you from using Qt4 and QGraphicsView?

impeteperry
10th September 2008, 06:08
I am going back and check my data as I am sure that is where it must be as you suggest, but I would like to know about the "{ Q_ASSERT_X(i >= 0 && i < p.size(),...." message. can it help me find where and what is the problem is?.

I looked at QGraphicsView, as you suggested earlier, but for some reason decided not to go there. I will however do so now and try to make a parallel program to the one I have now.

What I am trying to do as a structural engineer is write a parametric driven program to replace the current CAD programs used in the industry and one that someone can learn to use in a day or two by going back to a modified command line operation similar to one I had written in pre-dos days. I do not have any time restraints, but a need to get it right.

I took a quick look at "graphicsview" and noted it was a 2D program and the program i am trying to re-write was a 3D rendered structure
Thanks for you indulgence

wysota
10th September 2008, 08:10
I am going back and check my data as I am sure that is where it must be as you suggest, but I would like to know about the "{ Q_ASSERT_X(i >= 0 && i < p.size(),...." message. can it help me find where and what is the problem is?.
Not really. But a backtrace from a debugger will and I suggest you use one here. There is no point in guessing if the application itself can tell you what is wrong.


I looked at QGraphicsView, as you suggested earlier, but for some reason decided not to go there. I will however do so now and try to make a parallel program to the one I have now.
I really suggest you reconsider using GV. It's perfect for your usecase.


I took a quick look at "graphicsview" and noted it was a 2D program and the program i am trying to re-write was a 3D rendered structure
But you are rendering it on a 2D canvas, so everything is ok. If you want to have real 3D, consider using OpenGL with one of the viewer frameworks available for Qt.

impeteperry
12th September 2008, 18:53
Thanks
I am using opengl.

There are 2 parts to the program.
1. developing a library of concrete elements (columns, beams, plank, connection hardware etc.) using opengl.

2. defining where they go.

This in a replacement for conventional CAD! which is prone for errors resulting from a multiplicity of input points for a given item. (floor plan, excavations, wall sections and details);

I layout a set of grids( support lines)
select a level (1st, 2nd, 3rd etc floor, )
place columns from the column library and locate them on grid intersections
place beams from the beam library and locate them by their supporting columns
place plank from the plank library and locate them by their supporting beams

now, if a grid line is moved, the associated columns move, the beam location and spans change, the plank location and spans change.
Now is a change levels, the column length changes etc.

this is all done automatically. Sort of like a "solid modeler" which I had tried.

Sorry to be so verbose, and I thank you for you patients.

wysota
12th September 2008, 19:05
Hmm... honestly I don't see anything 3D in the second image you attached to the last post.

impeteperry
12th September 2008, 19:25
Hmm... honestly I don't see anything 3D in the second image you attached to the last post.
All right you are getting to me. This is a database that defines the total structure. Any change here changes everything. I am going away for a couple of weeks and try out your recommendations from scratch

Thanks again

wysota
12th September 2008, 20:02
Regardless of what the data is meant for, it is displayed as 2D, therefore suits well with the Graphics View architecture.

impeteperry
13th September 2008, 03:46
I am already incorporating QGraphicView (trying anyway) into my program.
Thanks again

pete.

impeteperry
14th October 2008, 12:43
Thanks for all the help. How do I close this posts so I can use some attachments on another post i want to make