Kaydet (Commit) 46cea346 authored tarafından Jan Holesovsky's avatar Jan Holesovsky Kaydeden (comit) Zolnai Tamás

opengl charts: Move the init from sc to chart2, to have the right parent.

Change-Id: I1e23329345e00e7d8e1f269c832e84d015824c0a
üst df5202ff
...@@ -43,6 +43,7 @@ $(eval $(call gb_Library_use_libraries,chartcontroller,\ ...@@ -43,6 +43,7 @@ $(eval $(call gb_Library_use_libraries,chartcontroller,\
ucbhelper \ ucbhelper \
utl \ utl \
vcl \ vcl \
vclopengl \
$(gb_UWINAPI) \ $(gb_UWINAPI) \
)) ))
......
...@@ -726,6 +726,9 @@ void SAL_CALL ChartController::dispose() ...@@ -726,6 +726,9 @@ void SAL_CALL ChartController::dispose()
//--release all resources and references //--release all resources and references
{ {
uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider(getModel(), uno::UNO_QUERY_THROW);
x3DWindowProvider->setWindow(0);
uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY ); uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY );
if( xViewBroadcaster.is() ) if( xViewBroadcaster.is() )
xViewBroadcaster->removeModeChangeListener(this); xViewBroadcaster->removeModeChangeListener(this);
......
...@@ -22,8 +22,11 @@ ...@@ -22,8 +22,11 @@
#include "HelpIds.hrc" #include "HelpIds.hrc"
#include <vcl/help.hxx> #include <vcl/help.hxx>
#include <vcl/openglwin.hxx>
#include <vcl/settings.hxx> #include <vcl/settings.hxx>
#include <com/sun/star/chart2/X3DChartWindowProvider.hpp>
using namespace ::com::sun::star; using namespace ::com::sun::star;
namespace namespace
...@@ -42,10 +45,11 @@ namespace ...@@ -42,10 +45,11 @@ namespace
namespace chart namespace chart
{ {
ChartWindow::ChartWindow( WindowController* pWindowController, Window* pParent, WinBits nStyle ) ChartWindow::ChartWindow( ChartController* pController, Window* pParent, WinBits nStyle )
: Window(pParent, nStyle) : Window(pParent, nStyle)
, m_pWindowController( pWindowController ) , m_pWindowController( pController )
, m_bInPaint(false) , m_bInPaint(false)
, m_pOpenGLWindow(new OpenGLWindow(this))
{ {
this->SetHelpId( HID_SCH_WIN_DOCUMENT ); this->SetHelpId( HID_SCH_WIN_DOCUMENT );
this->SetMapMode( MapMode(MAP_100TH_MM) ); this->SetMapMode( MapMode(MAP_100TH_MM) );
...@@ -55,10 +59,21 @@ ChartWindow::ChartWindow( WindowController* pWindowController, Window* pParent, ...@@ -55,10 +59,21 @@ ChartWindow::ChartWindow( WindowController* pWindowController, Window* pParent,
EnableRTL( false ); EnableRTL( false );
if( pParent ) if( pParent )
pParent->EnableRTL( false );// #i96215# necessary for a correct position of the context menu in rtl mode pParent->EnableRTL( false );// #i96215# necessary for a correct position of the context menu in rtl mode
m_pOpenGLWindow->Show();
uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider(pController->getModel(), uno::UNO_QUERY_THROW);
sal_uInt64 nWindowPtr = reinterpret_cast<sal_uInt64>(m_pOpenGLWindow);
x3DWindowProvider->setWindow(nWindowPtr);
} }
ChartWindow::~ChartWindow() ChartWindow::~ChartWindow()
{ {
if (m_pWindowController && m_pWindowController->getModel().is())
{
uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider(m_pWindowController->getModel(), uno::UNO_QUERY_THROW);
x3DWindowProvider->setWindow(0);
}
delete m_pOpenGLWindow;
} }
void ChartWindow::clear() void ChartWindow::clear()
...@@ -79,10 +94,18 @@ void ChartWindow::PrePaint() ...@@ -79,10 +94,18 @@ void ChartWindow::PrePaint()
void ChartWindow::Paint( const Rectangle& rRect ) void ChartWindow::Paint( const Rectangle& rRect )
{ {
m_bInPaint = true; m_bInPaint = true;
if( m_pWindowController ) if (m_pOpenGLWindow && m_pOpenGLWindow->IsVisible())
m_pWindowController->execute_Paint( rRect ); {
m_pOpenGLWindow->Paint(rRect);
}
else if (m_pWindowController)
{
m_pWindowController->execute_Paint(rRect);
}
else else
{
Window::Paint( rRect ); Window::Paint( rRect );
}
m_bInPaint = false; m_bInPaint = false;
} }
...@@ -124,6 +147,8 @@ void ChartWindow::Resize() ...@@ -124,6 +147,8 @@ void ChartWindow::Resize()
m_pWindowController->execute_Resize(); m_pWindowController->execute_Resize();
else else
Window::Resize(); Window::Resize();
m_pOpenGLWindow->SetSizePixel(GetSizePixel());
} }
void ChartWindow::Activate() void ChartWindow::Activate()
......
...@@ -21,10 +21,12 @@ ...@@ -21,10 +21,12 @@
#include <vcl/window.hxx> #include <vcl/window.hxx>
class OpenGLWindow;
namespace chart namespace chart
{ {
class WindowController; class ChartController;
/** The ChartWindow collects events from the window and forwards them the to the controller /** The ChartWindow collects events from the window and forwards them the to the controller
thus the controller can perform appropriate actions thus the controller can perform appropriate actions
...@@ -33,7 +35,7 @@ thus the controller can perform appropriate actions ...@@ -33,7 +35,7 @@ thus the controller can perform appropriate actions
class ChartWindow : public Window class ChartWindow : public Window
{ {
public: public:
ChartWindow( WindowController* pWindowController, Window* pParent, WinBits nStyle ); ChartWindow( ChartController* pController, Window* pParent, WinBits nStyle );
virtual ~ChartWindow(); virtual ~ChartWindow();
void clear(); void clear();
...@@ -63,8 +65,9 @@ public: ...@@ -63,8 +65,9 @@ public:
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE; virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
private: private:
WindowController* m_pWindowController; ChartController* m_pWindowController;
bool m_bInPaint; bool m_bInPaint;
OpenGLWindow* m_pOpenGLWindow;
void adjustHighContrastMode(); void adjustHighContrastMode();
}; };
......
...@@ -1412,7 +1412,6 @@ void ChartModel::setWindow( const sal_uInt64 nWindowPtr ) ...@@ -1412,7 +1412,6 @@ void ChartModel::setWindow( const sal_uInt64 nWindowPtr )
{ {
void* pPtr = (void*)nWindowPtr; void* pPtr = (void*)nWindowPtr;
OpenGLWindow* pWindow = reinterpret_cast<OpenGLWindow*>(pPtr); OpenGLWindow* pWindow = reinterpret_cast<OpenGLWindow*>(pPtr);
assert(pWindow);
mpOpenGLWindow = pWindow; mpOpenGLWindow = pWindow;
} }
......
...@@ -47,8 +47,8 @@ void RenderThread::renderFrame() ...@@ -47,8 +47,8 @@ void RenderThread::renderFrame()
if(!mpChart->mbValidContext) if(!mpChart->mbValidContext)
return; return;
mpChart->mrWindow.getContext().makeCurrent(); mpChart->mpWindow->getContext().makeCurrent();
Size aSize = mpChart->mrWindow.GetSizePixel(); Size aSize = mpChart->mpWindow->GetSizePixel();
mpChart->mpRenderer->SetSize(aSize); mpChart->mpRenderer->SetSize(aSize);
if(mpChart->mbNeedsNewRender) if(mpChart->mbNeedsNewRender)
{ {
...@@ -64,7 +64,7 @@ void RenderThread::renderFrame() ...@@ -64,7 +64,7 @@ void RenderThread::renderFrame()
} }
mpChart->mpRenderer->ProcessUnrenderedShape(mpChart->mbNeedsNewRender); mpChart->mpRenderer->ProcessUnrenderedShape(mpChart->mbNeedsNewRender);
mpChart->mbNeedsNewRender = false; mpChart->mbNeedsNewRender = false;
mpChart->mrWindow.getContext().swapBuffers(); mpChart->mpWindow->getContext().swapBuffers();
} }
...@@ -127,10 +127,10 @@ void RenderAnimationThread::execute() ...@@ -127,10 +127,10 @@ void RenderAnimationThread::execute()
GL3DBarChart::GL3DBarChart( GL3DBarChart::GL3DBarChart(
const css::uno::Reference<css::chart2::XChartType>& xChartType, const css::uno::Reference<css::chart2::XChartType>& xChartType,
OpenGLWindow& rWindow) : OpenGLWindow* pWindow) :
mxChartType(xChartType), mxChartType(xChartType),
mpRenderer(new opengl3D::OpenGL3DRenderer()), mpRenderer(new opengl3D::OpenGL3DRenderer()),
mrWindow(rWindow), mpWindow(pWindow),
mpCamera(NULL), mpCamera(NULL),
mbValidContext(true), mbValidContext(true),
mpTextCache(new opengl3D::TextCache()), mpTextCache(new opengl3D::TextCache()),
...@@ -142,9 +142,13 @@ GL3DBarChart::GL3DBarChart( ...@@ -142,9 +142,13 @@ GL3DBarChart::GL3DBarChart(
mbNeedsNewRender(true), mbNeedsNewRender(true),
mbCameraInit(false) mbCameraInit(false)
{ {
Size aSize = mrWindow.GetSizePixel(); Size aSize;
if (mpWindow)
{
mpWindow->setRenderer(this);
Size aSize = mpWindow->GetSizePixel();
}
mpRenderer->SetSize(aSize); mpRenderer->SetSize(aSize);
mrWindow.setRenderer(this);
mpRenderer->init(); mpRenderer->init();
} }
...@@ -162,8 +166,8 @@ GL3DBarChart::~GL3DBarChart() ...@@ -162,8 +166,8 @@ GL3DBarChart::~GL3DBarChart()
if(mpRenderThread.is()) if(mpRenderThread.is())
mpRenderThread->join(); mpRenderThread->join();
osl::MutexGuard aGuard(maMutex); osl::MutexGuard aGuard(maMutex);
if(mbValidContext) if(mbValidContext && mpWindow)
mrWindow.setRenderer(NULL); mpWindow->setRenderer(NULL);
} }
namespace { namespace {
...@@ -288,7 +292,7 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer ...@@ -288,7 +292,7 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
BarInformation(glm::vec3(nXPos, nYPos, float(nVal/nMaxVal)), BarInformation(glm::vec3(nXPos, nYPos, float(nVal/nMaxVal)),
nVal, nIndex, nSeriesIndex))); nVal, nIndex, nSeriesIndex)));
maShapes.push_back(new opengl3D::Bar(mpRenderer.get(), aBarPosition, nColor, nId)); //maShapes.push_back(new opengl3D::Bar(mpRenderer.get(), aBarPosition, nColor, nId));
nId += ID_STEP; nId += ID_STEP;
} }
...@@ -403,10 +407,10 @@ void GL3DBarChart::update() ...@@ -403,10 +407,10 @@ void GL3DBarChart::update()
{ {
if(mpRenderThread.is()) if(mpRenderThread.is())
mpRenderThread->join(); mpRenderThread->join();
Size aSize = mrWindow.GetSizePixel(); Size aSize = mpWindow->GetSizePixel();
mrWindow.getContext().setWinSize(aSize); mpWindow->getContext().setWinSize(aSize);
mpRenderThread = rtl::Reference<RenderThread>(new RenderOneFrameThread(this)); mpRenderThread = rtl::Reference<RenderThread>(new RenderOneFrameThread(this));
mrWindow.getContext().resetCurrent(); mpWindow->getContext().resetCurrent();
mpRenderThread->launch(); mpRenderThread->launch();
} }
...@@ -438,10 +442,10 @@ void GL3DBarChart::moveToDefault() ...@@ -438,10 +442,10 @@ void GL3DBarChart::moveToDefault()
if(mpRenderThread.is()) if(mpRenderThread.is())
mpRenderThread->join(); mpRenderThread->join();
Size aSize = mrWindow.GetSizePixel(); Size aSize = mpWindow->GetSizePixel();
mrWindow.getContext().setWinSize(aSize); mpWindow->getContext().setWinSize(aSize);
mpRenderThread = rtl::Reference<RenderThread>(new RenderAnimationThread(this, maCameraPosition, maDefaultCameraPosition, STEPS)); mpRenderThread = rtl::Reference<RenderThread>(new RenderAnimationThread(this, maCameraPosition, maDefaultCameraPosition, STEPS));
mrWindow.getContext().resetCurrent(); mpWindow->getContext().resetCurrent();
mpRenderThread->launch(); mpRenderThread->launch();
/* /*
...@@ -496,10 +500,10 @@ void GL3DBarChart::clickedAt(const Point& rPos, sal_uInt16 nButtons) ...@@ -496,10 +500,10 @@ void GL3DBarChart::clickedAt(const Point& rPos, sal_uInt16 nButtons)
glm::vec3 maTargetPosition = rBarInfo.maPos; glm::vec3 maTargetPosition = rBarInfo.maPos;
maTargetPosition.z += 240; maTargetPosition.z += 240;
maTargetPosition.y += BAR_SIZE_Y / 2.0f; maTargetPosition.y += BAR_SIZE_Y / 2.0f;
Size aSize = mrWindow.GetSizePixel(); Size aSize = mpWindow->GetSizePixel();
mrWindow.getContext().setWinSize(aSize); mpWindow->getContext().setWinSize(aSize);
mpRenderThread = rtl::Reference<RenderThread>(new RenderAnimationThread(this, maCameraPosition, maTargetPosition, STEPS)); mpRenderThread = rtl::Reference<RenderThread>(new RenderAnimationThread(this, maCameraPosition, maTargetPosition, STEPS));
mrWindow.getContext().resetCurrent(); mpWindow->getContext().resetCurrent();
mpRenderThread->launch(); mpRenderThread->launch();
/* /*
...@@ -577,11 +581,11 @@ void GL3DBarChart::moveToCorner() ...@@ -577,11 +581,11 @@ void GL3DBarChart::moveToCorner()
if(mpRenderThread.is()) if(mpRenderThread.is())
mpRenderThread->join(); mpRenderThread->join();
Size aSize = mrWindow.GetSizePixel(); Size aSize = mpWindow->GetSizePixel();
mrWindow.getContext().setWinSize(aSize); mpWindow->getContext().setWinSize(aSize);
mpRenderThread = rtl::Reference<RenderThread>(new RenderAnimationThread(this, getCornerPosition(mnCornerId), mpRenderThread = rtl::Reference<RenderThread>(new RenderAnimationThread(this, getCornerPosition(mnCornerId),
maCameraPosition, STEPS)); maCameraPosition, STEPS));
mrWindow.getContext().resetCurrent(); mpWindow->getContext().resetCurrent();
mpRenderThread->launch(); mpRenderThread->launch();
// TODO: moggi: add to thread // TODO: moggi: add to thread
...@@ -604,6 +608,12 @@ void GL3DBarChart::contextDestroyed() ...@@ -604,6 +608,12 @@ void GL3DBarChart::contextDestroyed()
mbValidContext = false; mbValidContext = false;
} }
void GL3DBarChart::setOpenGLWindow(OpenGLWindow* pWindow)
{
if (mpWindow != pWindow)
mpWindow = pWindow;
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -49,7 +49,7 @@ class GL3DBarChart : public GL3DPlotterBase, public IRenderer ...@@ -49,7 +49,7 @@ class GL3DBarChart : public GL3DPlotterBase, public IRenderer
public: public:
GL3DBarChart( GL3DBarChart(
const css::uno::Reference<css::chart2::XChartType>& xChartType, const css::uno::Reference<css::chart2::XChartType>& xChartType,
OpenGLWindow& rContext); OpenGLWindow* pContext);
virtual ~GL3DBarChart(); virtual ~GL3DBarChart();
...@@ -65,6 +65,8 @@ public: ...@@ -65,6 +65,8 @@ public:
virtual void scroll(long nDelta) SAL_OVERRIDE; virtual void scroll(long nDelta) SAL_OVERRIDE;
virtual void contextDestroyed() SAL_OVERRIDE; virtual void contextDestroyed() SAL_OVERRIDE;
void setOpenGLWindow(OpenGLWindow* pWindow);
private: private:
void moveToCorner(); void moveToCorner();
...@@ -75,7 +77,7 @@ private: ...@@ -75,7 +77,7 @@ private:
boost::ptr_vector<opengl3D::Renderable3DObject> maShapes; boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
boost::scoped_ptr<opengl3D::OpenGL3DRenderer> mpRenderer; boost::scoped_ptr<opengl3D::OpenGL3DRenderer> mpRenderer;
OpenGLWindow& mrWindow; OpenGLWindow* mpWindow;
opengl3D::Camera* mpCamera; opengl3D::Camera* mpCamera;
bool mbValidContext; bool mbValidContext;
......
...@@ -3250,7 +3250,13 @@ void ChartView::createShapes3D() ...@@ -3250,7 +3250,13 @@ void ChartView::createShapes3D()
if (!m_pGL3DPlotter) if (!m_pGL3DPlotter)
{ {
m_pGL3DPlotter.reset(new GL3DBarChart(xChartType, *pWindow)); m_pGL3DPlotter.reset(new GL3DBarChart(xChartType, pWindow));
}
else
{
GL3DBarChart* pChart = dynamic_cast<GL3DBarChart*>(m_pGL3DPlotter.get());
if (pChart)
pChart->setOpenGLWindow(pWindow);
} }
uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY ); uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY );
......
...@@ -544,22 +544,6 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* ...@@ -544,22 +544,6 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
ScDocument& rScDoc = pScDocSh->GetDocument(); ScDocument& rScDoc = pScDocSh->GetDocument();
bool bUndo (rScDoc.IsUndoEnabled()); bool bUndo (rScDoc.IsUndoEnabled());
Window* pParentWindow = rData.GetActiveWin();
OpenGLWindow* pChildWindow = new OpenGLWindow(pParentWindow);
Size aWindowSize = pChildWindow->LogicToPixel( aSize, MapMode( MAP_100TH_MM ) );
pChildWindow->SetSizePixel(aWindowSize);
pChildWindow->Show();
uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider( xChartModel, uno::UNO_QUERY_THROW );
sal_uInt64 nWindowPtr = reinterpret_cast<sal_uInt64>(pChildWindow);
x3DWindowProvider->setWindow(nWindowPtr);
ScGridWindow* pGridWindow = dynamic_cast<ScGridWindow*>(pParentWindow);
if(pGridWindow)
{
pGridWindow->AddChildWindow(pChildWindow);
}
else
SAL_WARN("sc", "not a grid window. You are in serious trouble");
if( pReqArgs ) if( pReqArgs )
{ {
const SfxPoolItem* pItem; const SfxPoolItem* pItem;
...@@ -634,7 +618,6 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* ...@@ -634,7 +618,6 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
// get chart position (from window size and data range) // get chart position (from window size and data range)
aStart = pViewSh->GetChartInsertPos( aSize, aPositionRange ); aStart = pViewSh->GetChartInsertPos( aSize, aPositionRange );
} }
pChildWindow->SetPosPixel(pChildWindow->LogicToPixel(aStart, MapMode(MAP_100TH_MM)));
Rectangle aRect (aStart, aSize); Rectangle aRect (aStart, aSize);
SdrOle2Obj* pObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aName, aRect); SdrOle2Obj* pObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aName, aRect);
...@@ -729,7 +712,6 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* ...@@ -729,7 +712,6 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
sal_Int16 nDialogRet = xDialog->execute(); sal_Int16 nDialogRet = xDialog->execute();
if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL ) if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL )
{ {
pGridWindow->DeleteChildWindow(pChildWindow);
// leave OLE inplace mode and unmark // leave OLE inplace mode and unmark
OSL_ASSERT( pViewShell ); OSL_ASSERT( pViewShell );
OSL_ASSERT( pView ); OSL_ASSERT( pView );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment