Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6492 > unrolled thread

Re: Problem displaying user-created .cdf files

Started byJohn Fultz <jfultz@wolfram.com>
First post2011-11-17 11:08 +0000
Last post2011-11-20 10:47 +0000
Articles 6 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Problem displaying user-created .cdf files John Fultz <jfultz@wolfram.com> - 2011-11-17 11:08 +0000
    Re: Problem displaying user-created .cdf files Gary <gpalmerlv@gmail.com> - 2011-11-19 11:54 +0000
    Re: Problem displaying user-created .cdf files Gary <gpalmerlv@gmail.com> - 2011-11-19 11:54 +0000
      Re: Problem displaying user-created .cdf files Gary <gpalmerlv@gmail.com> - 2011-11-20 10:36 +0000
      Re: Problem displaying user-created .cdf files Gary <gpalmerlv@gmail.com> - 2011-11-20 10:45 +0000
      Re: Problem displaying user-created .cdf files Gary <gpalmerlv@gmail.com> - 2011-11-20 10:47 +0000

#6492 — Re: Problem displaying user-created .cdf files

FromJohn Fultz <jfultz@wolfram.com>
Date2011-11-17 11:08 +0000
SubjectRe: Problem displaying user-created .cdf files
Message-ID<ja2pvl$mak$1@smc.vnet.net>
Does the content appear in a *fresh* session of Mathematica, after you've newly 
opened the notebook and have evaluated no cells at all (including initialization 
cells)?

One common failure that happens in this regard is that the CDF relies on some 
state in the kernel which is not automatically established, but requires 
Shift+Enter evaluations to establish.  Here's a very simple example:

(* Bad!! *)
f[x_] := Sin[x]
Manipulate[f[x], {x, 0, 10}]

The definition of f will be lost in any new session of Mathematica or Player.  
But, of course, it will appear to have worked while you were authoring it.

In the specific case of Manipulate, there are generally two ways to resolve
this.  You can use the "automatic" method...the SaveDefinitions option:

(* Good example #1 *)
f[x_] := Sin[x]
Manipulate[f[x], {x, 0, 10}, SaveDefinitions->True]

This works quite nicely, but for very complex examples (particularly when 
packages need to be loaded), SaveDefinitions automatic methods can either fail 
or produce an unnecessarily large (in terms of file size) result.

The other method involves making sure that you properly localize everything.
Depending upon your code, this might involve the use of DynamicModules, 
Initialization options, or other devices.  In this case of the example I 
provide, it's a fairly straightforward Initialization option:

(* Good example #2 *)
Manipulate[f[x], {x, 0, 10}, Initialization:>(f[x_] := Sin[x])]

I am guessing a bit as to the exact nature of your problem based upon your 
description.  It's possible that it might be some other sort of issue which I 
didn't describe, like for example a limitation of the sandbox environment that 
the web browser plugin runs in.  If my explanation above didn't help, then what 
you really need to send for people to help debug your problem is the CDF itself.

Sincerely,

John Fultz
jfultz@wolfram.com
User Interface Group
Wolfram Research, Inc.


On Wed, 16 Nov 2011 04:46:46 -0500 (EST), Gary wrote:
> The cdf. files that I create do not display properly. They can be
> opened, viewed, and manipulated with Mathematica, but CDF Player is
> able to display them only partially, even after enabling Dynamics. The
> same problem occurs when they open in a web page.
>
> I get the right size box and properly labeled axes, but a tan
> background (the intended one is light yellow). The four sliders appear
> properly labeled above the display window, but none of the real
> content (a disk, three arrows, and a sphere) of the demonstration
> appears. The slider buttons slide, but since there are no objects in
> the display, they can't do anything.
>
> To the best of my knowledge, I followed all the instructions for
> preparing the .cdf file: close unwanted cells, hide brackets, enable
> Deployed in Cell Options --> General Properties --> Deployed, making
> sure that the file "rotate_demo.cdf" was selected in the menu of the
> Options for Global Preferences dialog. I saved the file as .cdf using
> the menu choice in the save dialog. I tried each of the following two
> html tags in a web page.
>
> <script src="http://www.wolfram.com/cdf-player/plugin/v1.0/
> cdfplugin.js"
> type="text/javascript"></script><script type="text/javascript">// <!
> [CDATA[
> var cdf = new cdf_plugin();
> cdf.addCDFObject("rotate_demo_applet", "rotate_demo.cdf", 800, 800);
> // ]]></script>
>
> <embed src="rotate_demo.cdf" width="1000" height="1000">
>
> Files downloaded from Wolfram's demonstration .cdf files and opened in
> in either a browser or the CDF Player display and operate properly, so
> it seems the error must occur when the files are created.  Any ideas?
>
> Mathematica 8, iMac, OS X 10.6.8, Chrome, Firefox


[toc] | [next] | [standalone]


#6539

FromGary <gpalmerlv@gmail.com>
Date2011-11-19 11:54 +0000
Message-ID<ja85di$ikq$1@smc.vnet.net>
In reply to#6492
I took John's suggestion and added SaveDefinitions --> True to the
Manipulate[] options. This seemed to solve the problem, in that I was
able to save a notebook as a cdf file and display it in both the CDF
Player and on a web page on a remote server where I have an account
<faculty.unlv.edu/gbp/mma/rotate_on_arbit_axes.html>. I won't
guarantee to leave that page up indefinitely, but I will leave it for
a week, but you may not be able to access it anyway for reasons that
follow in (1).

But solving this problem seemed to lead to other problems, to wit:
(1) The site mentioned above does not always work. It worked for me
the first couple of times and it worked for a friend. But I now find
that it somes up with a dialog and a button which disappear before I
can read or select them, leaving me with a gray square. I tried
deleting cookies and history in Firefox, with the result that opening
the cdf web page now produces a solid black page in that browser. Is
it possible that in creating a very large display (width = 1400 height
= 1100) I exceeded the capacity of the browser or the Player? I have
reduced the display dimensions in the web page now to 600 x 400, and
it tries to display, but leaves only the gray panel after the
permissions dialog flickers twice.
(2) On opening Mathematica Home Edition 8, I now find that the Open...
link on the opening panel doesn't work. This is not a big deal,
because I can still open files from the File menu, but it is a
nuisance. The Wolfram CDF Player functions properly.
(3) More problematic, I find that the Open Option Inspector button in
the Preferences --> Advanced panel is now grayed out and
dysfunctional. Since the file I was working with had the brackets
hidden with Display Options --> ShowCellBrackets --> False, that file
is now practically uneditable because I need the brackets to profile
the cell boundaries. Furthermore, I have no way of setting other
options or of knowing which options are set. Is there a way to restore
the function of this important button?

In attempting to fix these problems, I repaired disk permissions with
the Disk Utility and reinstalled Mathematica 8 from the diskette. That
produced no improvement. The Open... and Open Option Inspector buttons
still don't work. The browsers appear to be working well on all other
sites that I use. What now? Have these problems been seen before or am
I uniquely talented at unintentionally disorganizing a perfectly good
computer program?

Mathematica Home Edition 8, iMac, OS X 10.6.8, Chrome, Firefox

On Nov 17, 6:08 am, John Fultz <jfu...@wolfram.com> wrote:
> Does the content appear in a *fresh* session of Mathematica, after you've newly
> opened the notebook and have evaluated no cells at all (including initial ization
> cells)?
>
> One common failure that happens in this regard is that the CDF relies on some
> state in the kernel which is not automatically established, but requires
> Shift+Enter evaluations to establish.  Here's a very simple example:
>
> (* Bad!! *)
> f[x_] := Sin[x]
> Manipulate[f[x], {x, 0, 10}]
>
> The definition of f will be lost in any new session of Mathematica or Player.
> But, of course, it will appear to have worked while you were authoring it.
>
> In the specific case of Manipulate, there are generally two ways to resolve
> this.  You can use the "automatic" method...the SaveDefinitions option:
>
> (* Good example #1 *)
> f[x_] := Sin[x]
> Manipulate[f[x], {x, 0, 10}, SaveDefinitions->True]
>
> This works quite nicely, but for very complex examples (particularly when
> packages need to be loaded), SaveDefinitions automatic methods can either fail
> or produce an unnecessarily large (in terms of file size) result.
>
> The other method involves making sure that you properly localize everything.
> Depending upon your code, this might involve the use of DynamicModules,
> Initialization options, or other devices.  In this case of the example I
> provide, it's a fairly straightforward Initialization option:
>
> (* Good example #2 *)
> Manipulate[f[x], {x, 0, 10}, Initialization:>(f[x_] := Sin[x])]
>
> I am guessing a bit as to the exact nature of your problem based upon your
> description.  It's possible that it might be some other sort of issue which I
> didn't describe, like for example a limitation of the sandbox environment that
> the web browser plugin runs in.  If my explanation above didn't help, then what
> you really need to send for people to help debug your problem is the CDF itself.
>
> Sincerely,
>
> John Fultz
> jfu...@wolfram.com
> User Interface Group
> Wolfram Research, Inc.
>
>
>
>
>
>
>
> On Wed, 16 Nov 2011 04:46:46 -0500 (EST), Gary wrote:
> > The cdf. files that I create do not display properly. They can be
> > opened, viewed, and manipulated with Mathematica, but CDF Player is
> > able to display them only partially, even after enabling Dynamics. The
> > same problem occurs when they open in a web page.
>
> > I get the right size box and properly labeled axes, but a tan
> > background (the intended one is light yellow). The four sliders appear
> > properly labeled above the display window, but none of the real
> > content (a disk, three arrows, and a sphere) of the demonstration
> > appears. The slider buttons slide, but since there are no objects in
> > the display, they can't do anything.
>
> > To the best of my knowledge, I followed all the instructions for
> > preparing the .cdf file: close unwanted cells, hide brackets, enable
> > Deployed in Cell Options --> General Properties --> Deployed, making
> > sure that the file "rotate_demo.cdf" was selected in the menu of the
> > Options for Global Preferences dialog. I saved the file as .cdf using
> > the menu choice in the save dialog. I tried each of the following two
> > html tags in a web page.
>
> > <script src="http://www.wolfram.com/cdf-player/plugin/v1.0/
> > cdfplugin.js"
> > type="text/javascript"></script><script type="text/javascript">// <=
!
> > [CDATA[
> > var cdf = new cdf_plugin();
> > cdf.addCDFObject("rotate_demo_applet", "rotate_demo.cdf", 800, 800);
> > // ]]></script>
>
> > <embed src="rotate_demo.cdf" width="1000" height="1000">
>
> > Files downloaded from Wolfram's demonstration .cdf files and opened in
> > in either a browser or the CDF Player display and operate properly, so
> > it seems the error must occur when the files are created.  Any ideas?
>
> > Mathematica 8, iMac, OS X 10.6.8, Chrome, Firefox

[toc] | [prev] | [next] | [standalone]


#6540

FromGary <gpalmerlv@gmail.com>
Date2011-11-19 11:54 +0000
Message-ID<ja85eh$iks$1@smc.vnet.net>
In reply to#6492
I should add to the previous, that not only is the Open Option
Inspector button grayed out, but the entire Preferences dialog appears
to be frozen.

[toc] | [prev] | [next] | [standalone]


#6548

FromGary <gpalmerlv@gmail.com>
Date2011-11-20 10:36 +0000
Message-ID<jaal7a$14f$1@smc.vnet.net>
In reply to#6540
Progress
I previously reported that the slider controls in my Manipulate[]
graphic were gray and inactive. Setting "Format --> Option Inspector --
> Cell Options --> General Properties --> Deployed --> True" did not
help (yes, the file was selected). But next to Deployed, I noticed
Enabled, so I set Deployed --> False and set Enabled --> True. That
turned on the blue slider buttons again. I rechecked by setting
Enabled --> False and resetting Deployed --> True. That produced
inactive slider buttons. Furthermore, in the main Cell menu, the
Delete All Output choice was now grayed out. I again set Deployed -->
False and set Enabled --> True and got the active controls back as
well as an active Delete All Output. So I did the obvious, setting
both Deployed and Enabled to True. The controls are active and Delete
All Output is active. The instructions I have found all said to set
Deployed --> True, but I con't recall any mention of Enabled. It is
not clear to me what Deployed --> True does in this situation. Enabled
--> True seems to be both necessary and sufficient, at least within
the notebook. Does Deployed affect only the cdf files?

I am puzzled that my many searches for online documentation on this
point produced only snippets of information on Deployed (generally
with incomplete information on where to find it) and no information at
all on Cell Options --> General Properties --> Enabled (True/False).
For example, I don't find it here <http://reference.wolfram.com/
mathematica/ref/Manipulate.html>. I feel a need for a few collected
pages of expanded discussion of when and where the various options
available under the Options Inspector are or are not needed. There is
a great need for a document on trouble shooting. The technical
descriptions are not always obvious to a beginner. I am picking up a
few things, but at a cost which seems unnecessarily high. Some of the
needed discussion might be scattered among the many books on
Mathematica, or many of the answers might be concentrated in one or
two books, but which ones?

Mathematica Home Edition 8, iMac, OS X 10.6.8, Chrome, Firefox

[toc] | [prev] | [next] | [standalone]


#6567

FromGary <gpalmerlv@gmail.com>
Date2011-11-20 10:45 +0000
Message-ID<jaalnh$1a4$1@smc.vnet.net>
In reply to#6540
...and problem reinstalling plugin
I am adding one more message here because I wasn't sure whether to
create a new topic, but I think this problem may be related to the
previous. When I reinstalled Mathematica and then installed the
browser plugin from the disk, the installation succeeded, but the disk
began grinding. To shut it off, I had to force quit the kernel and
other processes in the Activity Monitor. I was able to reproduce the
problem, which did not occur when I first installed Mathematica and the
plugin.

Mathematica Home Edition 8, iMac, OS X 10.6.8, Chrome, Firefox

[toc] | [prev] | [next] | [standalone]


#6571

FromGary <gpalmerlv@gmail.com>
Date2011-11-20 10:47 +0000
Message-ID<jaalrc$1b0$1@smc.vnet.net>
In reply to#6540
OK, I discovered the Open Option feature also resides in the Format
menu, so I do have access to the options. But the drama continues. I
restored the visible brackets to the .nb file and I find that
evaluation now produces a fine looking but non-functioning Manipulate
plot. To the best of my knowledge, I changed nothing in the code
itself, which formerly produced a notebook plot with working sliders.
I wonder if there is an option that I have set to the wrong value.

(* Rotation on arbitrary axes *)

(* Note that in Mathematica 3D graphics, the standard viewpoint has \
the x axis nearly horizontal and the y axis nearly vertical. *)

Clear[xV, yV, zV, originC, vDiskAxis]

(* Cartesian frame and origin *)
xV = {1, 0, 0};
yV = {0, 1, 0};
zV = {0, 0, 1};
originC = {0, 0, 0};

(* Line, arrow, disk functions defined to use vector parameters. *)
(* \
o, origin; vAxis, axis; len, cylinder length; r, cylinder radius *)

vLine[o_, v_, len_] := Line[{o, o + len*Normalize[v]}];

vArrow[o_, v_, len_] := Arrow[{o, o + len*Normalize[v]}];

vCylinder[o_, vAxis_, len_, r_] :=

  Cylinder[{o, o + len*Normalize[vAxis]}, r];

(* len in vFrame3D is length from origin; total length = 2*len *)

vFrame3D[len_] := {
   Thick, Black,
   vLine[-len*Normalize[xV], xV, 2*len],
   vLine[-len*Normalize[yV], yV, 2*len],
   vLine[-len*Normalize[zV], zV, 2*len],

   Text[Style["X", 16, Bold], (11/10)*len*Normalize[xV ]],
   Text[Style["Y", 16, Bold], (11/10)*len*Normalize[yV ]],
   Text[Style["Z", 16, Bold], (11/10)*len*Normalize[zV ]]
   };


vDiskAxis = {1, 1, 1};

demoObjects = {

   Thick, Red,
   vArrow[originC, xV, 5],
   vArrow[originC, yV, 5],
   vArrow[originC, zV, 5],

   Thick, Orange, vArrow[originC, vDiskAxis, 5],
   Magenta, vCylinder[originC, vDiskAxis, .2, .5],
   Blue, Specularity[1], Sphere[{2, 3, 2}, .5]

   };

Manipulate[
 Graphics3D[
  {
   vFrame3D[5], (* frame does not rotate *)
   Rotate[
    Rotate[
     Rotate[
      Rotate[
       demoObjects,
       w, vDiskAxis, originC
       ],
      x, {1, 0, 0}, originC
      ],
     y, {0, 1, 0}, originC
     ],
    z, {0, 0, 1}, originC
    ]
   },

  (* Parameters and ranges for Graphics3D[] *)

  ViewPoint -> {2, 3/4, .2},
  Background -> LightYellow,
  Boxed -> False,
  ImageSize -> Full,
  PlotRange -> {{-5, 5}, {-5, 6}, {-5, 5}}
  (* Alert: To avoid box shifting,
  specify PlotRange for x,y,and z axis. *)

  ],

 (* Parameters and ranges for Manipulate[] *)

 Style["\n\n\nROTATIONS\n", 16, Bold],

 Style["on disk axis", 16, Bold], {{w, 0}, 0, 2*Pi, 2*Pi/90},
 Style["on x axis", 16, Bold], {{x, 0}, 0, 2*Pi, 2*Pi/90},
 Style["on y axis", 16, Bold], {{y, 0}, 0, 2*Pi, 2*Pi/90},
 Style["on z axis", 16, Bold], {{z, 0}, 0, 2*Pi, 2*Pi/90},

 ContentSize -> 425,
 ControlPlacement -> Right,
 SaveDefinitions -> True

 ]

On Nov 19, 3:54 am, Gary <gpalme...@gmail.com> wrote:
> I should add to the previous, that not only is the Open Option
> Inspector button grayed out, but the entire Preferences dialog appears
> to be frozen.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web