Kaydet (Commit) 43d23a24 authored tarafından Jan Holesovsky's avatar Jan Holesovsky Kaydeden (comit) Markus Mohrhard

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

Conflicts:
	chart2/source/view/charttypes/GL3DBarChart.cxx

Change-Id: I1e23329345e00e7d8e1f269c832e84d015824c0a
üst 235fa033
......@@ -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;
}
......
......@@ -103,8 +103,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)
{
......@@ -121,7 +121,7 @@ void RenderThread::renderFrame()
}
mpChart->mpRenderer->ProcessUnrenderedShape(mpChart->mbNeedsNewRender);
mpChart->mbNeedsNewRender = false;
mpChart->mrWindow.getContext().swapBuffers();
mpChart->mpWindow->getContext().swapBuffers();
}
......@@ -438,10 +438,10 @@ void RenderBenchMarkThread::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()),
......@@ -492,9 +492,14 @@ GL3DBarChart::GL3DBarChart(
osl_getSystemTime(&maDataUpdateStartTime);
osl_getSystemTime(&maDataUpdateEndTime);
}
Size aSize = mrWindow.GetSizePixel();
Size aSize;
if (mpWindow)
{
mpWindow->setRenderer(this);
Size aSize = mpWindow->GetSizePixel();
}
mpRenderer->SetSize(aSize);
mrWindow.setRenderer(this);
mpWindow->setRenderer(this);
mpRenderer->init();
}
......@@ -518,8 +523,8 @@ GL3DBarChart::~GL3DBarChart()
if(mpRenderThread.is())
mpRenderThread->join();
if(mbValidContext)
mrWindow.setRenderer(NULL);
if(mbValidContext && mpWindow)
mpWindow->setRenderer(NULL);
}
void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSeriesContainer,
......@@ -741,10 +746,10 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
mpRenderer->SetScrollSpeed((float)(BAR_SIZE_X + BAR_DISTANCE_X) / (float)miScrollRate);
mpRenderer->SetScrollDistance((float)(BAR_SIZE_X + BAR_DISTANCE_X));
}
Size aSize = mrWindow.GetSizePixel();
mrWindow.getContext().setWinSize(aSize);
Size aSize = mpWindow->GetSizePixel();
mpWindow->getContext().setWinSize(aSize);
mpRenderThread = rtl::Reference<RenderThread>(new RenderBenchMarkThread(this));
mrWindow.getContext().resetCurrent();
mpWindow->getContext().resetCurrent();
mpRenderThread->launch();
}
miDataUpdateCounter++;
......@@ -758,10 +763,10 @@ void GL3DBarChart::update()
return;
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();
}
......@@ -807,10 +812,10 @@ void GL3DBarChart::moveToDefault()
mpRenderThread->join();
osl::MutexGuard aGuard(maMutex);
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();
/*
......@@ -879,10 +884,10 @@ void GL3DBarChart::clickedAt(const Point& rPos, sal_uInt16 nButtons)
glm::vec3 aTargetPosition = rBarInfo.maPos;
aTargetPosition.z += 240;
aTargetPosition.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, aTargetPosition, STEPS));
mrWindow.getContext().resetCurrent();
mpWindow->getContext().resetCurrent();
mpRenderThread->launch();
/*
......@@ -969,11 +974,11 @@ void GL3DBarChart::moveToCorner()
osl::MutexGuard aGuard(maMutex);
Size aSize = mrWindow.GetSizePixel();
mrWindow.getContext().setWinSize(aSize);
Size aSize = mpWindow->GetSizePixel();
mpWindow->getContext().setWinSize(aSize);
mpRenderThread = rtl::Reference<RenderThread>(new RenderAnimationThread(this, maCameraPosition,
getCornerPosition(mnCornerId), STEPS));
mrWindow.getContext().resetCurrent();
mpWindow->getContext().resetCurrent();
mpRenderThread->launch();
// TODO: moggi: add to thread
......@@ -1305,6 +1310,13 @@ IMPL_LINK_NOARG(GL3DBarChart, updateTimer)
maTimer.Start();
return 0;
}
void GL3DBarChart::setOpenGLWindow(OpenGLWindow* pWindow)
{
if (mpWindow != pWindow)
mpWindow = pWindow;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -65,7 +65,7 @@ class GL3DBarChart : public GL3DPlotterBase, public IRenderer
public:
GL3DBarChart(
const css::uno::Reference<css::chart2::XChartType>& xChartType,
OpenGLWindow& rContext);
OpenGLWindow* pContext);
virtual ~GL3DBarChart();
......@@ -81,6 +81,8 @@ public:
virtual void scroll(long nDelta) SAL_OVERRIDE;
virtual void contextDestroyed() SAL_OVERRIDE;
void setOpenGLWindow(OpenGLWindow* pWindow);
private:
void moveToCorner();
......@@ -110,7 +112,7 @@ private:
boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
boost::scoped_ptr<opengl3D::OpenGL3DRenderer> mpRenderer;
OpenGLWindow& mrWindow;
OpenGLWindow* mpWindow;
opengl3D::Camera* mpCamera;
bool mbValidContext;
......
......@@ -3191,7 +3191,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