Re: Generating previewed snippets yourselves...
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...
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...
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...
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...
"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...
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...
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...
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...
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...
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...
> 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...
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...
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...
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...
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...
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...
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 imageReady; private: /// U
Re: Generating previewed snippets yourselves...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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. > 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'. > 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... 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...
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...
On Sat, Jul 06, 2002 at 09:08:09PM +0200, Lars Gullik Bjønnes wrote: > IMHO this is perfect for either a separate process or a thread..., We dont' have threads yet, do we? > we would then push conversion requests onto a queue, and the queue > would pop requests off this queue, handle it, and put the result back on a > "result queue", and notify the main event handler that something should be > done with it. > > If we could make it so that the thread do not actually use any of the lyx > data structures, then we would have no concurrency problems either. It does not need any additional lyx data. > Have a look at boost::thread, I already have code for thread queues etc. Ah... 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...
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. > Anyway, the current implementation is certainly Ok for 30 or 40 equations. Fine. 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...
Angus Leeming <[EMAIL PROTECTED]> writes: > 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? That's not what I meant. It is certainly quite a good choice to be generating all PNG files with a single LaTeX/DviPS/GhostScript run. It is not a good choice to be loading all those PNGs into memory when they are not needed. Let them sit on the disk until they are really displayed. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum Email: [EMAIL PROTECTED]
Re: Generating previewed snippets yourselves...
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]
Re: Generating previewed snippets yourselves...
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...
Herbert Voss wrote: > 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. and cropping the image on the left side gives a better result, too. I do not understand the sense of "%03d" in the lyxpreview2ppm.sh. the patch is only for demo Herbert -- http://www.lyx.org/help/ Index: lyxpreview2ppm.sh === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/scripts/lyxpreview2ppm.sh,v retrieving revision 1.1 diff -u -r1.1 lyxpreview2ppm.sh --- lyxpreview2ppm.sh 5 Jul 2002 21:24:11 - 1.1 +++ lyxpreview2ppm.sh 7 Jul 2002 05:46:13 - @@ -65,9 +65,11 @@ ALPHA=2 fi -gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pnm -sOutputFile=${BASE}%03d.ppm \ +gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pnm -sOutputFile=${BASE}001.pnm \ -dGraphicsAlphaBit=${ALPHA} -dTextAlphaBits=${ALPHA} -r${RESOLUTION} \ ${PSFILE} + +pnmcrop -left ${BASE}001.pnm > ${BASE}001.ppm STATUS=$? EXECUTABLE="gs ${PSFILE}"; CHECK_STATUS
Re: Generating previewed snippets yourselves...
Angus Leeming <[EMAIL PROTECTED]> writes: | 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? | | Anyway, the current implementation is certainly Ok for 30 or 40 equations. [Your lines are awfully long...] IMHO this is perfect for either a separate process or a thread..., we would then push conversion requests onto a queue, and the queue would pop requests off this queue, handle it, and put the result back on a "result queue", and notify the main event handler that something should be done with it. If we could make it so that the thread do not actually use any of the lyx data structures, then we would have no concurrency problems either. Have a look at boost::thread, I already have code for thread queues etc. -- Lgb
Re: Generating previewed snippets yourselves...
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. Herbert -- http://www.lyx.org/help/
Re: Generating previewed snippets yourselves...
On Saturday 06 July 2002 1:41 pm, Kornel Benko wrote: > On Saturday 06 July 2002 13:20, Angus Leeming wrote: > > I've just committed a fix; I was applying the right metrics info to the > > wrong image! > > I didn't notice it before ... > The background of the created previes is little different to the > screen-background. See attached. Odd indeed. > Besides this, very impressing. ;-)
Re: Generating previewed snippets yourselves...
-BEGIN PGP SIGNED MESSAGE- On Saturday 06 July 2002 13:20, Angus Leeming wrote: > I've just committed a fix; I was applying the right metrics info to the > wrong image! I didn't notice it before ... The background of the created previes is little different to the screen-background. See attached. Besides this, very impressing. Kornel - -- Kornel Benko [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: PGP 6.5.8 iQCVAwUBPSbliLewfbDGmeqhAQFLGQP7B2gsbG+pkWAWKBcvJQrSEreIvEdu0xkH w1DUovG3C5KmRPMlqvsJLXrtVuqGVwHzt/iu7iiW6urN/Wt5QkBTXBiWC5fFeWSf wGkQ3fMhEIKYnfiZgVHY/wv0Q/A60kwefuHTTDanX51SRs6GUaLeI5rVYW25iQQl wVjDWh3BW8o= =sORg -END PGP SIGNATURE- <>
Re: Generating previewed snippets yourselves...
On Friday 05 July 2002 10:47 pm, David Kastrup wrote: > > Incidentally, if you load a document with LOTS of equations, don't expect > > to see anything soon. We only load the images into LyX once gs has > > finished generating ALL the bitmap files. > > > > I've just tried with a Thesis containing 617 equations. It took gs > > about 5 mins to do the work. Thereafter LyX freezes until all these > > images are loaded up into memory. > > That's not good. > > > I think we'll have to do something about that. Presumably the > > elegant solution of loading an image file as it is created might > > aleviate this problem somewhat. > > That's not a good solution. The good solution would be to load only > those images that actually appear on-screen. Often in a single > editing session, you will not even be looking at most of the > document. No need to be loading the stuff into memory in the first > place, then. Agreed. Currently I just do: void Previews::generateBufferPreviews(Buffer * buffer) { if (!buffer || !lyxrc.preview) return; PreviewLoader & ploader = loader(buffer); Buffer::inset_iterator it = buffer->inset_const_iterator_begin(); Buffer::inset_iterator end = buffer->inset_const_iterator_end(); for (; it != end; ++it) { if ((*it)->lyxCode() == Inset::MATH_CODE) { (*it)->generatePreview(ploader); } } ploader.startLoading(); } 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? Anyway, the current implementation is certainly Ok for 30 or 40 equations. Angus
Re: Generating previewed snippets yourselves...
On Saturday 06 July 2002 11:52 am, Kornel Benko wrote: > 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!!! I've just committed a fix; I was applying the right metrics info to the wrong image! regards, Angus
Re: Generating previewed snippets yourselves...
-BEGIN PGP SIGNED MESSAGE- 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. Kornel - -- Kornel Benko [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: PGP 6.5.8 iQCVAwUBPSbMCbewfbDGmeqhAQGV/wP+KQ9r/RUsjMk8JnuWatfNXuZSGsGIbtha s1JEa3p+i95tPVosV+4hXZxjZgAkN4/hO0WQHVIeA2lBxOU6AHYD1hwtDKzRU6b4 rr0kFhwhYZygWUMj0Rd4Jz4jUyjFc9u+axTYi7a0PhHyydQmXkq5Nfe7IafyGR6S PVFHaiTb6qA= =ssrr -END PGP SIGNATURE-
Re: Generating previewed snippets yourselves...
Angus Leeming <[EMAIL PROTECTED]> writes: > You'll also need to grab a copy of preview-latex. I grabbed the most recent > stable version, preview-latex-0.7.2b.tar.gz from > http://prdownloads.sourceforge.net/preview-latex > > Actually, you'll need just the preview.sty .def and .cfg files that are > generated by > tar xvzf preview-latex-0.7.2b.tar.gz > cd preview-latex-0.7.2b/latex > follow the instructions in README-preview > Don't forget to install them someplace LaTeX can find them and remember to > run texhash or equivalent. Note that _this_ subset can be had from CTAN:macros/latex/contrib/supported/preview where CTAN is your favorite CTAN mirror (try finger [EMAIL PROTECTED] if you do not know about CTAN). No need to get the complete preview-latex stuff (unless you are curious). > Incidentally, if you load a document with LOTS of equations, don't expect to > see anything soon. We only load the images into LyX once gs has finished > generating ALL the bitmap files. > > I've just tried with a Thesis containing 617 equations. It took gs > about 5 mins to do the work. Thereafter LyX freezes until all these > images are loaded up into memory. That's not good. > I think we'll have to do something about that. Presumably the > elegant solution of loading an image file as it is created might > aleviate this problem somewhat. That's not a good solution. The good solution would be to load only those images that actually appear on-screen. Often in a single editing session, you will not even be looking at most of the document. No need to be loading the stuff into memory in the first place, then. And it sounds like thinking about some sort of persistency would be good. If you create a temporary directory with a name deriving from the main document, and you take some sort of basic timestamps from the document, it should be possible when restarting LyX to know whether one can keep the current previews or should regenerate. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum Email: [EMAIL PROTECTED]
Generating previewed snippets yourselves...
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. To get the equivalent of this image yourself, you should add the following to your preferences file. \preview true \set_color "preview" "#df" \format "lyxpreview" "lyxpreview" "LyX preview" "" \converter "lyxpreview" "ppm" "sh LYXSRC/lib/scripts/lyxpreview2ppm.sh" "" where LYXSRC is ... You'll also need to grab a copy of preview-latex. I grabbed the most recent stable version, preview-latex-0.7.2b.tar.gz from http://prdownloads.sourceforge.net/preview-latex Actually, you'll need just the preview.sty .def and .cfg files that are generated by tar xvzf preview-latex-0.7.2b.tar.gz cd preview-latex-0.7.2b/latex follow the instructions in README-preview Don't forget to install them someplace LaTeX can find them and remember to run texhash or equivalent. I have not yet addressed the fact that the size of the screenshot fonts is different to those used by LyX. If you really don't like this, you can always modify lyxpreview2ppm.sh, hard-coding the RESOLUTION parameter rather than letting lyX set it. - RESOLUTION=$2 + RESOLUTION=124 will give you similar-sized previews to those in the attached image. Incidentally, if you load a document with LOTS of equations, don't expect to see anything soon. We only load the images into LyX once gs has finished generating ALL the bitmap files. I've just tried with a Thesis containing 617 equations. It took gs about 5 mins to do the work. Thereafter LyX freezes until all these images are loaded up into memory. I think we'll have to do something about that. Presumably the elegant solution of loading an image file as it is created might aleviate this problem somewhat. Have fun and a good weekend, Angus preview.png Description: PNG image