Mercurial > hg > svgui
comparison view/View.cpp @ 1605:ae2d5f8ff005
When asked to render the whole view width, we need to wait for the layers to be ready before we can determine what the width is
author | Chris Cannam |
---|---|
date | Thu, 30 Apr 2020 14:47:13 +0100 |
parents | f12c25651f96 |
children | 52d4bfba5b3d |
comparison
equal
deleted
inserted
replaced
1604:5feb1a8318df | 1605:ae2d5f8ff005 |
---|---|
2990 | 2990 |
2991 paint.restore(); | 2991 paint.restore(); |
2992 } | 2992 } |
2993 | 2993 |
2994 bool | 2994 bool |
2995 View::render(QPainter &paint, int xorigin, sv_frame_t f0, sv_frame_t f1) | 2995 View::waitForLayersToBeReady() |
2996 { | 2996 { |
2997 int x0 = int(round(m_zoomLevel.framesToPixels(double(f0)))); | |
2998 int x1 = int(round(m_zoomLevel.framesToPixels(double(f1)))); | |
2999 | |
3000 int w = x1 - x0; | |
3001 | |
3002 sv_frame_t origCentreFrame = m_centreFrame; | |
3003 | |
3004 bool someLayersIncomplete = false; | 2997 bool someLayersIncomplete = false; |
3005 | 2998 |
3006 #ifdef DEBUG_VIEW | 2999 #ifdef DEBUG_VIEW |
3007 SVDEBUG << "View::render: checking completion" << endl; | 3000 SVDEBUG << "View::waitForLayersToBeReady: checking completion" << endl; |
3008 #endif | 3001 #endif |
3009 | 3002 |
3010 for (LayerList::iterator i = m_layerStack.begin(); | 3003 for (LayerList::iterator i = m_layerStack.begin(); |
3011 i != m_layerStack.end(); ++i) { | 3004 i != m_layerStack.end(); ++i) { |
3012 | 3005 |
3062 usleep(50000); | 3055 usleep(50000); |
3063 } | 3056 } |
3064 } | 3057 } |
3065 | 3058 |
3066 #ifdef DEBUG_VIEW | 3059 #ifdef DEBUG_VIEW |
3067 SVDEBUG << "View::render: ok, we're ready" << endl; | 3060 SVDEBUG << "View::waitForLayersToBeReady: ok, we're ready" << endl; |
3068 #endif | 3061 #endif |
3062 | |
3063 return true; | |
3064 } | |
3065 | |
3066 bool | |
3067 View::render(QPainter &paint, int xorigin, sv_frame_t f0, sv_frame_t f1) | |
3068 { | |
3069 int x0 = int(round(m_zoomLevel.framesToPixels(double(f0)))); | |
3070 int x1 = int(round(m_zoomLevel.framesToPixels(double(f1)))); | |
3071 | |
3072 int w = x1 - x0; | |
3073 | |
3074 #ifdef DEBUG_VIEW | |
3075 SVDEBUG << "View::render: Render request is for frames " << f0 | |
3076 << " to " << f1 << " (pixels " << x0 << " to " << x1 | |
3077 << ", width " << w << ")" << endl; | |
3078 #endif | |
3079 | |
3080 if (!waitForLayersToBeReady()) { | |
3081 return false; | |
3082 } | |
3083 | |
3084 sv_frame_t origCentreFrame = m_centreFrame; | |
3069 | 3085 |
3070 QProgressDialog progress(tr("Rendering image..."), | 3086 QProgressDialog progress(tr("Rendering image..."), |
3071 tr("Cancel"), 0, w / width(), this); | 3087 tr("Cancel"), 0, w / width(), this); |
3072 | 3088 |
3073 for (int x = 0; x < w; x += width()) { | 3089 for (int x = 0; x < w; x += width()) { |
3121 } | 3137 } |
3122 | 3138 |
3123 QImage * | 3139 QImage * |
3124 View::renderToNewImage() | 3140 View::renderToNewImage() |
3125 { | 3141 { |
3142 if (!waitForLayersToBeReady()) { | |
3143 return nullptr; | |
3144 } | |
3145 | |
3126 sv_frame_t f0 = getModelsStartFrame(); | 3146 sv_frame_t f0 = getModelsStartFrame(); |
3127 sv_frame_t f1 = getModelsEndFrame(); | 3147 sv_frame_t f1 = getModelsEndFrame(); |
3128 | 3148 |
3129 return renderPartToNewImage(f0, f1); | 3149 return renderPartToNewImage(f0, f1); |
3130 } | 3150 } |