Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF3D » Problem getting Draw3d to draw something
Problem getting Draw3d to draw something [message #2286] Mon, 13 April 2009 00:28 Go to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5469
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040800040307000704080608
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit

Hi,

I tried to wrap my head around Draw3d a bit and play around with it but
didn't managed to get a simple example working (I simply wanted to draw
a rectangle).

Could someone please correct the code from below for me?

Tom

--------------040800040307000704080608
Content-Type: text/plain;
name="View.java"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="View.java"

cGFja2FnZSB0ZXN0M2Q7CgppbXBvcnQgb3JnLmVjbGlwc2UuZHJhdzJkLkZp Z3VyZTsKaW1w
b3J0IG9yZy5lY2xpcHNlLmRyYXcyZC5HcmFwaGljczsKaW1wb3J0IG9yZy5l Y2xpcHNlLmRy
YXcyZC5MaWdodHdlaWdodFN5c3RlbTsKaW1wb3J0IG9yZy5lY2xpcHNlLmRy YXcyZC5YWUxh
eW91dDsKaW1wb3J0IG9yZy5lY2xpcHNlLmRyYXcyZC5nZW9tZXRyeS5Qb2lu dDsKaW1wb3J0
IG9yZy5lY2xpcHNlLmRyYXczZC5EcmF3M0RDYW52YXM7CmltcG9ydCBvcmcu ZWNsaXBzZS5k
cmF3M2QuRmlndXJlM0Q7CmltcG9ydCBvcmcuZWNsaXBzZS5kcmF3M2QuTGln aHR3ZWlnaHRT
eXN0ZW0zRDsKaW1wb3J0IG9yZy5lY2xpcHNlLmRyYXczZC5SZW5kZXJDb250 ZXh0OwppbXBv
cnQgb3JnLmVjbGlwc2UuZHJhdzNkLlhZWkxheW91dDsKaW1wb3J0IG9yZy5l Y2xpcHNlLnN3
dC5TV1Q7CmltcG9ydCBvcmcuZWNsaXBzZS5zd3QubGF5b3V0LkZpbGxMYXlv dXQ7CmltcG9y
dCBvc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JlLnNldExheW91dE1hbmFnZXIobmV3IFhZWkxheW91dCgpKTsK CQlsd3Muc2V0
Q29udGVudHMocm9vdEZpZ3VyZSk7CgkJCgkJRHJhdzNEQ2FudmFzIGN2cyA9 IERyYXczRENh
bnZhcy5jcmVhdGVDYW52YXMocGFyZW50LCBTV1QuTk9ORSwgbHdzKTsKCQlj dnMuc2V0QmFj
a2dyb3VuZChwYXJlbnQuZ2V0RGlzcGxheSgpLmdldFN5c3RlbUNvbG9yKFNX VC5DT0xPUl9E
QVJLX1JFRCkpOwoKCX0KCgkvKioKCSAqIFBhc3NpbmcgdGhlIGZvY3VzIHJl cXVlc3QgdG8g
dGhlIHZpZXdlcidzIGNvbnRyb2wuCgkgKi8KCXB1YmxpYyB2b2lkIHNldEZv Y3VzKCkgewoJ
CQoJfQp9
--------------040800040307000704080608--
Re: Problem getting Draw3d to draw something [message #2318 is a reply to message #2286] Mon, 13 April 2009 12:03 Go to previous message
Jens von Pilgrim is currently offline Jens von PilgrimFriend
Messages: 295
Registered: July 2009
Senior Member
Hi Tom,

frankly we haven't yet tested or used Draw3D "outside" GEF3D. I have
created a view in the graph example which uses Draw3D without GEF3D:
org.eclipse.gef3d.examples.graph.editor.Draw3DViewPart. You simply have
to update the graph example and test the view in action. Since no
camera tool is provided, you cannot move around of course. But at least
you could get an impression on how to initialize the Draw3DCanvas and
the LightweightSystem3D. This will hopefully help.

Cheers

Jens

For your convenience, here is the initialization snippet from the
example. The initial camera position is set to look at (0,0,0) from
(0,0,-1000). See my posting on April 1st (Re: Draw3d Program) for
details about that.

@Override
public void createPartControl(Composite parent) {
// some composite
Composite c = new Composite(parent,SWT.NONE);
c.setLayout(new FillLayout());

// create a Draw3DCanvas inside:
LightweightSystem3D lws3D = new LightweightSystem3D();
lws3D.setDrawAxes(true);
canvas = Draw3DCanvas.createCanvas(c, SWT.NONE,
lws3D);
lws3D.setControl(canvas);

// create some figures:
...

// set content of lightweight system:
lws3D.setContents(graphFigure);

}
Re: Problem getting Draw3d to draw something [message #561234 is a reply to message #2286] Mon, 13 April 2009 12:03 Go to previous message
Jens von Pilgrim is currently offline Jens von PilgrimFriend
Messages: 295
Registered: July 2009
Senior Member
Hi Tom,

frankly we haven't yet tested or used Draw3D "outside" GEF3D. I have
created a view in the graph example which uses Draw3D without GEF3D:
org.eclipse.gef3d.examples.graph.editor.Draw3DViewPart. You simply have
to update the graph example and test the view in action. Since no
camera tool is provided, you cannot move around of course. But at least
you could get an impression on how to initialize the Draw3DCanvas and
the LightweightSystem3D. This will hopefully help.

Cheers

Jens

For your convenience, here is the initialization snippet from the
example. The initial camera position is set to look at (0,0,0) from
(0,0,-1000). See my posting on April 1st (Re: Draw3d Program) for
details about that.

@Override
public void createPartControl(Composite parent) {
// some composite
Composite c = new Composite(parent,SWT.NONE);
c.setLayout(new FillLayout());

// create a Draw3DCanvas inside:
LightweightSystem3D lws3D = new LightweightSystem3D();
lws3D.setDrawAxes(true);
canvas = Draw3DCanvas.createCanvas(c, SWT.NONE,
lws3D);
lws3D.setControl(canvas);

// create some figures:
...

// set content of lightweight system:
lws3D.setContents(graphFigure);

}
Previous Topic:Problem getting Draw3d to draw something
Next Topic:Signature of IFigure3D.render(..) and other similar methods changed
Goto Forum:
  


Current Time: Fri Nov 28 07:25:11 GMT 2014

Powered by FUDForum. Page generated in 0.19878 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software