Copying an object [message #17025] |
Tue, 31 August 1999 00:00  |
Waleed Al-Nuaimy
Messages: 12 Registered: July 1999
|
Junior Member |
|
|
Hi. How may one create an exact copy of an object?
In particular, I have an IDLgrModel containing other Models each wirth a
polygon object inside, and each little model is subjected to a number of
scale/translation/rotations. I want to create another Model identical to
this in all respects. Is there a direct way to do this?
Many thanks
Waleed Al-Nuaimy
Geo-Services International (UK) Ltd.
|
|
|
Re: Copying an object [message #17070 is a reply to message #17025] |
Fri, 03 September 1999 00:00  |
Ben Tupper
Messages: 186 Registered: August 1999
|
Senior Member |
|
|
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
David Fanning wrote:
<blockquote TYPE=CITE>
<p>P.S. Let's just say I should pay more attention to those
<br>tips that guy Flemming, or whoever he is, writes. :-)
<br> </blockquote>
I've been wondering about identity of this Flemming guy, also.
<pre>--
Ben Tupper
Bigelow Laboratory for Ocean Science
tupper@seadas.bigelow.org
Pemaquid River Company
pemaquidriver@tidewater.net</pre>
</html>
|
|
|
Re: Copying an object [message #17073 is a reply to message #17025] |
Fri, 03 September 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Stein Vidar Hagfors Haugan (steinhh@ulrik.uio.no) writes:
> Since the documentation for STRUCT_ASSIGN in 5.2.1 says
> that both destination and source may be an object reference
Ah, thanks for this, Stein Vidar. I tried STRUCT_ASSIGN
the other day because I had heard rumors it was suppose
to work with objects, but it failed miserably. Of course,
it didn't occur to me to look at the documentation and
find out it needed to be done inside an object method. :-)
Cheers,
David
P.S. Let's just say I should pay more attention to those
tips that guy Flemming, or whoever he is, writes. :-)
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: Copying an object [message #17074 is a reply to message #17025] |
Fri, 03 September 1999 00:00  |
steinhh
Messages: 260 Registered: June 1994
|
Senior Member |
|
|
Since the documentation for STRUCT_ASSIGN in 5.2.1 says
that both destination and source may be an object reference
when used inside an object method, the only "problem" is to make an
uninitialized instance of the object (like val = {STRUCT_NAME}).
But this could easily be implemented in an object's init method,
thus:
FUNCTION BLAH::INIT,....,CLONE=CLONE
IF OBJ_VALID(CLONE) THEN BEGIN
IF NOT OBJ_CLASS(CLONE) EQ OBJ_CLASS(SELF) THEN ... ;ERROR
STRUCT_ASSIGN,CLONE,SELF
RETURN,1
END
:
: ;; Non-clone initialization code
END
which would be called like this:
clone = OBJ_NEW('BLAH',CLONE=ORIGINAL)
Of course, this doesn't deal with issues of "parents" or other
pointers to the cloned objects. But this will have to be dealt
with for each specific type of object.
Regards,
Stein Vidar
|
|
|