Re: Generating previewed snippets yourselves...

2002-07-22 Thread Lars Gullik Bjønnes

John Levon [EMAIL PROTECTED] writes:

| On Mon, Jul 08, 2002 at 09:53:07AM +0100, Angus Leeming wrote:

 I really like Lars' idea of a separate thread, especially if we combine it 
 with an intelligent queue so we can send off 40 equations or so at a time.

| Do we really need a thread rather than a process ?

Inter thread communication is a bit easier than inter process
communication. (and you then do not need XTL to transfere entire
objects, but just use a queue (or similar) instead.)

-- 
Lgb



Re: Generating previewed snippets yourselves...

2002-07-22 Thread Lars Gullik Bjønnes

John Levon <[EMAIL PROTECTED]> writes:

| On Mon, Jul 08, 2002 at 09:53:07AM +0100, Angus Leeming wrote:
>
>> I really like Lars' idea of a separate thread, especially if we combine it 
>> with an intelligent queue so we can send off 40 equations or so at a time.
>
| Do we really need a thread rather than a process ?

Inter thread communication is a bit easier than inter process
communication. (and you then do not need XTL to transfere entire
objects, but just use a queue (or similar) instead.)

-- 
Lgb



Re: Generating previewed snippets yourselves...

2002-07-10 Thread Juergen Vigna

Angus Leeming wrote:
 
 Jürgen, I'm sinking fast in a pile of poo. However I think that this gives me 
 the paragraph that is currently visible at the top of the LyX screen.

#:O)

 BufferView * bv = ...; // I have a cached copy of this.

Where are you here. Where should the below piece of code pe placed.
(this is important to know!)

 LyXText * text - bv-getLyXText();

You only care for bv-text. For this stuff you have always start from
the topmost place IMO.

 int const top_y = text-first_y;

This cannot be const as it is set in the below call to the right y value!

 Row * row = text-getRowNearY(top_y);
 Paragraph * par = row-par();

Otherwise your pretty there ;)

 If that's right, then that's all I need. I'll just load all previews for 
 insets in the 5 pars on either side of this using Paragraph::next() and 
 Paragraph::previous().

No I think you always should load all of one paragraph and then check if
the first row of the following paragraph is still visible on screen if 
yes iterate above.

 Am I on the right track?

Yes more or less, but I will bring you there #:O)

Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Mitterstrich 151/A  Tel/Fax: +39-0471-450260 / +39-0471-450253
I-39050 SteineggWeb: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-10 Thread Juergen Vigna

Angus Leeming wrote:
 >
> Jürgen, I'm sinking fast in a pile of poo. However I think that this gives me 
> the paragraph that is currently visible at the top of the LyX screen.

#:O)

> BufferView * bv = ...; // I have a cached copy of this.

Where are you here. Where should the below piece of code pe placed.
(this is important to know!)

> LyXText * text - bv->getLyXText();

You only care for bv->text. For this stuff you have always start from
the topmost place IMO.

> int const top_y = text->first_y;

This cannot be const as it is set in the below call to the right y value!

> Row * row = text->getRowNearY(top_y);
> Paragraph * par = row->par();

Otherwise your pretty there ;)

> If that's right, then that's all I need. I'll just load all previews for 
> insets in the 5 pars on either side of this using Paragraph::next() and 
> Paragraph::previous().

No I think you always should load all of one paragraph and then check if
the first row of the following paragraph is still visible on screen if 
yes iterate above.

> Am I on the right track?

Yes more or less, but I will bring you there #:O)

Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Mitterstrich 151/A  Tel/Fax: +39-0471-450260 / +39-0471-450253
I-39050 SteineggWeb: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-09 Thread Juergen Vigna

Angus Leeming wrote:
 On Monday 08 July 2002 4:36 pm, Juergen Vigna wrote:
 
Ok. No we don't have a isVisible function right now and I don't think
this is easy to make as the visibility depends on the x,baseline
values passed as parameters to draw, which could change if I have to
rebreak the text after the loading. You could have a look at the
tabular.C or insettext.C draw functions. I just draw the visible
parts there, but for a graphics file with a fixed hight it could
be as easy as if baseline+graphics_height  0 then draw.

I forgot here obviously that it should be  screen height!

 Excuse me if I'm being dumn, but do you do have this info to hand because you 
 only call Inset::draw for a small set of Insets at a time. All you need to do 
 is cache this info. Something like:
 
 vectorInset * visible_insets;
 
 void Your_Main_Draw_Routine () {
   visible_insets.clear();
   for (some group of insets) {
   inset-draw(...);
   visible_insets.push_back(inset);
   }
 }
 
 bool isVisible(Inset * inset) {
   vectorInset *::const_iterator it = visible_insets.begin();
   vectorInset *::const_iterator end = visible_insets.end();
   it = std::find(it, end, inset);
   return it != end;
 }
 
 Am I wrong?

Yes we could do that, but what happens if we have a rebreaking
of the rows (and we most surely will have if sizes change). Then
the above information is not valid anymore and you have to ask
the single insets again. But on the other hand we don't care if we
load one or 2 insets too much the important part is that the
row rebreaking is good afterwards.

bool SomeInset::loadGraphics()
{
 if (graphicsAvailable())
 return loadGraphics_setDimensions();
 return false;
}

bool SomeInset::loadGraphics_setDimensions();
{
 if (!graphicsAvailable())
 return false;
 loadGraphics();
 setDimensions();
 if (dimesions_changed)
  return true;
 return false;
}

I guess somewhere in BufferView:

...
bool do_rebreak = false;
for in in all_visible_insets(); do
 do_rebreak = in-loadGraphics() || do_rebreak;
done
if (do_rebreak)
 rebreakLyXText(par_of_first_vis_inset, par_of_last_vis_inset);
redrawScreenIfNeeded(); (== update() call ;)
...

Do you think something like this would work?

  Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-09 Thread Angus Leeming

On Tuesday 09 July 2002 8:28 am, Juergen Vigna wrote:
 Angus Leeming wrote:
  On Monday 08 July 2002 4:36 pm, Juergen Vigna wrote:
 Ok. No we don't have a isVisible function right now and I don't think
 this is easy to make as the visibility depends on the x,baseline
 values passed as parameters to draw, which could change if I have to
 rebreak the text after the loading. You could have a look at the
 tabular.C or insettext.C draw functions. I just draw the visible
 parts there, but for a graphics file with a fixed hight it could
 be as easy as if baseline+graphics_height  0 then draw.

 I forgot here obviously that it should be  screen height!

Jürgen, I'm sinking fast in a pile of poo. However I think that this gives me 
the paragraph that is currently visible at the top of the LyX screen.

BufferView * bv = ...; // I have a cached copy of this.
LyXText * text - bv-getLyXText();
int const top_y = text-first_y;
Row * row = text-getRowNearY(top_y);
Paragraph * par = row-par();

If that's right, then that's all I need. I'll just load all previews for 
insets in the 5 pars on either side of this using Paragraph::next() and 
Paragraph::previous().

Am I on the right track?

Angus





Re: Generating previewed snippets yourselves...

2002-07-09 Thread Juergen Vigna

Angus Leeming wrote:
> On Monday 08 July 2002 4:36 pm, Juergen Vigna wrote:
> 
>>Ok. No we don't have a isVisible function right now and I don't think
>>this is easy to make as the "visibility" depends on the x,baseline
>>values passed as parameters to draw, which could change if I have to
>>rebreak the text after the loading. You could have a look at the
>>tabular.C or insettext.C draw functions. I just draw the visible
>>parts there, but for a graphics file with a fixed hight it could
>>be as easy as "if baseline+graphics_height > 0 then draw".

I forgot here obviously that it should be < screen height!

> Excuse me if I'm being dumn, but do you do have this info to hand because you 
> only call Inset::draw for a small set of Insets at a time. All you need to do 
> is cache this info. Something like:
> 
> vector visible_insets;
> 
> void Your_Main_Draw_Routine () {
>   visible_insets.clear();
>   for (some group of insets) {
>   inset->draw(...);
>   visible_insets.push_back(inset);
>   }
> }
> 
> bool isVisible(Inset * inset) {
>   vector::const_iterator it = visible_insets.begin();
>   vector::const_iterator end = visible_insets.end();
>   it = std::find(it, end, inset);
>   return it != end;
> }
> 
> Am I wrong?

Yes we could do that, but what happens if we have a rebreaking
of the rows (and we most surely will have if sizes change). Then
the above information is not valid anymore and you have to ask
the single insets again. But on the other hand we don't care if we
load one or 2 insets too much the important part is that the
row rebreaking is good afterwards.

bool SomeInset::loadGraphics()
{
 if (graphicsAvailable())
 return loadGraphics_setDimensions();
 return false;
}

bool SomeInset::loadGraphics_setDimensions();
{
 if (!graphicsAvailable())
 return false;
 loadGraphics();
 setDimensions();
 if (dimesions_changed)
  return true;
 return false;
}

I guess somewhere in BufferView:

...
bool do_rebreak = false;
for in in all_visible_insets(); do
 do_rebreak = in->loadGraphics() || do_rebreak;
done
if (do_rebreak)
 rebreakLyXText(par_of_first_vis_inset, par_of_last_vis_inset);
redrawScreenIfNeeded(); (== update() call ;)
...

Do you think something like this would work?

  Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-09 Thread Angus Leeming

On Tuesday 09 July 2002 8:28 am, Juergen Vigna wrote:
> Angus Leeming wrote:
> > On Monday 08 July 2002 4:36 pm, Juergen Vigna wrote:
> >>Ok. No we don't have a isVisible function right now and I don't think
> >>this is easy to make as the "visibility" depends on the x,baseline
> >>values passed as parameters to draw, which could change if I have to
> >>rebreak the text after the loading. You could have a look at the
> >>tabular.C or insettext.C draw functions. I just draw the visible
> >>parts there, but for a graphics file with a fixed hight it could
> >>be as easy as "if baseline+graphics_height > 0 then draw".
>
> I forgot here obviously that it should be < screen height!

Jürgen, I'm sinking fast in a pile of poo. However I think that this gives me 
the paragraph that is currently visible at the top of the LyX screen.

BufferView * bv = ...; // I have a cached copy of this.
LyXText * text - bv->getLyXText();
int const top_y = text->first_y;
Row * row = text->getRowNearY(top_y);
Paragraph * par = row->par();

If that's right, then that's all I need. I'll just load all previews for 
insets in the 5 pars on either side of this using Paragraph::next() and 
Paragraph::previous().

Am I on the right track?

Angus





Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Andre Poenitz wrote:
 On Sat, Jul 06, 2002 at 12:31:16PM +0100, Angus Leeming wrote:
 
I'm sure that the wizards will be able to help here. Wizards, are you reading 
this? I'd like to generate small batches of these previews, say for the first 
three or four screen heights. Thereafter, if I arrive at an inset for which a 
preview hasn't been generated, I'd like to generate previews for three or 
four screen heights around it. Any thoughts on an interface?
 
 
 Remember that currently we have problem with the on demand loading as
 done by the graphics insets. We'll certainly run into the same problem when
 we do that with the previews. So I'd still try to load everything ASAP, at
 least we might consider doing that size caching in the .lyx thingy.

What problem do you see here? I cannot look at the code right now but
IMO that when terminating to convert the images a signal is called which
then enters all insets and loads the requested file is this true? Well
IMO it's really easy to decide inside the inset that it is actually
not in a position where it is displayed so loading of the image would
not be needed and we just return from there without doing anything.

We only redraw the inset where we need to and that would be really
fews. I don't think that iterating over all insets in the buffer
takes that long actaully I think it should be quite fast, what takes
up the time is loading of the images into the buffer and then redrawing
in when it is not needed.

So I think that David is right and that this is easily doable, but
maybe I just didn't understand exactly what you really do and so my
above proposal is not really doable.

 Jug

P.S.: I sent a few replies to the mailing list this morning but
   I only now see that I always replied to the sender only could
   the people please forward the messages to the list. Thanks!

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Andre Poenitz wrote:
 On Mon, Jul 08, 2002 at 09:17:28AM +0200, Juergen Vigna wrote:
 
What problem do you see here?
 
 
 The cursor jumps wildly when scrolling down the documents. To a degree that
 LyX is unusable if you have lots of images. I believe storing the image
 size in the .lyx file might improve the situation a lot.

Well normal graphics should do that anyway! I don't know if that
would help for stuff like preview, but it wouldn't be worse too,
would it?

IMO that when terminating to convert the images a signal is called which
then enters all insets and loads the requested file is this true? Well
IMO it's really easy to decide inside the inset that it is actually
not in a position where it is displayed so loading of the image would
not be needed and we just return from there without doing anything.
 
 
 But when we need it there is a delay of up to several(!) seconds. Not nice
 when 'jsut scrolling down'.

Are you sure? The image is already converted you just have to load it
and display it I don't think that should take so much time for a screen
full of images and if you want you always could preload a screenfull
of images before and behind the actuall displayed size, just not all
of them.

P.S.: I sent a few replies to the mailing list this morning but
  I only now see that I always replied to the sender only could
  the people please forward the messages to the list. Thanks!
 
 
 Some to me? I'll have a look what's left. I usually delete read mail...

I already sent the replies to the list so they will actually only loose
the original post ;)

  Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 09:42:34AM +0200, Juergen Vigna wrote:
 Well normal graphics should do that anyway! I don't know if that
 would help for stuff like preview, but it wouldn't be worse too,
 would it?

Certainly not.

 But when we need it there is a delay of up to several(!) seconds. Not nice
 when 'jsut scrolling down'.
 
 Are you sure?


Yes. I am still unable to read some documentation containing lots of
screenshots created with 1.1.6fix4 with neither 1.2.0 nor 1.3.0cvs.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Andre Poenitz wrote:

 Yes. I am still unable to read some documentation containing lots of
 screenshots created with 1.1.6fix4 with neither 1.2.0 nor 1.3.0cvs.

IMO you're mixing stuff here. InsetGraphics right now still starts
to convert the image when it should be displayed and that is what
you see as delay. What we were talking about is if you already _have_
the converted image and only have to load and display it!

   Jug


-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Sunday 07 July 2002 9:23 pm, David Kastrup wrote:
 Herbert Voss [EMAIL PROTECTED] writes:
  Angus Leeming wrote:
 
  whith the geometry-package loaded I got something like the attached
  gif. The equationnumber is outside of the
  workarea - the (for the preview wrong) textwidth
  from geometry was taken for the image width.
 
  \usepackage{geometry}
  \geometry{blah ... blah}
 
  should be ignored in the preamble.

 The dvips option of preview.sty tries to override any ugly
 PostScript.  Either try loading the preview style last, or load it
 with the delayed option set.

Hmmm. I do load the preview style last. I'll try and set the delayed option 
also.

 \PassOptionsToPackage{showlabels}{preview}

David, this is how I invoke preview.sty now:

// Use the preview style file to ensure that each snippet appears on a
// fresh page.
os  \n
\\usepackage[active,delayed,dvips,tightpage,showlabels]{preview}\n
   \n;

I'm unable to get the equation labels, presumably because I run latex only 
once. Is that right? Will I need multiple passes.

Does the showlabels option give me eq: some eq label or does it give just a 
number, eg (1)?

Angus





Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 10:05 am, Juergen Vigna wrote:
 Andre Poenitz wrote:
  Yes. I am still unable to read some documentation containing lots of
  screenshots created with 1.1.6fix4 with neither 1.2.0 nor 1.3.0cvs.

 IMO you're mixing stuff here. InsetGraphics right now still starts
 to convert the image when it should be displayed and that is what
 you see as delay. What we were talking about is if you already _have_
 the converted image and only have to load and display it!

Yes. Unfortunately if I have 1000 equations in a thesis then loading them all 
takes a significant chunk of time. Minutes.

I really like Lars' idea of a separate thread, especially if we combine it 
with an intelligent queue so we can send off 40 equations or so at a time.

Angus



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Herbert Voss

Angus Leeming wrote:

 Yes. Unfortunately if I have 1000 equations in a thesis then loading them all 
 takes a significant chunk of time. Minutes.


I have sometimes formulas over nearly one page. This takes also
some time to build the preview.

Herbert



-- 
http://www.lyx.org/help/




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Angus Leeming wrote:
  On Monday 08 July 2002 10:05 am, Juergen Vigna wrote:
 
 Andre Poenitz wrote:
 
 Yes. I am still unable to read some documentation containing lots of
 screenshots created with 1.1.6fix4 with neither 1.2.0 nor 1.3.0cvs.
 
 IMO you're mixing stuff here. InsetGraphics right now still starts
 to convert the image when it should be displayed and that is what
 you see as delay. What we were talking about is if you already _have_
 the converted image and only have to load and display it!
 
 
  Yes. Unfortunately if I have 1000 equations in a thesis then loading 
them all
  takes a significant chunk of time. Minutes.
 
  I really like Lars' idea of a separate thread, especially if we 
combine it
  with an intelligent queue so we can send off 40 equations or so at a 
time.

_PLEASE_ enlighten me here. Are you talking about _loading_ or about
_converting_ or maybe about both? I think we should make a distinction
about _convert_ an image and _load/draw_ and image.

 Jug


-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._





Re: Generating previewed snippets yourselves...

2002-07-08 Thread John Levon

On Mon, Jul 08, 2002 at 09:53:07AM +0100, Angus Leeming wrote:

 I really like Lars' idea of a separate thread, especially if we combine it 
 with an intelligent queue so we can send off 40 equations or so at a time.

Do we really need a thread rather than a process ?

john

-- 
If a thing is not diminished by being shared, it is not rightly owned if
 it is only owned  not shared.
- St. Augustine



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Herbert Voss

Angus Leeming wrote:

 \\usepackage[active,delayed,dvips,tightpage,showlabels]{preview}\n
\n;
 
 I'm unable to get the equation labels, presumably because I run latex only 
 once. Is that right? Will I need multiple passes.
 
 Does the showlabels option give me eq: some eq label or does it give just a 
 number, eg (1)?


I have no problems here with that code


Herbert



-- 
http://www.lyx.org/help/




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 10:26 am, Herbert Voss wrote:
 Angus Leeming wrote:
 
  \\usepackage[active,delayed,dvips,tightpage,showlabels]{preview}\n 
  \n;
 
  I'm unable to get the equation labels, presumably because I run latex
  only once. Is that right? Will I need multiple passes.
 
  Does the showlabels option give me eq: some eq label or does it give
  just a number, eg (1)?

 I have no problems here with that code

I see no equation label in your screenshot.
A



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 10:24 am, Juergen Vigna wrote:
 Angus Leeming wrote:
   On Monday 08 July 2002 10:05 am, Juergen Vigna wrote:
  Andre Poenitz wrote:
  Yes. I am still unable to read some documentation containing lots of
  screenshots created with 1.1.6fix4 with neither 1.2.0 nor 1.3.0cvs.
  
  IMO you're mixing stuff here. InsetGraphics right now still starts
  to convert the image when it should be displayed and that is what
  you see as delay. What we were talking about is if you already _have_
  the converted image and only have to load and display it!
  
   Yes. Unfortunately if I have 1000 equations in a thesis then loading

 them all

   takes a significant chunk of time. Minutes.
  
   I really like Lars' idea of a separate thread, especially if we

 combine it

   with an intelligent queue so we can send off 40 equations or so at a

 time.

 _PLEASE_ enlighten me here. Are you talking about _loading_ or about
 _converting_ or maybe about both? I think we should make a distinction
 about _convert_ an image and _load/draw_ and image.

Just loading.

The preview code will gather all the latex snippets together and send them 
off as a forked process to convert to X image files of PPM format. LyX 
(xforms) can load these natively. It is this loading process that takes time 
for 1000 equations. Hence Lars' idea of a thread.

Angus



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 10:24 am, John Levon wrote:
 On Mon, Jul 08, 2002 at 09:53:07AM +0100, Angus Leeming wrote:
  I really like Lars' idea of a separate thread, especially if we combine
  it with an intelligent queue so we can send off 40 equations or so at a
  time.

 Do we really need a thread rather than a process ?

I don't know. We want to load 1000 image files into LyX. We don't want the 
user to wait for 5 minutes for this to occur. Sounds like a thread to me. 
Tell me otherwise.

A



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Herbert Voss

Angus Leeming wrote:

 On Monday 08 July 2002 10:26 am, Herbert Voss wrote:
 
Angus Leeming wrote:

   
\\usepackage[active,delayed,dvips,tightpage,showlabels]{preview}\n 
\n;

I'm unable to get the equation labels, presumably because I run latex
only once. Is that right? Will I need multiple passes.

Does the showlabels option give me eq: some eq label or does it give
just a number, eg (1)?

I have no problems here with that code

 
 I see no equation label in your screenshot.


??? the eq:1, eq:2, ... are my labels

Herbert


-- 
http://www.lyx.org/help/




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Angus Leeming wrote:
_PLEASE_ enlighten me here. Are you talking about _loading_ or about
_converting_ or maybe about both? I think we should make a distinction
about _convert_ an image and _load/draw_ and image.
 
 
 Just loading.
 
 The preview code will gather all the latex snippets together and send them 
 off as a forked process to convert to X image files of PPM format. LyX 
 (xforms) can load these natively. It is this loading process that takes time 
 for 1000 equations. Hence Lars' idea of a thread.

Ok that specified how much time takes it to just load 1-3 screenfull
of images (obviously not only images but the screenfulls of your
document)? It is not necessary to load all images at starting of lyx
but only when they are needed.

  Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 10:43 am, Herbert Voss wrote:
 Angus Leeming wrote:
  On Monday 08 July 2002 10:26 am, Herbert Voss wrote:
 Angus Leeming wrote:

 \\usepackage[active,delayed,dvips,tightpage,showlabels]{preview}\n 
 \n;
 
 I'm unable to get the equation labels, presumably because I run latex
 only once. Is that right? Will I need multiple passes.
 
 Does the showlabels option give me eq: some eq label or does it give
 just a number, eg (1)?
 
 I have no problems here with that code
 
  I see no equation label in your screenshot.

 ??? the eq:1, eq:2, ... are my labels

Sorry. I looked only at the first image file, not the second. Now I see.
A



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 10:44 am, Juergen Vigna wrote:
 Angus Leeming wrote:
 _PLEASE_ enlighten me here. Are you talking about _loading_ or about
 _converting_ or maybe about both? I think we should make a distinction
 about _convert_ an image and _load/draw_ and image.
 
  Just loading.
 
  The preview code will gather all the latex snippets together and send
  them off as a forked process to convert to X image files of PPM format.
  LyX (xforms) can load these natively. It is this loading process that
  takes time for 1000 equations. Hence Lars' idea of a thread.

 Ok that specified how much time takes it to just load 1-3 screenfull
 of images (obviously not only images but the screenfulls of your
 document)? It is not necessary to load all images at starting of lyx
 but only when they are needed.

Yes. This it would make sense to do this too. That's the first thing on my 
list of improvements. We'll see if that provides acceptable performance.

Along these lines, I think if it's a good idea if we can prevent loading 
while we're scrolling. Ie, if I'm moving the view using the scrollbar or the 
arrow keys, loading should be disabled. Only when I've stopped this and the 
screen position hasn't changed for a second or so should loading be started.

What do you think. Is this possible?

Angus



Re: Generating previewed snippets yourselves...

2002-07-08 Thread David Kastrup

Angus Leeming [EMAIL PROTECTED] writes:

 On Monday 08 July 2002 10:24 am, John Levon wrote:
  On Mon, Jul 08, 2002 at 09:53:07AM +0100, Angus Leeming wrote:
   I really like Lars' idea of a separate thread, especially if we combine
   it with an intelligent queue so we can send off 40 equations or so at a
   time.
 
  Do we really need a thread rather than a process ?
 
 I don't know. We want to load 1000 image files into LyX. We don't want the 
 user to wait for 5 minutes for this to occur. Sounds like a thread to me. 
 Tell me otherwise.

