ScreenImageMgr.cpp   ScreenImageMgr.cpp 
skipping to change at line 21 skipping to change at line 21
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "ScreenImageMgr.hpp" #include "ScreenImageMgr.hpp"
#include "StelMainGraphicsView.hpp" #include "StelMainView.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelModule.hpp" #include "StelModule.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "VecMath.hpp" #include "VecMath.hpp"
skipping to change at line 46 skipping to change at line 46
#include <QMap> #include <QMap>
#include <QTimeLine> #include <QTimeLine>
#include <QGraphicsItemAnimation> #include <QGraphicsItemAnimation>
/////////////////////// ///////////////////////
// ScreenImage class // // ScreenImage class //
/////////////////////// ///////////////////////
ScreenImage::ScreenImage(const QString& filename, float x, float y, bool sh ow, float scale, float alpha, float fadeDuration) ScreenImage::ScreenImage(const QString& filename, float x, float y, bool sh ow, float scale, float alpha, float fadeDuration)
: tex(NULL), maxAlpha(alpha) : tex(NULL), maxAlpha(alpha)
{ {
try QPixmap pm(filename);
{ tex = StelMainView::getInstance().scene()->addPixmap(pm.scaled(pm.si
QString path = StelFileMgr::findFile("scripts/" + filename); ze()*scale));
QPixmap pm(path); tex->setPos(x, y);
tex = StelMainGraphicsView::getInstance().scene()->addPixmap
(pm.scaled(pm.size()*scale)); anim = new QGraphicsItemAnimation();
tex->setPos(x, y); moveTimer = new QTimeLine();
moveTimer->setCurveShape(QTimeLine::LinearCurve);
anim = new QGraphicsItemAnimation(); anim->setTimeLine(moveTimer);
moveTimer = new QTimeLine(); anim->setItem(tex);
moveTimer->setCurveShape(QTimeLine::LinearCurve);
anim->setTimeLine(moveTimer); fadeTimer = new QTimeLine();
anim->setItem(tex); fadeTimer->setCurveShape(QTimeLine::LinearCurve);
setFadeDuration(fadeDuration);
fadeTimer = new QTimeLine(); connect(fadeTimer, SIGNAL(valueChanged(qreal)), this, SLOT(setOpacit
fadeTimer->setCurveShape(QTimeLine::LinearCurve); y(qreal)));
setFadeDuration(fadeDuration);
connect(fadeTimer, SIGNAL(valueChanged(qreal)), this, SLOT(s // set inital displayed state
etOpacity(qreal))); if (show)
tex->setOpacity(maxAlpha);
// set inital displayed state else
if (show) tex->setOpacity(0.);
tex->setOpacity(maxAlpha);
else
tex->setOpacity(0.);
}
catch (std::runtime_error& e)
{
qWarning() << "Failed to create ScreenImage: " << e.what();
}
} }
ScreenImage::~ScreenImage() ScreenImage::~ScreenImage()
{ {
if (tex!=NULL) if (tex!=NULL)
{ {
delete tex; delete tex;
tex = NULL; tex = NULL;
} }
moveTimer->stop(); moveTimer->stop();
skipping to change at line 196 skipping to change at line 188
} }
ScreenImageMgr::~ScreenImageMgr() ScreenImageMgr::~ScreenImageMgr()
{ {
} }
void ScreenImageMgr::init() void ScreenImageMgr::init()
{ {
} }
void ScreenImageMgr::draw(StelCore* core, class StelRenderer* renderer) void ScreenImageMgr::draw(StelCore* core)
{ {
Q_UNUSED(renderer);
foreach(ScreenImage* m, allScreenImages) foreach(ScreenImage* m, allScreenImages)
if (m!=NULL) if (m!=NULL)
m->draw(core); m->draw(core);
} }
void ScreenImageMgr::createScreenImage(const QString& id, const QString& fi lename, float x, float y, void ScreenImageMgr::createScreenImage(const QString& id, const QString& fi lename, float x, float y,
float scale, bool visible, float alpha, float fadeDuration) float scale, bool visible, float alpha, float fadeDuration)
{ {
// First check to see if there is already an image loaded with the // First check to see if there is already an image loaded with the
// specified ID, and drop it if necessary // specified ID, and drop it if necessary
if (allScreenImages.contains(id)) if (allScreenImages.contains(id))
deleteImage(id); deleteImage(id);
ScreenImage* i = new ScreenImage(filename, x, y, visible, scale, alp QString path = StelFileMgr::findFile("scripts/" + filename);
ha, fadeDuration); if (!path.isEmpty())
if (i==NULL) {
return; ScreenImage* i = new ScreenImage(path, x, y, visible, scale,
alpha, fadeDuration);
if (i==NULL)
return;
allScreenImages[id] = i; allScreenImages[id] = i;
}
else
{
qWarning() << "Failed to create ScreenImage: file not exists
";
}
} }
void ScreenImageMgr::deleteImage(const QString& id) void ScreenImageMgr::deleteImage(const QString& id)
{ {
if (allScreenImages.contains(id)) if (allScreenImages.contains(id))
{ {
if (allScreenImages[id]!=NULL) if (allScreenImages[id]!=NULL)
{ {
delete allScreenImages[id]; delete allScreenImages[id];
allScreenImages[id] = NULL; allScreenImages[id] = NULL;
 End of changes. 6 change blocks. 
38 lines changed or deleted 38 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/