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,\
ucbhelper \
utl \
vcl \
vclopengl \
$(gb_UWINAPI) \
))
......
......@@ -726,6 +726,9 @@ void SAL_CALL ChartController::dispose()
//--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 );
if( xViewBroadcaster.is() )
xViewBroadcaster->removeModeChangeListener(this);
......
......@@ -22,8 +22,11 @@
#include "HelpIds.hrc"
#include <vcl/help.hxx>
#include <vcl/openglwin.hxx>
#include <vcl/settings.hxx>
#include <com/sun/star/chart2/X3DChartWindowProvider.hpp>
using namespace ::com::sun::star;
namespace
......@@ -42,10 +45,11 @@ namespace
namespace chart
{
ChartWindow::ChartWindow( WindowController* pWindowController, Window* pParent, WinBits nStyle )
ChartWindow::ChartWindow( ChartController* pController, Window* pParent, WinBits nStyle )
: Window(pParent, nStyle)
, m_pWindowController( pWindowController )
, m_pWindowController( pController )
, m_bInPaint(false)
, m_pOpenGLWindow(new OpenGLWindow(this))
{
this->SetHelpId( HID_SCH_WIN_DOCUMENT );
this->SetMapMode( MapMode(MAP_100TH_MM) );
......@@ -55,10 +59,21 @@ ChartWindow::ChartWindow( WindowController* pWindowController, Window* pParent,
EnableRTL( false );
if( pParent )
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()
{
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()
......@@ -79,10 +94,18 @@ void ChartWindow::PrePaint()
void ChartWindow::Paint( const Rectangle& rRect )
{
m_bInPaint = true;
if( m_pWindowController )
m_pWindowController->execute_Paint( rRect );
if (m_pOpenGLWindow && m_pOpenGLWindow->IsVisible())
{
m_pOpenGLWindow->Paint(rRect);
}
else if (m_pWindowController)
{
m_pWindowController->execute_Paint(rRect);
}
else
{
Window::Paint( rRect );
}
m_bInPaint = false;
}
......@@ -124,6 +147,8 @@ void ChartWindow::Resize()
m_pWindowController->execute_Resize();
else
Window::Resize();
m_pOpenGLWindow->SetSizePixel(GetSizePixel());
}
void ChartWindow::Activate()
......
......@@ -21,10 +21,12 @@
#include <vcl/window.hxx>
class OpenGLWindow;
namespace chart
{
class WindowController;
class ChartController;
/** The ChartWindow collects events from the window and forwards them the to the controller
thus the controller can perform appropriate actions
......@@ -33,7 +35,7 @@ thus the controller can perform appropriate actions
class ChartWindow : public Window
{
public:
ChartWindow( WindowController* pWindowController, Window* pParent, WinBits nStyle );
ChartWindow( ChartController* pController, Window* pParent, WinBits nStyle );
virtual ~ChartWindow();
void clear();
......@@ -63,8 +65,9 @@ public:
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
private:
WindowController* m_pWindowController;
ChartController* m_pWindowController;
bool m_bInPaint;
OpenGLWindow* m_pOpenGLWindow;
void adjustHighContrastMode();
};
......
......@@ -1412,7 +1412,6 @@ void ChartModel::setWindow( const sal_uInt64 nWindowPtr )
{
void* pPtr = (void*)nWindowPtr;
OpenGLWindow* pWindow = reinterpret_cast<OpenGLWindow*>(pPtr);
assert(pWindow);
mpOpenGLWindow = pWindow;
}
......
......@@ -47,8 +47,8 @@ void RenderThread::renderFrame()
if(!mpChart->mbValidContext)
return;
mpChart->mrWindow.getContext().makeCurrent();
Size aSize = mpChart->mrWindow.GetSizePixel();
mpChart->mpWindow->getContext().makeCurrent();
Size aSize = mpChart->mpWindow->GetSizePixel();
mpChart->mpRenderer->SetSize(aSize);
if(mpChart->mbNeedsNewRender)
{
......@@ -64,7 +64,7 @@ void RenderThread::renderFrame()
}
mpChart->mpRenderer->ProcessUnrenderedShape(mpChart->mbNeedsNewRender);
mpChart->mbNeedsNewRender = false;
mpChart->mrWindow.getContext().swapBuffers();
mpChart->mpWindow->getContext().swapBuffers();
}
......@@ -127,10 +127,10 @@ void RenderAnimationThread::execute()
GL3DBarChart::GL3DBarChart(
const css::uno::Reference<css::chart2::XChartType>& xChartType,
OpenGLWindow& rWindow) :
OpenGLWindow* pWindow) :
mxChartType(xChartType),
mpRenderer(new opengl3D::OpenGL3DRenderer()),
mrWindow(rWindow),
mpWindow(pWindow),
mpCamera(NULL),
mbValidContext(true),
mpTextCache(new opengl3D::TextCache()),
......@@ -142,9 +142,13 @@ GL3DBarChart::GL3DBarChart(
mbNeedsNewRender(true),
mbCameraInit(false)
{
Size aSize = mrWindow.GetSizePixel();
Size aSize;
if (mpWindow)
{
mpWindow->setRenderer(this);
Size aSize = mpWindow->GetSizePixel();
}
mpRenderer->SetSize(aSize);
mrWindow.setRenderer(this);
mpRenderer->init();
}
......@@ -162,8 +166,8 @@ GL3DBarChart::~GL3DBarChart()
if(mpRenderThread.is())
mpRenderThread->join();
osl::MutexGuard aGuard(maMutex);
if(mbValidContext)
mrWindow.setRenderer(NULL);
if(mbValidContext && mpWindow)
mpWindow->setRenderer(NULL);
}
namespace {
......@@ -288,7 +292,7 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
BarInformation(glm::vec3(nXPos, nYPos, float(nVal/nMaxVal)),
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;
}
......@@ -403,10 +407,10 @@ void GL3DBarChart::update()
{
if(mpRenderThread.is())
mpRenderThread->join();
Size aSize = mrWindow.GetSizePixel();
mrWindow.getContext().setWinSize(aSize);
Size aSize = mpWindow->GetSizePixel();
mpWindow->getContext().setWinSize(aSize);
mpRenderThread = rtl::Reference<RenderThread>(new RenderOneFrameThread(this));
mrWindow.getContext().resetCurrent();
mpWindow->getContext().resetCurrent();
mpRenderThread->launch();
}
......@@ -438,10 +442,10 @@ void GL3DBarChart::moveToDefault()
if(mpRenderThread.is())
mpRenderThread->join();
Size aSize = mrWindow.GetSizePixel();
mrWindow.getContext().setWinSize(aSize);
Size aSize = mpWindow->GetSizePixel();
mpWindow->getContext().setWinSize(aSize);
mpRenderThread = rtl::Reference<RenderThread>(new RenderAnimationThread(this, maCameraPosition, maDefaultCameraPosition, STEPS));
mrWindow.getContext().resetCurrent();
mpWindow->getContext().resetCurrent();
mpRenderThread->launch();
/*
......@@ -496,10 +500,10 @@ void GL3DBarChart::clickedAt(const Point& rPos, sal_uInt16 nButtons)
glm::vec3 maTargetPosition = rBarInfo.maPos;
maTargetPosition.z += 240;
maTargetPosition.y += BAR_SIZE_Y / 2.0f;
Size aSize = mrWindow.GetSizePixel();
mrWindow.getContext().setWinSize(aSize);
Size aSize = mpWindow->GetSizePixel();
mpWindow->getContext().setWinSize(aSize);
mpRenderThread = rtl::Reference<RenderThread>(new RenderAnimationThread(this, maCameraPosition, maTargetPosition, STEPS));
mrWindow.getContext().resetCurrent();
mpWindow->getContext().resetCurrent();
mpRenderThread->launch();
/*
......@@ -577,11 +581,11 @@ void GL3DBarChart::moveToCorner()
if(mpRenderThread.is())
mpRenderThread->join();
Size aSize = mrWindow.GetSizePixel();
mrWindow.getContext().setWinSize(aSize);
Size aSize = mpWindow->GetSizePixel();
mpWindow->getContext().setWinSize(aSize);
mpRenderThread = rtl::Reference<RenderThread>(new RenderAnimationThread(this, getCornerPosition(mnCornerId),
maCameraPosition, STEPS));
mrWindow.getContext().resetCurrent();
mpWindow->getContext().resetCurrent();
mpRenderThread->launch();
// TODO: moggi: add to thread
......@@ -604,6 +608,12 @@ void GL3DBarChart::contextDestroyed()
mbValidContext = false;
}
void GL3DBarChart::setOpenGLWindow(OpenGLWindow* pWindow)
{
if (mpWindow != pWindow)
mpWindow = pWindow;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -49,7 +49,7 @@ class GL3DBarChart : public GL3DPlotterBase, public IRenderer
public:
GL3DBarChart(
const css::uno::Reference<css::chart2::XChartType>& xChartType,
OpenGLWindow& rContext);
OpenGLWindow* pContext);
virtual ~GL3DBarChart();
......@@ -65,6 +65,8 @@ public:
virtual void scroll(long nDelta) SAL_OVERRIDE;
virtual void contextDestroyed() SAL_OVERRIDE;
void setOpenGLWindow(OpenGLWindow* pWindow);
private:
void moveToCorner();
......@@ -75,7 +77,7 @@ private:
boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
boost::scoped_ptr<opengl3D::OpenGL3DRenderer> mpRenderer;
OpenGLWindow& mrWindow;
OpenGLWindow* mpWindow;
opengl3D::Camera* mpCamera;
bool mbValidContext;
......
......@@ -3250,7 +3250,13 @@ void ChartView::createShapes3D()
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 );
......
......@@ -544,22 +544,6 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
ScDocument& rScDoc = pScDocSh->GetDocument();
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 )
{
const SfxPoolItem* pItem;
......@@ -634,7 +618,6 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
// get chart position (from window size and data range)
aStart = pViewSh->GetChartInsertPos( aSize, aPositionRange );
}
pChildWindow->SetPosPixel(pChildWindow->LogicToPixel(aStart, MapMode(MAP_100TH_MM)));
Rectangle aRect (aStart, aSize);
SdrOle2Obj* pObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aName, aRect);
......@@ -729,7 +712,6 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
sal_Int16 nDialogRet = xDialog->execute();
if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL )
{
pGridWindow->DeleteChildWindow(pChildWindow);
// leave OLE inplace mode and unmark
OSL_ASSERT( pViewShell );
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