My pleasure.  You don't want to load 1000 image files into LyX when a
majority of them will never be displayed on screen since it is highly
unlikely that a particular editing session will rediplay the entire
document.  Load them when you need them, not before.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: [EMAIL PROTECTED]





Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 10:36:03AM +0100, Angus Leeming wrote:
 Along these lines, I think if it's a good idea if we can prevent loading 
 while we're scrolling. Ie, if I'm moving the view using the scrollbar or the 
 arrow keys, loading should be disabled. Only when I've stopped this and the 
 screen position hasn't changed for a second or so should loading be started.
 
 What do you think. Is this possible?

I'd do that, but on the loader side:

If an item is added to the 'to-be-loaded list', start a time out of a
second or so, and only if there are no new items added to that list, start
the actual loading, otherwise restart the timer. The more advanced version
of that would then re-order requests such that needed things go first.
Well, maybe a simple stack is already sufficient for that...

So this would be completely transparent to client code (the buffer etc) and
everything is well encapsulated within the loader. 

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 11:54:29AM +0200, David Kastrup wrote:
 My pleasure.  You don't want to load 1000 image files into LyX when a
 majority of them will never be displayed on screen since it is highly
 unlikely that a particular editing session will rediplay the entire
 document.  Load them when you need them, not before.

I usually scroll to the bottom of the doc and continue working from there.
So usually I'll see most things jsut once, but I'll see them.

Andre'
 

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread David Kastrup

Andre Poenitz [EMAIL PROTECTED] writes:

 On Mon, Jul 08, 2002 at 11:54:29AM +0200, David Kastrup wrote:
  My pleasure.  You don't want to load 1000 image files into LyX when a
  majority of them will never be displayed on screen since it is highly
  unlikely that a particular editing session will rediplay the entire
  document.  Load them when you need them, not before.
 
 I usually scroll to the bottom of the doc and continue working from
 there.

Then you deserve the punishment you get.  People which instead jump
to the end of the document with a single cursor positioning command
(I presume somthing like this exists) don't need to be punished
likewise.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: [EMAIL PROTECTED]





Re: Generating previewed snippets yourselves...

2002-07-08 Thread Herbert Voss

Andre Poenitz wrote:

 On Mon, Jul 08, 2002 at 11:54:29AM +0200, David Kastrup wrote:
 
My pleasure.  You don't want to load 1000 image files into LyX when a
majority of them will never be displayed on screen since it is highly
unlikely that a particular editing session will rediplay the entire
document.  Load them when you need them, not before.

 
 I usually scroll to the bottom of the doc and continue working from there.
 So usually I'll see most things jsut once, but I'll see them.



and where is the sense to see all the tons of previews,
when your screen at the end shows only let's say up to 10?

Herbert



-- 
http://www.lyx.org/help/




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Angus Leeming wrote:
 
 Yes. This it would make sense to do this too. That's the first thing on my 
 list of improvements. We'll see if that provides acceptable performance.
 
 Along these lines, I think if it's a good idea if we can prevent loading 
 while we're scrolling. Ie, if I'm moving the view using the scrollbar or the 
 arrow keys, loading should be disabled. Only when I've stopped this and the 
 screen position hasn't changed for a second or so should loading be started.
 
 What do you think. Is this possible?

Not in the first go, but with a bit of work maybe yes. This implies
that not InsetGraphics::draw() does the loading if needed but most
probably the BufferView has to do this then explicitely.

   Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 12:17:08PM +0200, Herbert Voss wrote:
 I usually scroll to the bottom of the doc and continue working from there.
 So usually I'll see most things jsut once, but I'll see them.
 
 and where is the sense to see all the tons of previews,
 when your screen at the end shows only let's say up to 10?

Not really much sense, but do you see an easy way out? How would the loader
decide between users stops here and user will scroll further down?

Maybe we could later cancle things from the preview queue, but I'd not do
that before I see that this is necessary.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 12:17:23PM +0200, David Kastrup wrote:
 Then you deserve the punishment you get.  People which instead jump
 to the end of the document with a single cursor positioning command
 (I presume somthing like this exists) don't need to be punished
 likewise.

LyX is a lousy text editor... typing 'G' certainly does not move to the end
of the buffer.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 12:18:51PM +0200, Juergen Vigna wrote:
 What do you think. Is this possible?
 
 Not in the first go, but with a bit of work maybe yes. This implies
 that not InsetGraphics::draw() does the loading if needed but most
 probably the BufferView has to do this then explicitely.

I do not want any preview code in the BufferView (nor in the Buffer, nor in
LyXText etc for that matter) And if that's not reason enough I'll call my
big brothers...

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Andre Poenitz wrote:
 I'd do that, but on the loader side:
 
 If an item is added to the 'to-be-loaded list', start a time out of a
 second or so, and only if there are no new items added to that list, start
 the actual loading, otherwise restart the timer. The more advanced version
 of that would then re-order requests such that needed things go first.
 Well, maybe a simple stack is already sufficient for that...
 
 So this would be completely transparent to client code (the buffer etc) and
 everything is well encapsulated within the loader. 

IMO you're thinking too complicated ;)

I think that graphics I just scrolled up but are way away now don't
have to be loaded. BufferView knows what it displays and just has to
request loading/redrawing of the graphics insets it displays a certain
time after scrolling stopped. The insets then know if they already
loaded/displayed correctly or have to do it on the request!

  Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Andre Poenitz wrote:
 On Mon, Jul 08, 2002 at 11:54:29AM +0200, David Kastrup wrote:
 
My pleasure.  You don't want to load 1000 image files into LyX when a
majority of them will never be displayed on screen since it is highly
unlikely that a particular editing session will rediplay the entire
document.  Load them when you need them, not before.
 
 
 I usually scroll to the bottom of the doc and continue working from there.
 So usually I'll see most things jsut once, but I'll see them.

Well I use Ctrl-End for this and it brings me at the spot without
displaying the whole of the document. But I think this can be
handled with the delayed loading model Angus told us, can't it?

 Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Andre Poenitz wrote:
 On Mon, Jul 08, 2002 at 12:18:51PM +0200, Juergen Vigna wrote:
 
What do you think. Is this possible?

Not in the first go, but with a bit of work maybe yes. This implies
that not InsetGraphics::draw() does the loading if needed but most
probably the BufferView has to do this then explicitely.
 
 
 I do not want any preview code in the BufferView (nor in the Buffer, nor in
 LyXText etc for that matter) And if that's not reason enough I'll call my
 big brothers...

Start to call then :) This is not preview stuff it is just
loading graphics on demand stuff and I think this can be in
BufferView! Not all of lyx graphics is connected to preview,
is it?

   Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread David Kastrup

Andre Poenitz [EMAIL PROTECTED] writes:

 On Mon, Jul 08, 2002 at 12:17:23PM +0200, David Kastrup wrote:
  Then you deserve the punishment you get.  People which instead jump
  to the end of the document with a single cursor positioning command
  (I presume somthing like this exists) don't need to be punished
  likewise.
 
 LyX is a lousy text editor... typing 'G' certainly does not move to the end
 of the buffer.

If Ctrl-End would not do the trick, it would be much saner to
implement that rather than promote Page Down as a substitute.  It
appears, however, that LyX is not quite as bad as you would think.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: [EMAIL PROTECTED]





Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 12:29:46PM +0200, Juergen Vigna wrote:
 I do not want any preview code in the BufferView (nor in the Buffer, nor in
 LyXText etc for that matter) And if that's not reason enough I'll call my
 big brothers...
 
 Start to call then :)

Larss!

 This is not preview stuff it is just loading graphics on demand
 stuff and I think this can be in BufferView!

But if it can be done outside, why should BufferView know of its existence
at all?

 Not all of lyx graphics is connected to preview, is it?

[No. And it hopefully wont...]

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 12:31:46PM +0200, David Kastrup wrote:
  LyX is a lousy text editor... typing 'G' certainly does not move to the end
  of the buffer.
 
 If Ctrl-End would not do the trick, it would be much saner to
 implement that rather than promote Page Down as a substitute.  It
 appears, however, that LyX is not quite as bad as you would think.

Nah, I won't start learning how to break my fingers. Either 'G' does the
trick or I will scroll ;-}

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 11:34 am, Andre Poenitz wrote:
 On Mon, Jul 08, 2002 at 12:29:46PM +0200, Juergen Vigna wrote:
  I do not want any preview code in the BufferView (nor in the Buffer, nor
   in LyXText etc for that matter) And if that's not reason enough I'll
   call my big brothers...
 
  Start to call then :)

 Larss!

  This is not preview stuff it is just loading graphics on demand
  stuff and I think this can be in BufferView!

 But if it can be done outside, why should BufferView know of its existence
 at all?

  Not all of lyx graphics is connected to preview, is it?

 [No. And it hopefully wont...]

 Andre'

You two, stop squabbling NOW!

;-)

The preview code is entirely separate from the rest of LyX so we can do what 
we like. Attached are Previews.h and PreviewLoader.h, the interface as seen 
by the rest of LyX.

At the moment, BufferView::buffer calls 
Previews::generateBufferPreviews(buffer) to start the conversion of all 
snippets. I'm sure we can pass it a paragraph_iterator position as well so 
that we only generate previews for 20 equations on either side or something.

Similarly, an individual inset calls PreviewLoader::add(latex_snippet). 
Followed by PreviewLoader::startLoading(). It should be possible to make 
startLoading a little more intelligent, so that we load the 20 or so 
equations on either side of the snippets currently in the queue as well.

Ok, Ok. We don't have a paragraph_iterator.

Could you two great minds think of ways of improving the interface to do what 
we'd like to do. The rest should be hidden inside the implementation.

A


// -*- C++ -*-
/**
 *  \file Previews.h
 *  Copyright 2002 the LyX Team
 *  Read the file COPYING
 *
 * \author Angus Leeming [EMAIL PROTECTED]
 *
 *  grfx::Previews is a singleton class that stores the grfx::PreviewLoader
 *  for each buffer requiring one.
 */

#ifndef PREVIEWS_H
#define PREVIEWS_H

#ifdef __GNUG__
#pragma interface
#endif

#include LString.h
#include boost/utility.hpp
#include boost/scoped_ptr.hpp

class Buffer;

namespace grfx {

class PreviewLoader;

class Previews : boost::noncopyable {
public:
	/// a wrapper for lyxrc.preview
	static bool activated();

	/// This is a singleton class. Get the instance.
	static Previews  get();

	/** Returns the PreviewLoader for this buffer.
	 *  Used by individual insets to update their own preview.
	 *  We assert that (buffer != 0) but do not pass a Buffer 
	 *  so that insets do not need to #include buffer.h
	 */
	PreviewLoader  loader(Buffer * buffer);

	/** Called from the Buffer d-tor.
	 *  If (buffer == 0), does nothing.
	 */
	void removeLoader(Buffer * buffer);

	/** For a particular buffer, initiate the generation of previews
	 *  for each and every snippetof LaTeX that's of interest with
	 *  a single forked process.
	 *  If (buffer == 0), does nothing.
	 */
	void generateBufferPreviews(Buffer * buffer);

private:
	/** Make the c-tor, d-tor private so we can control how many objects
	 *  are instantiated.
	 */
	Previews();
	///
	~Previews();

	/// Use the Pimpl idiom to hide the internals.
	class Impl;
	/// The pointer never changes although *pimpl_'s contents may.
	boost::scoped_ptrImpl const pimpl_;
};

} // namespace grfx

#endif // PREVIEWS_H


// -*- C++ -*-
/**
 *  \file PreviewLoader.h
 *  Copyright 2002 the LyX Team
 *  Read the file COPYING
 *
 * \author Angus Leeming [EMAIL PROTECTED]
 *
 *  grfx::PreviewLoader collects latex snippets together. Then, on a
 *  startLoading() call, these are dumped to file and processed, converting
 *  each snippet to a separate bitmap image file. Once a bitmap file is ready
 *  to be loaded back into LyX, the PreviewLoader emits a readyToDisplay signal
 *  to inform the initiating process.
 */

#ifndef PREVIEWLOADER_H
#define PREVIEWLOADER_H

#ifdef __GNUG__
#pragma interface
#endif

#include LString.h
#include boost/utility.hpp
#include boost/scoped_ptr.hpp
#include boost/signals/signal1.hpp

class Buffer;

namespace grfx {

class PreviewImage;

class PreviewLoader : boost::noncopyable {
public:
	/** We need buffer because we require the preamble to the
	 *  LaTeX file.
	 */
	PreviewLoader(Buffer const  buffer);
	///
	~PreviewLoader();

	/** Is there an image already associated with this snippet of LaTeX?
	 *  If so, returns a pointer to it, else returns 0.
	 */
	PreviewImage const * preview(string const  latex_snippet) const;

	///
	enum Status {
		///
		NotFound,
		///
		InQueue,
		///
		Processing,
		///
		Ready
	};

	/// How far have we got in loading the image?
	Status status(string const  latex_snippet) const;
	
	/// Add a snippet of LaTeX to the queue for processing.
	void add(string const  latex_snippet);

	/// Remove this snippet of LaTeX from the PreviewLoader.
	void remove(string const  latex_snippet);
	
	/** We have accumulated several latex snippets with status InQueue.
	 *  Initiate their transformation into bitmap images.
	 */
	void startLoading();

	/// Emit this signal when an image is ready for 

Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Angus Leeming wrote:

 Could you two great minds think of ways of improving the interface to do what 
 we'd like to do. The rest should be hidden inside the implementation.

Well I cannot comment on your implementation (I don't have the time
to look over it in detail), but I will give you a realtime example
of what I think and why it should be in BufferView.

Think of being Andre opening your workfile and scrolling till the
end of the document. What should happens now:

1. All previews/graphics should be converted to a loadable format

2. I would like to display the part of the graphics I'm actually in
and am not interested to wait till all other graphics I passed
truth are displayed to.

3. Only the really needed graphics should be loaded and displayed

4. Who knows about where I am in the document? Yes ONLY LyXText
which is part of the BufferView and BufferView is generally
the passed pointer.

5. BufferView should now after I stopped scrolling for n bits
of defined time request the loading of the graphic segments
I'm displaying right now. For this it should advise the insets
actually displayed to load it's graphics and fix it's width
(if it differs from the saved one which could be).

6. We have to do a rebreak of the text starting at the first displayed
paragraph-row.

7. We have to redraw the screen.

That is how I see it. But please fill in the gaps how you would see
the whole process and where I'm wrong.

Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 1:17 pm, Juergen Vigna wrote:
 Angus Leeming wrote:
  Could you two great minds think of ways of improving the interface to do
  what we'd like to do. The rest should be hidden inside the
  implementation.

 Well I cannot comment on your implementation (I don't have the time
 to look over it in detail), but I will give you a realtime example
 of what I think and why it should be in BufferView.

 Think of being Andre opening your workfile and scrolling till the
 end of the document. What should happens now:

 1. All previews/graphics should be converted to a loadable format

 2. I would like to display the part of the graphics I'm actually in
 and am not interested to wait till all other graphics I passed
 truth are displayed to.

 3. Only the really needed graphics should be loaded and displayed

 4. Who knows about where I am in the document? Yes ONLY LyXText
 which is part of the BufferView and BufferView is generally
 the passed pointer.

 5. BufferView should now after I stopped scrolling for n bits
 of defined time request the loading of the graphic segments
 I'm displaying right now. For this it should advise the insets
 actually displayed to load it's graphics and fix it's width
 (if it differs from the saved one which could be).

 6. We have to do a rebreak of the text starting at the first displayed
 paragraph-row.

 7. We have to redraw the screen.

 That is how I see it. But please fill in the gaps how you would see
 the whole process and where I'm wrong.

 Jug

I don't think you're wrong. I'd just like to implement it so that the Inset 
does as little as possible. I think I see how we'd do this, but I need your 
help to turn it into working code.

The plan
===
1. Don't load all image files once they are converted. 
2. insets ascertain whether they should use the previewed image with

void InsetFormula::draw(BufferView * bv, LyXFont const  font,
int y, float  xx, bool) const
{
if (preview_-usePreview()) {
pi.pain.image(x + 1, y - a + 1, w - 2, h - 2, 
  *(preview_-pimage_-image()));
...
}


If we modify this usePreview call, we can use that to invode startLoading, 
albeit without the inset knowing anything about this.

Within, InsetFormula::usePreview is:
bool InsetFormula::PreviewImpl::usePreview() const
{
// If the cached grfx::PreviewImage is invalid, update it.
string const snippet = latexString();
if (!pimage_ || snippet != pimage_-snippet()) {
grfx::PreviewLoader  ploader =
grfx::Previews::get().loader(view-buffer());
pimage_ = ploader.preview(snippet);
}

if (!pimage_)
return false;

return pimage_-image();
}

So, we already have the mechanism to trigger the loading of the image. Just 
modify PreviewLoader::preview to something like:

PreviewImage const *
PreviewLoader::Impl::preview(string const  latex_snippet, Inset * inset) 
const
{
Cache::const_iterator it = cache_.find(latex_snippet);
PreviewImage const * pimage = 
(it == cache_.end()) ? 0 : it-second.get();

+   // psuedo code
+   if (pimage  pimage-status() == WaitingToLoad) {
+   // call checkVisibility(inset) in 2 secs time
+   startTimer(2, inset, pimage, PreviewImage::checkVisibility)
+   }
+
return pimage;
}


void PreviewImage::checkVisibility(Inset * inset)
{
if (!inset || iloader_-status() != WaitingToLoad)
return;

if (!inset-isVisible())
return;

image-startLoading();
}   


So,, Jürgen, what should I use for inset-isVisible(). I have a Buffer  at 
my disposal.

Angus





Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 03:18:26PM +0100, Angus Leeming wrote:
 I don't think you're wrong. I'd just like to implement it so that the Inset 
 does as little as possible. I think I see how we'd do this, but I need your 
 help to turn it into working code.
 
 The plan
 ===
 1. Don't load all image files once they are converted. 
 2. insets ascertain whether they should use the previewed image with
 
 void InsetFormula::draw(BufferView * bv, LyXFont const  font,
   int y, float  xx, bool) const
 {
   if (preview_-usePreview()) {
   pi.pain.image(x + 1, y - a + 1, w - 2, h - 2, 
 *(preview_-pimage_-image()));
   ...
 }

Fine.
 
 If we modify this usePreview call, we can use that to invode startLoading, 
 albeit without the inset knowing anything about this.

Ok.

 [...]
 So, we already have the mechanism to trigger the loading of the image. Just 
 modify PreviewLoader::preview to something like:

Fine.

 void PreviewImage::checkVisibility(Inset * inset)
 {
   if (!inset || iloader_-status() != WaitingToLoad)
   return;
 
   if (!inset-isVisible())
   return;
 
   image-startLoading();
 } 
 
 
 So,, Jürgen, what should I use for inset-isVisible(). I have a Buffer  at 
 my disposal.

Ah... good that you are not asking me.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 3:48 pm, Andre Poenitz wrote:
  So,, Jürgen, what should I use for inset-isVisible(). I have a Buffer
   at my disposal.

 Ah... good that you are not asking me.

 Andre'

what happens if I s/Jürgen/Andre'/ in the above?
Angus



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 03:34:51PM +0100, Angus Leeming wrote:
 On Monday 08 July 2002 3:48 pm, Andre Poenitz wrote:
   So,, Jürgen, what should I use for inset-isVisible(). I have a Buffer
at my disposal.
 
  Ah... good that you are not asking me.
 
  Andre'
 
 what happens if I s/Jürgen/Andre'/ in the above?

I would have a problem as I don't know it.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

 I don't think you're wrong. I'd just like to implement it so that the Inset 
 does as little as possible. I think I see how we'd do this, but I need your 
 help to turn it into working code.
 
 The plan
 ===
 1. Don't load all image files once they are converted. 
 2. insets ascertain whether they should use the previewed image with
[snip]

I have the impression that we talk of different things. While you're
fixed at the preview level I think at a more general graphics level.
I don't care about the implementation of preview I care if and when
a graphics file is loaded and/or displayed.

void SomeInset::draw(...)
{
  [am I in the range I need to be drawed?][no] return!

  [need to draw a graphics file]
  [is graphics already converted]?
 [no]  goto really_draw
 [yes] load graphics file; goto really_draw
really_draw:
  [am I visible]? [no] return!
  [draw myself]
}

This is more or less what I think the inset should do now. What
we can make better in the above design is the delaid loading
of graphics files. To do this IMO we would have to split the
loading from the drawing part. That means that loading the graphics
into memory has to be requested by someone. I see this something like:

[i am scrolling now]
[i stopped scrolling]
[call load graphics on all insets in 2 seconds]

after 2 seconds

[iterate over all insets and do]
[bool loaded = false;]
[loaded = loaded || inset-loadGraphicsIfAvailable()] for all insets
[if loaded rebreak_the_text() and redraw_the_screen()]

Am I clear what I think now?

   Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 4:02 pm, Juergen Vigna wrote:
  I don't think you're wrong. I'd just like to implement it so that the
  Inset does as little as possible. I think I see how we'd do this, but I
  need your help to turn it into working code.
 
  The plan
  ===
  1. Don't load all image files once they are converted.
  2. insets ascertain whether they should use the previewed image with

 [snip]

 I have the impression that we talk of different things. While you're
 fixed at the preview level I think at a more general graphics level.
 I don't care about the implementation of preview I care if and when
 a graphics file is loaded and/or displayed.

We're talking about /exactly/ the same thing.

I /want/ to invoke startLoading() from within Inset::draw.

I /do not want/ to do it without a little care. 

I envisage something like:

Image::startLoading(Inset * inset) {
// call REALLYstartLoading(inset) in 2 secs time
startTimer(2, inset REALLYstartLoading)
}

Image::REALLYstartLoading(Inset * inset) {
if (!inset-isVisible())
return;

// load it
..
}

Similarly in BufferView::updateInset(Inset * inset) {
if (!inset-isVisible())
return;

inset-draw();
}

So, my question again. What's the equivalent of Inset::isVisible(). I /do/ 
know the BufferView.

You know, /if/ there were such a method or way of ascertaining this 
information, then BufferView::updateInset() should also use it to not redraw 
things that aren't visible. That would stop all those the cursor jumps all 
over the place as the graphics insets are loaded problems that people moan 
about now.

void BufferView::updateInset(Inset * inset) {
if (!inset-isVisible())
return;

inset-draw();
}

Capito?
Angus



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Angus Leeming wrote:
 We're talking about /exactly/ the same thing.

Well I said I have the impression when I read your last post ;)

 I /want/ to invoke startLoading() from within Inset::draw.
 
 I /do not want/ to do it without a little care. 
 
 I envisage something like:
 
 Image::startLoading(Inset * inset) {
   // call REALLYstartLoading(inset) in 2 secs time
   startTimer(2, inset REALLYstartLoading)
 }
 
 Image::REALLYstartLoading(Inset * inset) {
   if (!inset-isVisible())
   return;
 
   // load it
   ..
 }
 
 Similarly in BufferView::updateInset(Inset * inset) {
   if (!inset-isVisible())
   return;
 
   inset-draw();
 }

What I miss in all this is the rebreaking where would you
put that here?


 So, my question again. What's the equivalent of Inset::isVisible(). I /do/ 
 know the BufferView.

Ok. No we don't have a isVisible function right now and I don't think
this is easy to make as the visibility depends on the x,baseline
values passed as parameters to draw, which could change if I have to
rebreak the text after the loading. You could have a look at the
tabular.C or insettext.C draw functions. I just draw the visible
parts there, but for a graphics file with a fixed hight it could
be as easy as if baseline+graphics_height  0 then draw.

 You know, /if/ there were such a method or way of ascertaining this 
 information, then BufferView::updateInset() should also use it to not redraw 
 things that aren't visible. That would stop all those the cursor jumps all 
 over the place as the graphics insets are loaded problems that people moan 
 about now.
 
 void BufferView::updateInset(Inset * inset) {
   if (!inset-isVisible())
   return;
 
   inset-draw();
 }

I don't think we can do this.

 Capito?

Sure I hope you too.

  Jug

P.S.: Is it only an impression or do I get mail doubled again :)

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 12:50:57PM -0300, Garst R. Reese wrote:
 Why not have a preview toggle.

The 'use preview option' could serve as such. The only missing thing would
be a LFUN to allow key bindings...

Andre' 

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 4:50 pm, Garst R. Reese wrote:
 Why not have a preview toggle. There might even be events that
 automagically toggle it, but there are times when I do a lot of
 scrolling around looking for stuff that I forgot if I even wrote. A
 simple way to toggle graphics and preview on and off (same toggle) would
 be nice (for me).
 Garst

It's in the Preferences dialog already I believe.
Angus





Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 4:36 pm, Juergen Vigna wrote:
 Ok. No we don't have a isVisible function right now and I don't think
 this is easy to make as the visibility depends on the x,baseline
 values passed as parameters to draw, which could change if I have to
 rebreak the text after the loading. You could have a look at the
 tabular.C or insettext.C draw functions. I just draw the visible
 parts there, but for a graphics file with a fixed hight it could
 be as easy as if baseline+graphics_height  0 then draw.

Excuse me if I'm being dumn, but do you do have this info to hand because you 
only call Inset::draw for a small set of Insets at a time. All you need to do 
is cache this info. Something like:

vectorInset * visible_insets;

void Your_Main_Draw_Routine () {
visible_insets.clear();
for (some group of insets) {
inset-draw(...);
visible_insets.push_back(inset);
}
}

bool isVisible(Inset * inset) {
vectorInset *::const_iterator it = visible_insets.begin();
vectorInset *::const_iterator end = visible_insets.end();
it = std::find(it, end, inset);
return it != end;
}

Am I wrong?
Angus



Re: Generating previewed snippets yourselves...

2002-07-08 Thread David Kastrup

Garst R. Reese [EMAIL PROTECTED] writes:

 Andre Poenitz wrote:
  
  On Mon, Jul 08, 2002 at 12:17:08PM +0200, Herbert Voss wrote:
   I usually scroll to the bottom of the doc and continue working from there.
   So usually I'll see most things jsut once, but I'll see them.
  
   and where is the sense to see all the tons of previews,
   when your screen at the end shows only let's say up to 10?
  
  Not really much sense, but do you see an easy way out? How would the loader
  decide between users stops here and user will scroll further down?
  
  Maybe we could later cancle things from the preview queue, but I'd not do
  that before I see that this is necessary.
  
 Why not have a preview toggle. There might even be events that
 automagically toggle it, but there are times when I do a lot of
 scrolling around looking for stuff that I forgot if I even wrote. A
 simple way to toggle graphics and preview on and off (same toggle) would
 be nice (for me). 

If you have a separate thread rendering previews, and this thread
will never render anything that is already off-screen again,
scrolling will not be braked by the image rendering process.  One
would have to think about a strategy where an image rendering is
taking quite long after the image location has already been scrolled
off screen, perhaps it would be worthwhile to abort in that case.

But apart from that, things should be workable rather asynchronously.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: [EMAIL PROTECTED]





Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Andre Poenitz wrote:
> On Sat, Jul 06, 2002 at 12:31:16PM +0100, Angus Leeming wrote:
> 
>>I'm sure that the wizards will be able to help here. Wizards, are you reading 
>>this? I'd like to generate small batches of these previews, say for the first 
>>three or four screen heights. Thereafter, if I arrive at an inset for which a 
>>preview hasn't been generated, I'd like to generate previews for three or 
>>four screen heights around it. Any thoughts on an interface?
> 
> 
> Remember that currently we have problem with the "on demand" loading as
> done by the graphics insets. We'll certainly run into the same problem when
> we do that with the previews. So I'd still try to load everything ASAP, at
> least we might consider doing that "size caching in the .lyx" thingy.

What problem do you see here? I cannot look at the code right now but
IMO that when terminating to convert the images a signal is called which
then enters all insets and loads the requested file is this true? Well
IMO it's really easy to decide inside the inset that it is actually
not in a position where it is displayed so loading of the image would
not be needed and we just return from there without doing anything.

We only redraw the inset where we need to and that would be really
fews. I don't think that iterating over all insets in the buffer
takes that long actaully I think it should be quite fast, what takes
up the time is loading of the images into the buffer and then redrawing
in when it is not needed.

So I think that David is right and that this is easily doable, but
maybe I just didn't understand exactly what you really do and so my
above proposal is not really doable.

 Jug

P.S.: I sent a few replies to the mailing list this morning but
   I only now see that I always replied to the sender only could
   the people please forward the messages to the list. Thanks!

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Andre Poenitz wrote:
> On Mon, Jul 08, 2002 at 09:17:28AM +0200, Juergen Vigna wrote:
> 
>>What problem do you see here?
> 
> 
> The cursor jumps wildly when scrolling down the documents. To a degree that
> LyX is unusable if you have lots of images. I believe storing the image
> size in the .lyx file might improve the situation a lot.

Well normal graphics should do that anyway! I don't know if that
would help for stuff like preview, but it wouldn't be worse too,
would it?

>>IMO that when terminating to convert the images a signal is called which
>>then enters all insets and loads the requested file is this true? Well
>>IMO it's really easy to decide inside the inset that it is actually
>>not in a position where it is displayed so loading of the image would
>>not be needed and we just return from there without doing anything.
> 
> 
> But when we need it there is a delay of up to several(!) seconds. Not nice
> when 'jsut scrolling down'.

Are you sure? The image is already converted you just have to load it
and display it I don't think that should take so much time for a screen
full of images and if you want you always could "preload" a screenfull
of images before and behind the actuall displayed size, just not all
of them.

>>P.S.: I sent a few replies to the mailing list this morning but
>>  I only now see that I always replied to the sender only could
>>  the people please forward the messages to the list. Thanks!
> 
> 
> Some to me? I'll have a look what's left. I usually delete read mail...

I already sent the replies to the list so they will actually only loose
the original post ;)

  Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 09:42:34AM +0200, Juergen Vigna wrote:
> Well normal graphics should do that anyway! I don't know if that
> would help for stuff like preview, but it wouldn't be worse too,
> would it?

Certainly not.

> >But when we need it there is a delay of up to several(!) seconds. Not nice
> >when 'jsut scrolling down'.
> 
> Are you sure?


Yes. I am still unable to read some documentation containing lots of
screenshots created with 1.1.6fix4 with neither 1.2.0 nor 1.3.0cvs.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Andre Poenitz wrote:

> Yes. I am still unable to read some documentation containing lots of
> screenshots created with 1.1.6fix4 with neither 1.2.0 nor 1.3.0cvs.

IMO you're mixing stuff here. InsetGraphics right now still starts
to convert the image when it should be displayed and that is what
you see as delay. What we were talking about is if you already _have_
the converted image and only have to load and display it!

   Jug


-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Sunday 07 July 2002 9:23 pm, David Kastrup wrote:
> Herbert Voss <[EMAIL PROTECTED]> writes:
> > Angus Leeming wrote:
> >
> > whith the geometry-package loaded I got something like the attached
> > gif. The equationnumber is outside of the
> > workarea -> the (for the preview wrong) textwidth
> > from geometry was taken for the image width.
> >
> > \usepackage{geometry}
> > \geometry{blah ... blah}
> >
> > should be ignored in the preamble.
>
> The dvips option of preview.sty tries to override any ugly
> PostScript.  Either try loading the preview style last, or load it
> with the "delayed" option set.

Hmmm. I do load the preview style last. I'll try and set the delayed option 
also.

> \PassOptionsToPackage{showlabels}{preview}

David, this is how I invoke preview.sty now:

// Use the preview style file to ensure that each snippet appears on a
// fresh page.
os << "\n"
   << "\\usepackage[active,delayed,dvips,tightpage,showlabels]{preview}\n"
  << "\n";

I'm unable to get the equation labels, presumably because I run latex only 
once. Is that right? Will I need multiple passes.

Does the showlabels option give me "eq: some eq label" or does it give just a 
number, eg (1)?

Angus





Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 10:05 am, Juergen Vigna wrote:
> Andre Poenitz wrote:
> > Yes. I am still unable to read some documentation containing lots of
> > screenshots created with 1.1.6fix4 with neither 1.2.0 nor 1.3.0cvs.
>
> IMO you're mixing stuff here. InsetGraphics right now still starts
> to convert the image when it should be displayed and that is what
> you see as delay. What we were talking about is if you already _have_
> the converted image and only have to load and display it!

Yes. Unfortunately if I have 1000 equations in a thesis then loading them all 
takes a significant chunk of time. Minutes.

I really like Lars' idea of a separate thread, especially if we combine it 
with an intelligent queue so we can send off 40 equations or so at a time.

Angus



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Herbert Voss

Angus Leeming wrote:

> Yes. Unfortunately if I have 1000 equations in a thesis then loading them all 
> takes a significant chunk of time. Minutes.


I have sometimes formulas over nearly one page. This takes also
some time to build the preview.

Herbert



-- 
http://www.lyx.org/help/




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Angus Leeming wrote:
 > On Monday 08 July 2002 10:05 am, Juergen Vigna wrote:
 >
 >>Andre Poenitz wrote:
 >>
 >>>Yes. I am still unable to read some documentation containing lots of
 >>>screenshots created with 1.1.6fix4 with neither 1.2.0 nor 1.3.0cvs.
 >>
 >>IMO you're mixing stuff here. InsetGraphics right now still starts
 >>to convert the image when it should be displayed and that is what
 >>you see as delay. What we were talking about is if you already _have_
 >>the converted image and only have to load and display it!
 >
 >
 > Yes. Unfortunately if I have 1000 equations in a thesis then loading 
them all
 > takes a significant chunk of time. Minutes.
 >
 > I really like Lars' idea of a separate thread, especially if we 
combine it
 > with an intelligent queue so we can send off 40 equations or so at a 
time.

_PLEASE_ enlighten me here. Are you talking about _loading_ or about
_converting_ or maybe about both? I think we should make a distinction
about _convert_ an image and _load/draw_ and image.

 Jug


-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._





Re: Generating previewed snippets yourselves...

2002-07-08 Thread John Levon

On Mon, Jul 08, 2002 at 09:53:07AM +0100, Angus Leeming wrote:

> I really like Lars' idea of a separate thread, especially if we combine it 
> with an intelligent queue so we can send off 40 equations or so at a time.

Do we really need a thread rather than a process ?

john

-- 
"If a thing is not diminished by being shared, it is not rightly owned if
 it is only owned & not shared."
- St. Augustine



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Herbert Voss

Angus Leeming wrote:

><< "\\usepackage[active,delayed,dvips,tightpage,showlabels]{preview}\n"
>   << "\n";
> 
> I'm unable to get the equation labels, presumably because I run latex only 
> once. Is that right? Will I need multiple passes.
> 
> Does the showlabels option give me "eq: some eq label" or does it give just a 
> number, eg (1)?


I have no problems here with that code


Herbert



-- 
http://www.lyx.org/help/




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 10:26 am, Herbert Voss wrote:
> Angus Leeming wrote:
> ><<
> > "\\usepackage[active,delayed,dvips,tightpage,showlabels]{preview}\n" <<
> > "\n";
> >
> > I'm unable to get the equation labels, presumably because I run latex
> > only once. Is that right? Will I need multiple passes.
> >
> > Does the showlabels option give me "eq: some eq label" or does it give
> > just a number, eg (1)?
>
> I have no problems here with that code

I see no equation label in your screenshot.
A



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 10:24 am, Juergen Vigna wrote:
> Angus Leeming wrote:
>  > On Monday 08 July 2002 10:05 am, Juergen Vigna wrote:
>  >>Andre Poenitz wrote:
>  >>>Yes. I am still unable to read some documentation containing lots of
>  >>>screenshots created with 1.1.6fix4 with neither 1.2.0 nor 1.3.0cvs.
>  >>
>  >>IMO you're mixing stuff here. InsetGraphics right now still starts
>  >>to convert the image when it should be displayed and that is what
>  >>you see as delay. What we were talking about is if you already _have_
>  >>the converted image and only have to load and display it!
>  >
>  > Yes. Unfortunately if I have 1000 equations in a thesis then loading
>
> them all
>
>  > takes a significant chunk of time. Minutes.
>  >
>  > I really like Lars' idea of a separate thread, especially if we
>
> combine it
>
>  > with an intelligent queue so we can send off 40 equations or so at a
>
> time.
>
> _PLEASE_ enlighten me here. Are you talking about _loading_ or about
> _converting_ or maybe about both? I think we should make a distinction
> about _convert_ an image and _load/draw_ and image.

Just loading.

The preview code will gather all the latex snippets together and send them 
off as a forked process to convert to X image files of PPM format. LyX 
(xforms) can load these natively. It is this loading process that takes time 
for 1000 equations. Hence Lars' idea of a thread.

Angus



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 10:24 am, John Levon wrote:
> On Mon, Jul 08, 2002 at 09:53:07AM +0100, Angus Leeming wrote:
> > I really like Lars' idea of a separate thread, especially if we combine
> > it with an intelligent queue so we can send off 40 equations or so at a
> > time.
>
> Do we really need a thread rather than a process ?

I don't know. We want to load 1000 image files into LyX. We don't want the 
user to wait for 5 minutes for this to occur. Sounds like a thread to me. 
Tell me otherwise.

A



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Herbert Voss

Angus Leeming wrote:

> On Monday 08 July 2002 10:26 am, Herbert Voss wrote:
> 
>>Angus Leeming wrote:
>>
>>>   <<
>>>"\\usepackage[active,delayed,dvips,tightpage,showlabels]{preview}\n" <<
>>>"\n";
>>>
>>>I'm unable to get the equation labels, presumably because I run latex
>>>only once. Is that right? Will I need multiple passes.
>>>
>>>Does the showlabels option give me "eq: some eq label" or does it give
>>>just a number, eg (1)?
>>>
>>I have no problems here with that code
>>
> 
> I see no equation label in your screenshot.


??? the eq:1, eq:2, ... are my labels

Herbert


-- 
http://www.lyx.org/help/




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Angus Leeming wrote:
>>_PLEASE_ enlighten me here. Are you talking about _loading_ or about
>>_converting_ or maybe about both? I think we should make a distinction
>>about _convert_ an image and _load/draw_ and image.
> 
> 
> Just loading.
> 
> The preview code will gather all the latex snippets together and send them 
> off as a forked process to convert to X image files of PPM format. LyX 
> (xforms) can load these natively. It is this loading process that takes time 
> for 1000 equations. Hence Lars' idea of a thread.

Ok that specified how much time takes it to just load 1-3 screenfull
of images (obviously not only images but the screenfulls of your
document)? It is not necessary to load all images at starting of lyx
but only when they are needed.

  Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 10:43 am, Herbert Voss wrote:
> Angus Leeming wrote:
> > On Monday 08 July 2002 10:26 am, Herbert Voss wrote:
> >>Angus Leeming wrote:
> >>>   <<
> >>>"\\usepackage[active,delayed,dvips,tightpage,showlabels]{preview}\n" <<
> >>>"\n";
> >>>
> >>>I'm unable to get the equation labels, presumably because I run latex
> >>>only once. Is that right? Will I need multiple passes.
> >>>
> >>>Does the showlabels option give me "eq: some eq label" or does it give
> >>>just a number, eg (1)?
> >>
> >>I have no problems here with that code
> >
> > I see no equation label in your screenshot.
>
> ??? the eq:1, eq:2, ... are my labels

Sorry. I looked only at the first image file, not the second. Now I see.
A



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 10:44 am, Juergen Vigna wrote:
> Angus Leeming wrote:
> >>_PLEASE_ enlighten me here. Are you talking about _loading_ or about
> >>_converting_ or maybe about both? I think we should make a distinction
> >>about _convert_ an image and _load/draw_ and image.
> >
> > Just loading.
> >
> > The preview code will gather all the latex snippets together and send
> > them off as a forked process to convert to X image files of PPM format.
> > LyX (xforms) can load these natively. It is this loading process that
> > takes time for 1000 equations. Hence Lars' idea of a thread.
>
> Ok that specified how much time takes it to just load 1-3 screenfull
> of images (obviously not only images but the screenfulls of your
> document)? It is not necessary to load all images at starting of lyx
> but only when they are needed.

Yes. This it would make sense to do this too. That's the first thing on my 
list of improvements. We'll see if that provides "acceptable" performance.

Along these lines, I think if it's a good idea if we can prevent loading 
while we're scrolling. Ie, if I'm moving the view using the scrollbar or the 
arrow keys, loading should be disabled. Only when I've stopped this and the 
screen position hasn't changed for a second or so should loading be started.

What do you think. Is this possible?

Angus



Re: Generating previewed snippets yourselves...

2002-07-08 Thread David Kastrup

Angus Leeming <[EMAIL PROTECTED]> writes:

> On Monday 08 July 2002 10:24 am, John Levon wrote:
> > On Mon, Jul 08, 2002 at 09:53:07AM +0100, Angus Leeming wrote:
> > > I really like Lars' idea of a separate thread, especially if we combine
> > > it with an intelligent queue so we can send off 40 equations or so at a
> > > time.
> >
> > Do we really need a thread rather than a process ?
> 
> I don't know. We want to load 1000 image files into LyX. We don't want the 
> user to wait for 5 minutes for this to occur. Sounds like a thread to me. 
> Tell me otherwise.

My pleasure.  You don't want to load 1000 image files into LyX when a
majority of them will never be displayed on screen since it is highly
unlikely that a particular editing session will rediplay the entire
document.  Load them when you need them, not before.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: [EMAIL PROTECTED]





Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 10:36:03AM +0100, Angus Leeming wrote:
> Along these lines, I think if it's a good idea if we can prevent loading 
> while we're scrolling. Ie, if I'm moving the view using the scrollbar or the 
> arrow keys, loading should be disabled. Only when I've stopped this and the 
> screen position hasn't changed for a second or so should loading be started.
> 
> What do you think. Is this possible?

I'd do that, but on the loader side:

If an item is added to the 'to-be-loaded list', start a time out of a
second or so, and only if there are no new items added to that list, start
the actual loading, otherwise restart the timer. The more advanced version
of that would then re-order requests such that "needed" things go first.
Well, maybe a simple stack is already sufficient for that...

So this would be completely transparent to client code (the buffer etc) and
everything is well encapsulated within the loader. 

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 11:54:29AM +0200, David Kastrup wrote:
> My pleasure.  You don't want to load 1000 image files into LyX when a
> majority of them will never be displayed on screen since it is highly
> unlikely that a particular editing session will rediplay the entire
> document.  Load them when you need them, not before.

I usually scroll to the bottom of the doc and continue working from there.
So "usually" I'll see most things jsut once, but I'll see them.

Andre'
> 

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread David Kastrup

Andre Poenitz <[EMAIL PROTECTED]> writes:

> On Mon, Jul 08, 2002 at 11:54:29AM +0200, David Kastrup wrote:
> > My pleasure.  You don't want to load 1000 image files into LyX when a
> > majority of them will never be displayed on screen since it is highly
> > unlikely that a particular editing session will rediplay the entire
> > document.  Load them when you need them, not before.
> 
> I usually scroll to the bottom of the doc and continue working from
> there.

Then you deserve the punishment you get.  People which instead jump
to the end of the document with a single cursor positioning command
(I presume somthing like this exists) don't need to be punished
likewise.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: [EMAIL PROTECTED]





Re: Generating previewed snippets yourselves...

2002-07-08 Thread Herbert Voss

Andre Poenitz wrote:

> On Mon, Jul 08, 2002 at 11:54:29AM +0200, David Kastrup wrote:
> 
>>My pleasure.  You don't want to load 1000 image files into LyX when a
>>majority of them will never be displayed on screen since it is highly
>>unlikely that a particular editing session will rediplay the entire
>>document.  Load them when you need them, not before.
>>
> 
> I usually scroll to the bottom of the doc and continue working from there.
> So "usually" I'll see most things jsut once, but I'll see them.



and where is the sense to see all the tons of previews,
when your screen at the end shows only let's say up to 10?

Herbert



-- 
http://www.lyx.org/help/




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Angus Leeming wrote:
> 
> Yes. This it would make sense to do this too. That's the first thing on my 
> list of improvements. We'll see if that provides "acceptable" performance.
> 
> Along these lines, I think if it's a good idea if we can prevent loading 
> while we're scrolling. Ie, if I'm moving the view using the scrollbar or the 
> arrow keys, loading should be disabled. Only when I've stopped this and the 
> screen position hasn't changed for a second or so should loading be started.
> 
> What do you think. Is this possible?

Not in the first go, but with a bit of work maybe yes. This implies
that not InsetGraphics::draw() does the loading if needed but most
probably the BufferView has to do this then explicitely.

   Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 12:17:08PM +0200, Herbert Voss wrote:
> >I usually scroll to the bottom of the doc and continue working from there.
> >So "usually" I'll see most things jsut once, but I'll see them.
> 
> and where is the sense to see all the tons of previews,
> when your screen at the end shows only let's say up to 10?

Not really much sense, but do you see an easy way out? How would the loader
decide between "users stops here" and "user will scroll further down"?

Maybe we could later cancle things from the preview queue, but I'd not do
that before I see that this is necessary.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 12:17:23PM +0200, David Kastrup wrote:
> Then you deserve the punishment you get.  People which instead jump
> to the end of the document with a single cursor positioning command
> (I presume somthing like this exists) don't need to be punished
> likewise.

LyX is a lousy text editor... typing 'G' certainly does not move to the end
of the buffer.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 12:18:51PM +0200, Juergen Vigna wrote:
> >What do you think. Is this possible?
> 
> Not in the first go, but with a bit of work maybe yes. This implies
> that not InsetGraphics::draw() does the loading if needed but most
> probably the BufferView has to do this then explicitely.

I do not want any preview code in the BufferView (nor in the Buffer, nor in
LyXText etc for that matter) And if that's not reason enough I'll call my
big brothers...

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Andre Poenitz wrote:
> I'd do that, but on the loader side:
> 
> If an item is added to the 'to-be-loaded list', start a time out of a
> second or so, and only if there are no new items added to that list, start
> the actual loading, otherwise restart the timer. The more advanced version
> of that would then re-order requests such that "needed" things go first.
> Well, maybe a simple stack is already sufficient for that...
> 
> So this would be completely transparent to client code (the buffer etc) and
> everything is well encapsulated within the loader. 

IMO you're thinking too complicated ;)

I think that graphics I just scrolled up but are way away now don't
have to be loaded. BufferView knows what it displays and just has to
request loading/redrawing of the graphics insets it displays a certain
time after scrolling stopped. The insets then know if they already
loaded/displayed correctly or have to do it on the request!

  Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Andre Poenitz wrote:
> On Mon, Jul 08, 2002 at 11:54:29AM +0200, David Kastrup wrote:
> 
>>My pleasure.  You don't want to load 1000 image files into LyX when a
>>majority of them will never be displayed on screen since it is highly
>>unlikely that a particular editing session will rediplay the entire
>>document.  Load them when you need them, not before.
> 
> 
> I usually scroll to the bottom of the doc and continue working from there.
> So "usually" I'll see most things jsut once, but I'll see them.

Well I use Ctrl-End for this and it brings me at the spot without
displaying the whole of the document. But I think this can be
handled with the delayed loading model Angus told us, can't it?

 Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Andre Poenitz wrote:
> On Mon, Jul 08, 2002 at 12:18:51PM +0200, Juergen Vigna wrote:
> 
>>>What do you think. Is this possible?
>>
>>Not in the first go, but with a bit of work maybe yes. This implies
>>that not InsetGraphics::draw() does the loading if needed but most
>>probably the BufferView has to do this then explicitely.
> 
> 
> I do not want any preview code in the BufferView (nor in the Buffer, nor in
> LyXText etc for that matter) And if that's not reason enough I'll call my
> big brothers...

Start to call then :) This is not "preview" stuff it is just
"loading graphics on demand" stuff and I think this can be in
BufferView! Not all of lyx graphics is connected to "preview",
is it?

   Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread David Kastrup

