Ubuntu 20.04 packaging.
[dcpomatic.git] / src / wx / timing_panel.cc
1 /*
2     Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #include "timing_panel.h"
22 #include "wx_util.h"
23 #include "film_viewer.h"
24 #include "timecode.h"
25 #include "content_panel.h"
26 #include "move_to_dialog.h"
27 #include "static_text.h"
28 #include "dcpomatic_button.h"
29 #include "lib/content.h"
30 #include "lib/image_content.h"
31 #include "lib/text_content.h"
32 #include "lib/dcp_subtitle_content.h"
33 #include "lib/audio_content.h"
34 #include "lib/string_text_file_content.h"
35 #include "lib/video_content.h"
36 #include "lib/dcp_content.h"
37 #include "lib/ffmpeg_content.h"
38 #include <dcp/locale_convert.h>
39 #ifndef __WXGTK3__
40 #include <gtk/gtk.h>
41 #endif
42 #include <boost/foreach.hpp>
43 #include <set>
44 #include <iostream>
45
46 using std::cout;
47 using std::string;
48 using std::set;
49 using boost::shared_ptr;
50 using boost::weak_ptr;
51 using boost::dynamic_pointer_cast;
52 using boost::optional;
53 using dcp::locale_convert;
54 using namespace dcpomatic;
55
56 TimingPanel::TimingPanel (ContentPanel* p, weak_ptr<FilmViewer> viewer)
57         /* horrid hack for apparent lack of context support with wxWidgets i18n code */
58         /// TRANSLATORS: translate the word "Timing" here; do not include the "Timing|" prefix
59         : ContentSubPanel (p, S_("Timing|Timing"))
60         , _viewer (viewer)
61         , _film_content_changed_suspender (boost::bind(&TimingPanel::film_content_changed, this, _1))
62 {
63         wxSize size = TimecodeBase::size (this);
64
65         for (int i = 0; i < 3; ++i) {
66                 _colon[i] = create_label (this, wxT(":"), false);
67         }
68
69         //// TRANSLATORS: this is an abbreviation for "hours"
70         _h_label = new StaticText (this, _("h"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL);
71 #ifndef __WXGTK3__
72         /* Hack to work around failure to centre text on GTK */
73         gtk_label_set_line_wrap (GTK_LABEL(_h_label->GetHandle()), FALSE);
74 #endif
75         //// TRANSLATORS: this is an abbreviation for "minutes"
76         _m_label = new StaticText (this, _("m"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL);
77 #ifndef __WXGTK3__
78         gtk_label_set_line_wrap (GTK_LABEL (_m_label->GetHandle()), FALSE);
79 #endif
80         //// TRANSLATORS: this is an abbreviation for "seconds"
81         _s_label = new StaticText (this, _("s"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL);
82 #ifndef __WXGTK3__
83         gtk_label_set_line_wrap (GTK_LABEL(_s_label->GetHandle()), FALSE);
84 #endif
85         //// TRANSLATORS: this is an abbreviation for "frames"
86         _f_label = new StaticText (this, _("f"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL);
87 #ifndef __WXGTK3__
88         gtk_label_set_line_wrap (GTK_LABEL(_f_label->GetHandle()), FALSE);
89 #endif
90
91         _position_label = create_label (this, _("Position"), true);
92         _position = new Timecode<DCPTime> (this);
93         _move_to_start_of_reel = new Button (this, _("Move to start of reel"));
94         _full_length_label = create_label (this, _("Full length"), true);
95         _full_length = new Timecode<DCPTime> (this);
96         _trim_start_label = create_label (this, _("Trim from start"), true);
97         _trim_start = new Timecode<ContentTime> (this);
98         _trim_start_to_playhead = new Button (this, _("Trim up to current position"));
99         _trim_end_label = create_label (this, _("Trim from end"), true);
100         _trim_end = new Timecode<ContentTime> (this);
101         _trim_end_to_playhead = new Button (this, _("Trim after current position"));
102         _play_length_label = create_label (this, _("Play length"), true);
103         _play_length = new Timecode<DCPTime> (this);
104
105         _video_frame_rate_label = create_label (this, _("Video frame rate"), true);
106         _video_frame_rate = new wxTextCtrl (this, wxID_ANY);
107         _set_video_frame_rate = new Button (this, _("Set"));
108         _set_video_frame_rate->Enable (false);
109
110         /* We can't use Wrap() here as it doesn't work with markup:
111          * http://trac.wxwidgets.org/ticket/13389
112          */
113
114         wxString in = _("<i>Only change this if the content's frame rate has been read incorrectly.</i>");
115         wxString out;
116         int const width = 20;
117         int current = 0;
118         for (size_t i = 0; i < in.Length(); ++i) {
119                 if (in[i] == ' ' && current >= width) {
120                         out += '\n';
121                         current = 0;
122                 } else {
123                         out += in[i];
124                         ++current;
125                 }
126         }
127
128         _tip = new StaticText (this, wxT (""));
129         _tip->SetLabelMarkup (out);
130 #ifdef DCPOMATIC_OSX
131         /* Hack to stop hidden text on some versions of OS X */
132         _tip->SetMinSize (wxSize (-1, 256));
133 #endif
134
135         _position->Changed.connect    (boost::bind (&TimingPanel::position_changed, this));
136         _move_to_start_of_reel->Bind  (wxEVT_BUTTON, boost::bind (&TimingPanel::move_to_start_of_reel_clicked, this));
137         _full_length->Changed.connect (boost::bind (&TimingPanel::full_length_changed, this));
138         _trim_start->Changed.connect  (boost::bind (&TimingPanel::trim_start_changed, this));
139         _trim_start_to_playhead->Bind (wxEVT_BUTTON, boost::bind (&TimingPanel::trim_start_to_playhead_clicked, this));
140         _trim_end->Changed.connect    (boost::bind (&TimingPanel::trim_end_changed, this));
141         _trim_end_to_playhead->Bind   (wxEVT_BUTTON, boost::bind (&TimingPanel::trim_end_to_playhead_clicked, this));
142         _play_length->Changed.connect (boost::bind (&TimingPanel::play_length_changed, this));
143         _video_frame_rate->Bind       (wxEVT_TEXT, boost::bind (&TimingPanel::video_frame_rate_changed, this));
144         _set_video_frame_rate->Bind   (wxEVT_BUTTON, boost::bind (&TimingPanel::set_video_frame_rate, this));
145
146         shared_ptr<FilmViewer> fv = _viewer.lock ();
147         DCPOMATIC_ASSERT (fv);
148         fv->ImageChanged.connect (boost::bind (&TimingPanel::setup_sensitivity, this));
149
150         setup_sensitivity ();
151         add_to_grid ();
152 }
153
154 void
155 TimingPanel::add_to_grid ()
156 {
157         bool const full = Config::instance()->interface_complexity() == Config::INTERFACE_FULL;
158
159         int r = 0;
160
161         wxSizer* labels = new wxBoxSizer (wxHORIZONTAL);
162         labels->Add (_h_label, 1, wxEXPAND);
163         add_label_to_sizer (labels, _colon[0], false);
164         labels->Add (_m_label, 1, wxEXPAND);
165         add_label_to_sizer (labels, _colon[1], false);
166         labels->Add (_s_label, 1, wxEXPAND);
167         add_label_to_sizer (labels, _colon[2], false);
168         labels->Add (_f_label, 1, wxEXPAND);
169         _grid->Add (labels, wxGBPosition(r, 1));
170         ++r;
171
172         add_label_to_sizer (_grid, _position_label, true, wxGBPosition(r, 0));
173         _grid->Add (_position, wxGBPosition(r, 1));
174         ++r;
175
176         _move_to_start_of_reel->Show (full);
177         _full_length_label->Show (full);
178         _full_length->Show (full);
179         _play_length_label->Show (full);
180         _play_length->Show (full);
181         _video_frame_rate_label->Show (full);
182         _video_frame_rate->Show (full);
183         _set_video_frame_rate->Show (full);
184         _tip->Show (full);
185
186         if (full) {
187                 _grid->Add (_move_to_start_of_reel, wxGBPosition(r, 1));
188                 ++r;
189
190                 add_label_to_sizer (_grid, _full_length_label, true, wxGBPosition(r, 0));
191                 _grid->Add (_full_length, wxGBPosition(r, 1));
192                 ++r;
193         }
194
195         add_label_to_sizer (_grid, _trim_start_label, true, wxGBPosition(r, 0));
196         _grid->Add (_trim_start, wxGBPosition(r, 1));
197         ++r;
198
199         _grid->Add (_trim_start_to_playhead, wxGBPosition(r, 1));
200         ++r;
201
202         add_label_to_sizer (_grid, _trim_end_label, true, wxGBPosition(r, 0));
203         _grid->Add (_trim_end, wxGBPosition(r, 1));
204         ++r;
205
206         _grid->Add (_trim_end_to_playhead, wxGBPosition(r, 1));
207         ++r;
208
209         if (full) {
210                 add_label_to_sizer (_grid, _play_length_label, true, wxGBPosition(r, 0));
211                 _grid->Add (_play_length, wxGBPosition(r, 1));
212                 ++r;
213
214                 {
215                         add_label_to_sizer (_grid, _video_frame_rate_label, true, wxGBPosition(r, 0));
216                         wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
217                         s->Add (_video_frame_rate, 1, wxEXPAND);
218                         s->Add (_set_video_frame_rate, 0, wxLEFT | wxRIGHT, 8);
219                         _grid->Add (s, wxGBPosition(r, 1), wxGBSpan(1, 2));
220                 }
221                 ++r;
222
223                 _grid->Add (_tip, wxGBPosition(r, 1), wxGBSpan(1, 2));
224         }
225
226         /* Completely speculative fix for #891 */
227         _grid->Layout ();
228 }
229
230 void
231 TimingPanel::update_full_length ()
232 {
233         set<DCPTime> check;
234         BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
235                 check.insert (i->full_length(_parent->film()));
236         }
237
238         if (check.size() == 1) {
239                 _full_length->set (_parent->selected().front()->full_length(_parent->film()), _parent->film()->video_frame_rate());
240         } else {
241                 _full_length->clear ();
242         }
243 }
244
245 void
246 TimingPanel::update_play_length ()
247 {
248         set<DCPTime> check;
249         BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
250                 check.insert (i->length_after_trim(_parent->film()));
251         }
252
253         if (check.size() == 1) {
254                 _play_length->set (_parent->selected().front()->length_after_trim(_parent->film()), _parent->film()->video_frame_rate());
255         } else {
256                 _play_length->clear ();
257         }
258 }
259
260 void
261 TimingPanel::film_content_changed (int property)
262 {
263         if (_film_content_changed_suspender.check(property)) {
264                 return;
265         }
266
267         int const film_video_frame_rate = _parent->film()->video_frame_rate ();
268
269         /* Here we check to see if we have exactly one different value of various
270            properties, and fill the controls with that value if so.
271         */
272
273         if (property == ContentProperty::POSITION) {
274
275                 set<DCPTime> check;
276                 BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
277                         check.insert (i->position ());
278                 }
279
280                 if (check.size() == 1) {
281                         _position->set (_parent->selected().front()->position(), film_video_frame_rate);
282                 } else {
283                         _position->clear ();
284                 }
285
286         } else if (
287                 property == ContentProperty::LENGTH ||
288                 property == ContentProperty::VIDEO_FRAME_RATE ||
289                 property == VideoContentProperty::FRAME_TYPE
290                 ) {
291
292                 update_full_length ();
293
294         } else if (property == ContentProperty::TRIM_START) {
295
296                 set<ContentTime> check;
297                 BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
298                         check.insert (i->trim_start ());
299                 }
300
301                 if (check.size() == 1) {
302                         _trim_start->set (_parent->selected().front()->trim_start (), film_video_frame_rate);
303                 } else {
304                         _trim_start->clear ();
305                 }
306
307         } else if (property == ContentProperty::TRIM_END) {
308
309                 set<ContentTime> check;
310                 BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
311                         check.insert (i->trim_end ());
312                 }
313
314                 if (check.size() == 1) {
315                         _trim_end->set (_parent->selected().front()->trim_end (), film_video_frame_rate);
316                 } else {
317                         _trim_end->clear ();
318                 }
319         }
320
321         if (
322                 property == ContentProperty::LENGTH ||
323                 property == ContentProperty::TRIM_START ||
324                 property == ContentProperty::TRIM_END ||
325                 property == ContentProperty::VIDEO_FRAME_RATE ||
326                 property == VideoContentProperty::FRAME_TYPE
327                 ) {
328
329                 update_play_length ();
330         }
331
332         if (property == ContentProperty::VIDEO_FRAME_RATE) {
333                 set<double> check_vc;
334                 shared_ptr<const Content> content;
335                 int count_ac = 0;
336                 int count_sc = 0;
337                 BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
338                         if (i->video && i->video_frame_rate()) {
339                                 check_vc.insert (i->video_frame_rate().get());
340                                 content = i;
341                         }
342                         if (i->audio && i->video_frame_rate()) {
343                                 ++count_ac;
344                                 content = i;
345                         }
346                         if (!i->text.empty() && i->video_frame_rate()) {
347                                 ++count_sc;
348                                 content = i;
349                         }
350
351                 }
352
353                 bool const single_frame_image_content = content && dynamic_pointer_cast<const ImageContent> (content) && content->number_of_paths() == 1;
354
355                 if ((check_vc.size() == 1 || count_ac == 1 || count_sc == 1) && !single_frame_image_content) {
356                         checked_set (_video_frame_rate, locale_convert<string> (content->video_frame_rate().get(), 5));
357                         _video_frame_rate->Enable (true);
358                 } else {
359                         checked_set (_video_frame_rate, wxT (""));
360                         _video_frame_rate->Enable (false);
361                 }
362         }
363
364         bool have_still = false;
365         BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
366                 shared_ptr<const ImageContent> ic = dynamic_pointer_cast<const ImageContent> (i);
367                 if (ic && ic->still ()) {
368                         have_still = true;
369                 }
370         }
371
372         _full_length->set_editable (have_still);
373         _play_length->set_editable (!have_still);
374         _set_video_frame_rate->Enable (false);
375         setup_sensitivity ();
376 }
377
378 void
379 TimingPanel::position_changed ()
380 {
381         DCPTime const pos = _position->get (_parent->film()->video_frame_rate ());
382         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
383                 i->set_position (_parent->film(), pos);
384         }
385 }
386
387 void
388 TimingPanel::full_length_changed ()
389 {
390         int const vfr = _parent->film()->video_frame_rate ();
391         Frame const len = _full_length->get (vfr).frames_round (vfr);
392         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
393                 shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (i);
394                 if (ic && ic->still ()) {
395                         ic->video->set_length (len);
396                 }
397         }
398 }
399
400 void
401 TimingPanel::trim_start_changed ()
402 {
403         shared_ptr<FilmViewer> fv = _viewer.lock ();
404         if (!fv) {
405                 return;
406         }
407
408         DCPTime const ph = fv->position ();
409
410         fv->set_coalesce_player_changes (true);
411
412         shared_ptr<Content> ref;
413         optional<FrameRateChange> ref_frc;
414         optional<DCPTime> ref_ph;
415
416         Suspender::Block bl = _film_content_changed_suspender.block ();
417         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
418                 if (i->position() <= ph && ph < i->end(_parent->film())) {
419                         /* The playhead is in i.  Use it as a reference to work out
420                            where to put the playhead post-trim; we're trying to keep the playhead
421                            at the same frame of content that we're looking at pre-trim.
422                         */
423                         ref = i;
424                         ref_frc = _parent->film()->active_frame_rate_change (i->position ());
425                         ref_ph = ph - i->position() + DCPTime (i->trim_start(), ref_frc.get());
426                 }
427
428                 ContentTime const trim = _trim_start->get (i->video_frame_rate().get_value_or(_parent->film()->video_frame_rate()));
429                 i->set_trim_start (trim);
430         }
431
432         if (ref) {
433                 fv->seek (max(DCPTime(), ref_ph.get() + ref->position() - DCPTime(ref->trim_start(), ref_frc.get())), true);
434         }
435
436         fv->set_coalesce_player_changes (false);
437 }
438
439 void
440 TimingPanel::trim_end_changed ()
441 {
442         shared_ptr<FilmViewer> fv = _viewer.lock ();
443         if (!fv) {
444                 return;
445         }
446
447         fv->set_coalesce_player_changes (true);
448
449         Suspender::Block bl = _film_content_changed_suspender.block ();
450         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
451                 ContentTime const trim = _trim_end->get (i->video_frame_rate().get_value_or(_parent->film()->video_frame_rate()));
452                 i->set_trim_end (trim);
453         }
454
455         /* XXX: maybe playhead-off-the-end-of-the-film should be handled elsewhere */
456         if (fv->position() >= _parent->film()->length()) {
457                 fv->seek (_parent->film()->length() - DCPTime::from_frames(1, _parent->film()->video_frame_rate()), true);
458         }
459
460         fv->set_coalesce_player_changes (false);
461 }
462
463 void
464 TimingPanel::play_length_changed ()
465 {
466         DCPTime const play_length = _play_length->get (_parent->film()->video_frame_rate());
467         Suspender::Block bl = _film_content_changed_suspender.block ();
468         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
469                 FrameRateChange const frc = _parent->film()->active_frame_rate_change (i->position ());
470                 i->set_trim_end (
471                         ContentTime (max(DCPTime(), i->full_length(_parent->film()) - play_length), frc) - i->trim_start()
472                         );
473         }
474 }
475
476 void
477 TimingPanel::video_frame_rate_changed ()
478 {
479         bool enable = true;
480         if (_video_frame_rate->GetValue() == wxT("")) {
481                 /* No frame rate has been entered; if the user clicks "set" now it would unset the video
482                    frame rate in the selected content.  This can't be allowed for some content types.
483                 */
484                 BOOST_FOREACH (shared_ptr<Content> i, _parent->selected()) {
485                         if (
486                                 dynamic_pointer_cast<DCPContent>(i) ||
487                                 dynamic_pointer_cast<FFmpegContent>(i)
488                                 ) {
489                                 enable = false;
490                         }
491                 }
492         }
493
494         _set_video_frame_rate->Enable (enable);
495 }
496
497 void
498 TimingPanel::set_video_frame_rate ()
499 {
500         optional<double> fr;
501         if (_video_frame_rate->GetValue() != wxT("")) {
502                 fr = locale_convert<double> (wx_to_std (_video_frame_rate->GetValue ()));
503         }
504         Suspender::Block bl = _film_content_changed_suspender.block ();
505         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
506                 if (fr) {
507                         i->set_video_frame_rate (*fr);
508                 } else {
509                         i->unset_video_frame_rate ();
510                 }
511         }
512
513         _set_video_frame_rate->Enable (false);
514 }
515
516 void
517 TimingPanel::content_selection_changed ()
518 {
519         setup_sensitivity ();
520
521         film_content_changed (ContentProperty::POSITION);
522         film_content_changed (ContentProperty::LENGTH);
523         film_content_changed (ContentProperty::TRIM_START);
524         film_content_changed (ContentProperty::TRIM_END);
525         film_content_changed (ContentProperty::VIDEO_FRAME_RATE);
526 }
527
528 void
529 TimingPanel::film_changed (Film::Property p)
530 {
531         if (p == Film::VIDEO_FRAME_RATE) {
532                 update_full_length ();
533                 update_play_length ();
534         }
535 }
536
537 void
538 TimingPanel::trim_start_to_playhead_clicked ()
539 {
540         shared_ptr<FilmViewer> fv = _viewer.lock ();
541         if (!fv) {
542                 return;
543         }
544
545         shared_ptr<const Film> film = _parent->film ();
546         DCPTime const ph = fv->position().floor (film->video_frame_rate ());
547         optional<DCPTime> new_ph;
548
549         fv->set_coalesce_player_changes (true);
550
551         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
552                 if (i->position() < ph && ph < i->end(film)) {
553                         FrameRateChange const frc = film->active_frame_rate_change (i->position());
554                         i->set_trim_start (i->trim_start() + ContentTime (ph - i->position(), frc));
555                         new_ph = i->position ();
556                 }
557         }
558
559         if (new_ph) {
560                 fv->seek (new_ph.get(), true);
561         }
562
563         fv->set_coalesce_player_changes (false);
564 }
565
566 void
567 TimingPanel::trim_end_to_playhead_clicked ()
568 {
569         shared_ptr<FilmViewer> fv = _viewer.lock ();
570         if (!fv) {
571                 return;
572         }
573
574         shared_ptr<const Film> film = _parent->film ();
575         DCPTime const ph = fv->position().floor (film->video_frame_rate ());
576         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
577                 if (i->position() < ph && ph < i->end(film)) {
578                         FrameRateChange const frc = film->active_frame_rate_change (i->position ());
579                         i->set_trim_end (ContentTime(i->position() + i->full_length(film) - ph - DCPTime::from_frames(1, frc.dcp), frc) - i->trim_start());
580                 }
581         }
582 }
583
584 void
585 TimingPanel::setup_sensitivity ()
586 {
587         bool const e = !_parent->selected().empty ();
588
589         _position->Enable (e);
590         _move_to_start_of_reel->Enable (e);
591         _full_length->Enable (e);
592         _trim_start->Enable (e);
593         _trim_end->Enable (e);
594         _play_length->Enable (e);
595         _video_frame_rate->Enable (e);
596
597         shared_ptr<FilmViewer> fv = _viewer.lock ();
598         DCPOMATIC_ASSERT (fv);
599         DCPTime const ph = fv->position ();
600         bool any_over_ph = false;
601         BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
602                 if (i->position() <= ph && ph < i->end(_parent->film())) {
603                         any_over_ph = true;
604                 }
605         }
606
607         _trim_start_to_playhead->Enable (any_over_ph);
608         _trim_end_to_playhead->Enable (any_over_ph);
609 }
610
611 void
612 TimingPanel::move_to_start_of_reel_clicked ()
613 {
614         /* Find common position of all selected content, if it exists */
615
616         optional<DCPTime> position;
617         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
618                 if (!position) {
619                         position = i->position();
620                 } else {
621                         if (position.get() != i->position()) {
622                                 position.reset ();
623                                 break;
624                         }
625                 }
626         }
627
628         MoveToDialog* d = new MoveToDialog (this, position, _parent->film());
629
630         if (d->ShowModal() == wxID_OK) {
631                 BOOST_FOREACH (shared_ptr<Content> i, _parent->selected()) {
632                         i->set_position (_parent->film(), d->position());
633                 }
634         }
635         d->Destroy ();
636 }