Andre Poenitz <[EMAIL PROTECTED]> writes:

> On Mon, Jul 08, 2002 at 12:17:23PM +0200, David Kastrup wrote:
> > Then you deserve the punishment you get.  People which instead jump
> > to the end of the document with a single cursor positioning command
> > (I presume somthing like this exists) don't need to be punished
> > likewise.
> 
> LyX is a lousy text editor... typing 'G' certainly does not move to the end
> of the buffer.

If Ctrl-End would not do the trick, it would be much saner to
implement that rather than promote Page Down as a substitute.  It
appears, however, that LyX is not quite as bad as you would think.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: [EMAIL PROTECTED]





Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 12:29:46PM +0200, Juergen Vigna wrote:
> >I do not want any preview code in the BufferView (nor in the Buffer, nor in
> >LyXText etc for that matter) And if that's not reason enough I'll call my
> >big brothers...
> 
> Start to call then :)

Larss!

> This is not "preview" stuff it is just "loading graphics on demand"
> stuff and I think this can be in BufferView!

But if it can be done outside, why should BufferView know of its existence
at all?

> Not all of lyx graphics is connected to "preview", is it?

[No. And it hopefully wont...]

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 12:31:46PM +0200, David Kastrup wrote:
> > LyX is a lousy text editor... typing 'G' certainly does not move to the end
> > of the buffer.
> 
> If Ctrl-End would not do the trick, it would be much saner to
> implement that rather than promote Page Down as a substitute.  It
> appears, however, that LyX is not quite as bad as you would think.

Nah, I won't start learning how to break my fingers. Either 'G' does the
trick or I will scroll ;-}

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 11:34 am, Andre Poenitz wrote:
> On Mon, Jul 08, 2002 at 12:29:46PM +0200, Juergen Vigna wrote:
> > >I do not want any preview code in the BufferView (nor in the Buffer, nor
> > > in LyXText etc for that matter) And if that's not reason enough I'll
> > > call my big brothers...
> >
> > Start to call then :)
>
> Larss!
>
> > This is not "preview" stuff it is just "loading graphics on demand"
> > stuff and I think this can be in BufferView!
>
> But if it can be done outside, why should BufferView know of its existence
> at all?
>
> > Not all of lyx graphics is connected to "preview", is it?
>
> [No. And it hopefully wont...]
>
> Andre'

You two, stop squabbling NOW!

;-)

The preview code is entirely separate from the rest of LyX so we can do what 
we like. Attached are Previews.h and PreviewLoader.h, the interface as seen 
by the rest of LyX.

At the moment, BufferView::buffer calls 
Previews::generateBufferPreviews(buffer) to start the conversion of all 
snippets. I'm sure we can pass it a paragraph_iterator position as well so 
that we only generate previews for 20 equations on either side or something.

Similarly, an individual inset calls PreviewLoader::add(latex_snippet). 
Followed by PreviewLoader::startLoading(). It should be possible to make 
startLoading a little more intelligent, so that we load the 20 or so 
equations on either side of the snippets currently in the queue as well.

Ok, Ok. We don't have a paragraph_iterator.

Could you two great minds think of ways of improving the interface to do what 
we'd like to do. The rest should be hidden inside the implementation.

A


// -*- C++ -*-
/**
 *  \file Previews.h
 *  Copyright 2002 the LyX Team
 *  Read the file COPYING
 *
 * \author Angus Leeming <[EMAIL PROTECTED]>
 *
 *  grfx::Previews is a singleton class that stores the grfx::PreviewLoader
 *  for each buffer requiring one.
 */

#ifndef PREVIEWS_H
#define PREVIEWS_H

#ifdef __GNUG__
#pragma interface
#endif

#include "LString.h"
#include 
#include 

class Buffer;

namespace grfx {

class PreviewLoader;

class Previews : boost::noncopyable {
public:
	/// a wrapper for lyxrc.preview
	static bool activated();

	/// This is a singleton class. Get the instance.
	static Previews & get();

	/** Returns the PreviewLoader for this buffer.
	 *  Used by individual insets to update their own preview.
	 *  We assert that (buffer != 0) but do not pass a Buffer &
	 *  so that insets do not need to #include buffer.h
	 */
	PreviewLoader & loader(Buffer * buffer);

	/** Called from the Buffer d-tor.
	 *  If (buffer == 0), does nothing.
	 */
	void removeLoader(Buffer * buffer);

	/** For a particular buffer, initiate the generation of previews
	 *  for each and every snippetof LaTeX that's of interest with
	 *  a single forked process.
	 *  If (buffer == 0), does nothing.
	 */
	void generateBufferPreviews(Buffer * buffer);

private:
	/** Make the c-tor, d-tor private so we can control how many objects
	 *  are instantiated.
	 */
	Previews();
	///
	~Previews();

	/// Use the Pimpl idiom to hide the internals.
	class Impl;
	/// The pointer never changes although *pimpl_'s contents may.
	boost::scoped_ptr const pimpl_;
};

} // namespace grfx

#endif // PREVIEWS_H


// -*- C++ -*-
/**
 *  \file PreviewLoader.h
 *  Copyright 2002 the LyX Team
 *  Read the file COPYING
 *
 * \author Angus Leeming <[EMAIL PROTECTED]>
 *
 *  grfx::PreviewLoader collects latex snippets together. Then, on a
 *  startLoading() call, these are dumped to file and processed, converting
 *  each snippet to a separate bitmap image file. Once a bitmap file is ready
 *  to be loaded back into LyX, the PreviewLoader emits a readyToDisplay signal
 *  to inform the initiating process.
 */

#ifndef PREVIEWLOADER_H
#define PREVIEWLOADER_H

#ifdef __GNUG__
#pragma interface
#endif

#include "LString.h"
#include 
#include 
#include 

class Buffer;

namespace grfx {

class PreviewImage;

class PreviewLoader : boost::noncopyable {
public:
	/** We need buffer because we require the preamble to the
	 *  LaTeX file.
	 */
	PreviewLoader(Buffer const & buffer);
	///
	~PreviewLoader();

	/** Is there an image already associated with this snippet of LaTeX?
	 *  If so, returns a pointer to it, else returns 0.
	 */
	PreviewImage const * preview(string const & latex_snippet) const;

	///
	enum Status {
		///
		NotFound,
		///
		InQueue,
		///
		Processing,
		///
		Ready
	};

	/// How far have we got in loading the image?
	Status status(string const & latex_snippet) const;
	
	/// Add a snippet of LaTeX to the queue for processing.
	void add(string const & latex_snippet);

	/// Remove this snippet of LaTeX from the PreviewLoader.
	void remove(string const & latex_snippet);
	
	/** We have accumulated several latex snippets with status "InQueue".
	 *  Initiate their transformation into bitmap images.
	 */
	void startLoading();

	/// Emit this signal when an image is ready for display.
	boost::signal1 

Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Angus Leeming wrote:

> Could you two great minds think of ways of improving the interface to do what 
> we'd like to do. The rest should be hidden inside the implementation.

Well I cannot comment on your implementation (I don't have the time
to look over it in detail), but I will give you a realtime example
of what I think and why it should be in BufferView.

Think of being Andre opening your workfile and scrolling till the
end of the document. What should happens now:

1. All previews/graphics should be converted to a loadable format

2. I would like to display the part of the graphics I'm actually in
and am not interested to wait till all other graphics I passed
truth are displayed to.

3. Only the really needed graphics should be loaded and displayed

4. Who knows about where I am in the document? Yes ONLY LyXText
which is part of the BufferView and BufferView is generally
the passed pointer.

5. BufferView should now after I stopped scrolling for "n" bits
of defined time request the loading of the graphic segments
I'm displaying right now. For this it should advise the insets
actually displayed to load it's graphics and fix it's width
(if it differs from the saved one which could be).

6. We have to do a rebreak of the text starting at the first displayed
paragraph-row.

7. We have to redraw the screen.

That is how I see it. But please fill in the gaps how you would see
the whole process and where I'm wrong.

Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 1:17 pm, Juergen Vigna wrote:
> Angus Leeming wrote:
> > Could you two great minds think of ways of improving the interface to do
> > what we'd like to do. The rest should be hidden inside the
> > implementation.
>
> Well I cannot comment on your implementation (I don't have the time
> to look over it in detail), but I will give you a realtime example
> of what I think and why it should be in BufferView.
>
> Think of being Andre opening your workfile and scrolling till the
> end of the document. What should happens now:
>
> 1. All previews/graphics should be converted to a loadable format
>
> 2. I would like to display the part of the graphics I'm actually in
> and am not interested to wait till all other graphics I passed
> truth are displayed to.
>
> 3. Only the really needed graphics should be loaded and displayed
>
> 4. Who knows about where I am in the document? Yes ONLY LyXText
> which is part of the BufferView and BufferView is generally
> the passed pointer.
>
> 5. BufferView should now after I stopped scrolling for "n" bits
> of defined time request the loading of the graphic segments
> I'm displaying right now. For this it should advise the insets
> actually displayed to load it's graphics and fix it's width
> (if it differs from the saved one which could be).
>
> 6. We have to do a rebreak of the text starting at the first displayed
> paragraph-row.
>
> 7. We have to redraw the screen.
>
> That is how I see it. But please fill in the gaps how you would see
> the whole process and where I'm wrong.
>
> Jug

I don't think you're wrong. I'd just like to implement it so that the Inset 
does as little as possible. I think I see how we'd do this, but I need your 
help to turn it into working code.

The plan
===
1. Don't load all image files once they are converted. 
2. insets ascertain whether they should use the previewed image with

void InsetFormula::draw(BufferView * bv, LyXFont const & font,
int y, float & xx, bool) const
{
if (preview_->usePreview()) {
pi.pain.image(x + 1, y - a + 1, w - 2, h - 2, 
  *(preview_->pimage_->image()));
...
}


If we modify this usePreview call, we can use that to invode startLoading, 
albeit without the inset knowing anything about this.

Within, InsetFormula::usePreview is:
bool InsetFormula::PreviewImpl::usePreview() const
{
// If the cached grfx::PreviewImage is invalid, update it.
string const snippet = latexString();
if (!pimage_ || snippet != pimage_->snippet()) {
grfx::PreviewLoader & ploader =
grfx::Previews::get().loader(view->buffer());
pimage_ = ploader.preview(snippet);
}

if (!pimage_)
return false;

return pimage_->image();
}

So, we already have the mechanism to trigger the loading of the image. Just 
modify PreviewLoader::preview to something like:

PreviewImage const *
PreviewLoader::Impl::preview(string const & latex_snippet, Inset * inset) 
const
{
Cache::const_iterator it = cache_.find(latex_snippet);
PreviewImage const * pimage = 
(it == cache_.end()) ? 0 : it->second.get();

+   // psuedo code
+   if (pimage && pimage->status() == WaitingToLoad) {
+   // call checkVisibility(inset) in 2 secs time
+   startTimer(2, inset, pimage, ::checkVisibility)
+   }
+
return pimage;
}


void PreviewImage::checkVisibility(Inset * inset)
{
if (!inset || iloader_->status() != WaitingToLoad)
return;

if (!inset->isVisible())
return;

image->startLoading();
}   


So,, Jürgen, what should I use for "inset->isVisible()". I have a Buffer & at 
my disposal.

Angus





Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 03:18:26PM +0100, Angus Leeming wrote:
> I don't think you're wrong. I'd just like to implement it so that the Inset 
> does as little as possible. I think I see how we'd do this, but I need your 
> help to turn it into working code.
> 
> The plan
> ===
> 1. Don't load all image files once they are converted. 
> 2. insets ascertain whether they should use the previewed image with
> 
> void InsetFormula::draw(BufferView * bv, LyXFont const & font,
>   int y, float & xx, bool) const
> {
>   if (preview_->usePreview()) {
>   pi.pain.image(x + 1, y - a + 1, w - 2, h - 2, 
> *(preview_->pimage_->image()));
>   ...
> }

Fine.
 
> If we modify this usePreview call, we can use that to invode startLoading, 
> albeit without the inset knowing anything about this.

Ok.

> [...]
> So, we already have the mechanism to trigger the loading of the image. Just 
> modify PreviewLoader::preview to something like:

Fine.

> void PreviewImage::checkVisibility(Inset * inset)
> {
>   if (!inset || iloader_->status() != WaitingToLoad)
>   return;
> 
>   if (!inset->isVisible())
>   return;
> 
>   image->startLoading();
> } 
> 
> 
> So,, Jürgen, what should I use for "inset->isVisible()". I have a Buffer & at 
> my disposal.

Ah... good that you are not asking me.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 3:48 pm, Andre Poenitz wrote:
> > So,, Jürgen, what should I use for "inset->isVisible()". I have a Buffer
> > & at my disposal.
>
> Ah... good that you are not asking me.
>
> Andre'

what happens if I s/Jürgen/Andre'/ in the above?
Angus



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 03:34:51PM +0100, Angus Leeming wrote:
> On Monday 08 July 2002 3:48 pm, Andre Poenitz wrote:
> > > So,, Jürgen, what should I use for "inset->isVisible()". I have a Buffer
> > > & at my disposal.
> >
> > Ah... good that you are not asking me.
> >
> > Andre'
> 
> what happens if I s/Jürgen/Andre'/ in the above?

I would have a problem as I don't know it.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

> I don't think you're wrong. I'd just like to implement it so that the Inset 
> does as little as possible. I think I see how we'd do this, but I need your 
> help to turn it into working code.
> 
> The plan
> ===
> 1. Don't load all image files once they are converted. 
> 2. insets ascertain whether they should use the previewed image with
[snip]

I have the impression that we talk of different things. While you're
fixed at the preview level I think at a more general "graphics" level.
I don't care about the implementation of "preview" I care if and when
a graphics file is loaded and/or displayed.

void SomeInset::draw(...)
{
  [am I in the range I need to be drawed?][no] return!

  [need to draw a graphics file]
  [is graphics already converted]?
 [no]  goto really_draw
 [yes] load graphics file; goto really_draw
really_draw:
  [am I visible]? [no] return!
  [draw myself]
}

This is more or less what I think the inset should do now. What
we can make better in the above design is the "delaid" loading
of graphics files. To do this IMO we would have to split the
loading from the drawing part. That means that loading the graphics
into memory has to be requested by someone. I see this something like:

[i am scrolling now]
[i stopped scrolling]
[call load graphics on all insets in 2 seconds]

after 2 seconds

[iterate over all insets and do]
[bool loaded = false;]
[loaded = loaded || inset->loadGraphicsIfAvailable()] for all insets
[if loaded rebreak_the_text() and redraw_the_screen()]

Am I clear what I think now?

   Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 4:02 pm, Juergen Vigna wrote:
> > I don't think you're wrong. I'd just like to implement it so that the
> > Inset does as little as possible. I think I see how we'd do this, but I
> > need your help to turn it into working code.
> >
> > The plan
> > ===
> > 1. Don't load all image files once they are converted.
> > 2. insets ascertain whether they should use the previewed image with
>
> [snip]
>
> I have the impression that we talk of different things. While you're
> fixed at the preview level I think at a more general "graphics" level.
> I don't care about the implementation of "preview" I care if and when
> a graphics file is loaded and/or displayed.

We're talking about /exactly/ the same thing.

I /want/ to invoke startLoading() from within Inset::draw.

I /do not want/ to do it without a little care. 

I envisage something like:

Image::startLoading(Inset * inset) {
// call REALLYstartLoading(inset) in 2 secs time
startTimer(2, inset REALLYstartLoading)
}

Image::REALLYstartLoading(Inset * inset) {
if (!inset->isVisible())
return;

// load it
..
}

Similarly in BufferView::updateInset(Inset * inset) {
if (!inset->isVisible())
return;

inset->draw();
}

So, my question again. What's the equivalent of "Inset::isVisible()". I /do/ 
know the BufferView.

You know, /if/ there were such a method or way of ascertaining this 
information, then BufferView::updateInset() should also use it to not redraw 
things that aren't visible. That would stop all those "the cursor jumps all 
over the place as the graphics insets are loaded" problems that people moan 
about now.

void BufferView::updateInset(Inset * inset) {
if (!inset->isVisible())
return;

inset->draw();
}

Capito?
Angus



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Juergen Vigna

Angus Leeming wrote:
> We're talking about /exactly/ the same thing.

Well I said I have the impression when I read your last post ;)

> I /want/ to invoke startLoading() from within Inset::draw.
> 
> I /do not want/ to do it without a little care. 
> 
> I envisage something like:
> 
> Image::startLoading(Inset * inset) {
>   // call REALLYstartLoading(inset) in 2 secs time
>   startTimer(2, inset REALLYstartLoading)
> }
> 
> Image::REALLYstartLoading(Inset * inset) {
>   if (!inset->isVisible())
>   return;
> 
>   // load it
>   ..
> }
> 
> Similarly in BufferView::updateInset(Inset * inset) {
>   if (!inset->isVisible())
>   return;
> 
>   inset->draw();
> }

What I miss in all this is the "rebreaking" where would you
put that here?


> So, my question again. What's the equivalent of "Inset::isVisible()". I /do/ 
> know the BufferView.

Ok. No we don't have a isVisible function right now and I don't think
this is easy to make as the "visibility" depends on the x,baseline
values passed as parameters to draw, which could change if I have to
rebreak the text after the loading. You could have a look at the
tabular.C or insettext.C draw functions. I just draw the visible
parts there, but for a graphics file with a fixed hight it could
be as easy as "if baseline+graphics_height > 0 then draw".

> You know, /if/ there were such a method or way of ascertaining this 
> information, then BufferView::updateInset() should also use it to not redraw 
> things that aren't visible. That would stop all those "the cursor jumps all 
> over the place as the graphics insets are loaded" problems that people moan 
> about now.
> 
> void BufferView::updateInset(Inset * inset) {
>   if (!inset->isVisible())
>   return;
> 
>   inset->draw();
> }

I don't think we can do this.

> Capito?

Sure I hope you too.

  Jug

P.S.: Is it only an impression or do I get mail doubled again :)

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen   Web: http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._




Re: Generating previewed snippets yourselves...

2002-07-08 Thread Andre Poenitz

On Mon, Jul 08, 2002 at 12:50:57PM -0300, Garst R. Reese wrote:
> Why not have a preview toggle.

The 'use preview option' could serve as such. The only missing thing would
be a LFUN to allow key bindings...

Andre' 

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 4:50 pm, Garst R. Reese wrote:
> Why not have a preview toggle. There might even be events that
> automagically toggle it, but there are times when I do a lot of
> scrolling around looking for stuff that I forgot if I even wrote. A
> simple way to toggle graphics and preview on and off (same toggle) would
> be nice (for me).
> Garst

It's in the Preferences dialog already I believe.
Angus





Re: Generating previewed snippets yourselves...

2002-07-08 Thread Angus Leeming

On Monday 08 July 2002 4:36 pm, Juergen Vigna wrote:
> Ok. No we don't have a isVisible function right now and I don't think
> this is easy to make as the "visibility" depends on the x,baseline
> values passed as parameters to draw, which could change if I have to
> rebreak the text after the loading. You could have a look at the
> tabular.C or insettext.C draw functions. I just draw the visible
> parts there, but for a graphics file with a fixed hight it could
> be as easy as "if baseline+graphics_height > 0 then draw".

Excuse me if I'm being dumn, but do you do have this info to hand because you 
only call Inset::draw for a small set of Insets at a time. All you need to do 
is cache this info. Something like:

vector visible_insets;

void Your_Main_Draw_Routine () {
visible_insets.clear();
for (some group of insets) {
inset->draw(...);
visible_insets.push_back(inset);
}
}

bool isVisible(Inset * inset) {
vector::const_iterator it = visible_insets.begin();
vector::const_iterator end = visible_insets.end();
it = std::find(it, end, inset);
return it != end;
}

Am I wrong?
Angus



Re: Generating previewed snippets yourselves...

2002-07-08 Thread David Kastrup

"Garst R. Reese" <[EMAIL PROTECTED]> writes:

> Andre Poenitz wrote:
> > 
> > On Mon, Jul 08, 2002 at 12:17:08PM +0200, Herbert Voss wrote:
> > > >I usually scroll to the bottom of the doc and continue working from there.
> > > >So "usually" I'll see most things jsut once, but I'll see them.
> > >
> > > and where is the sense to see all the tons of previews,
> > > when your screen at the end shows only let's say up to 10?
> > 
> > Not really much sense, but do you see an easy way out? How would the loader
> > decide between "users stops here" and "user will scroll further down"?
> > 
> > Maybe we could later cancle things from the preview queue, but I'd not do
> > that before I see that this is necessary.
> > 
> Why not have a preview toggle. There might even be events that
> automagically toggle it, but there are times when I do a lot of
> scrolling around looking for stuff that I forgot if I even wrote. A
> simple way to toggle graphics and preview on and off (same toggle) would
> be nice (for me). 

If you have a separate thread rendering previews, and this thread
will never render anything that is already off-screen again,
scrolling will not be braked by the image rendering process.  One
would have to think about a strategy where an image rendering is
taking quite long after the image location has already been scrolled
off screen, perhaps it would be worthwhile to abort in that case.

But apart from that, things should be workable rather asynchronously.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: [EMAIL PROTECTED]





Re: Generating previewed snippets yourselves...

2002-07-07 Thread David Kastrup

Kornel Benko [EMAIL PROTECTED] writes:

 On Friday 05 July 2002 23:08, Angus Leeming wrote:

  I've just submitted my workings on the preview code to
  CVS. Attached is a screen shot of what you can now expect. As you
  can see, I've just about resolved the positioning of the preview
  on the screen. There may be an off-by-one problem.
 
 WOW!!!
 
 [snip]
 
  follow the instructions in README-preview
 
 Opposed to the instruction in README-preview to reconstruct
 preview.ins, it was sufficient to
 
   tex bootstrap.ins
   tex preview-mk.ins
 
 to get the required files.


The instructions in README-preview are for the standalone distribution
of preview.dtx.  preview-mk.ins differs from preview.ins mentioned in
README-preview mainly in that the latter will install into
TDS-compliant directories when an appropriate docstrip configuration
exists, while preview-mk.ins will always unpack into the current
directory in order to facilitate the usual make all  make install
procedure.

The standalone distribution of preview.dtx does not even come with
bootstrap.ins; that is only present in the complete preview-latex
distribution (which at the current point of time is definite overkill
for use with LyX).

The standalone preview distribution is at
CTAN:macros/latex/contrib/supported/preview IIRC.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: [EMAIL PROTECTED]





Re: Generating previewed snippets yourselves...

2002-07-07 Thread David Kastrup

Herbert Voss [EMAIL PROTECTED] writes:

 Angus Leeming wrote:
 
 whith the geometry-package loaded I got something like the attached
 gif. The equationnumber is outside of the
 workarea - the (for the preview wrong) textwidth
 from geometry was taken for the image width.
 
 \usepackage{geometry}
 \geometry{blah ... blah}
 
 should be ignored in the preamble.

The dvips option of preview.sty tries to override any ugly
PostScript.  Either try loading the preview style last, or load it
with the delayed option set.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: [EMAIL PROTECTED]





  1   2   >