Mercurial > hg > orthanc-stone
changeset 906:52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 17 Jul 2019 17:17:34 +0200 |
parents | 88bf49aebc13 |
children | 2f16ad9d30ad |
files | Applications/Generic/GuiAdapter.cpp Framework/Scene2DViewport/AngleMeasureTool.cpp Framework/Scene2DViewport/LayerHolder.cpp Framework/Scene2DViewport/LayerHolder.h Framework/Scene2DViewport/LineMeasureTool.cpp Framework/Scene2DViewport/MeasureToolsToolbox.cpp Framework/Scene2DViewport/MeasureToolsToolbox.h Framework/Scene2DViewport/ViewportController.cpp |
diffstat | 8 files changed, 107 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/Applications/Generic/GuiAdapter.cpp Wed Jul 17 16:56:53 2019 +0200 +++ b/Applications/Generic/GuiAdapter.cpp Wed Jul 17 17:17:34 2019 +0200 @@ -725,10 +725,13 @@ // SDL ONLY void GuiAdapter::Run() { +#if 0 + // TODO: MAKE THIS DYNAMIC !!! See SdlOpenGLViewport vs Cairo in ViewportWrapper # if ORTHANC_ENABLE_OPENGL == 1 && !defined(__APPLE__) glEnable(GL_DEBUG_OUTPUT); glDebugMessageCallback(OpenGLMessageCallback, 0); # endif +#endif // Uint32 SDL_GetWindowID(SDL_Window* window) // SDL_Window* SDL_GetWindowFromID(Uint32 id) // may return NULL
--- a/Framework/Scene2DViewport/AngleMeasureTool.cpp Wed Jul 17 16:56:53 2019 +0200 +++ b/Framework/Scene2DViewport/AngleMeasureTool.cpp Wed Jul 17 17:17:34 2019 +0200 @@ -43,7 +43,11 @@ AngleMeasureTool::AngleMeasureTool( MessageBroker& broker, boost::weak_ptr<ViewportController> controllerW) : MeasureTool(broker, controllerW) +#if ORTHANC_STONE_ENABLE_OUTLINED_TEXT == 1 , layerHolder_(boost::make_shared<LayerHolder>(controllerW,1,5)) +#else + , layerHolder_(boost::make_shared<LayerHolder>(controllerW, 1, 1)) +#endif , angleHighlightArea_(AngleHighlightArea_None) { RefreshScene(); @@ -293,8 +297,13 @@ // http://www.ltg.ed.ac.uk/~richard/utf-8.cgi?input=00B0&mode=hex sprintf(buf, "%0.02f\xc2\xb0", angleDeg); +#if ORTHANC_STONE_ENABLE_OUTLINED_TEXT == 1 SetTextLayerOutlineProperties( - GetController()->GetScene(), layerHolder_, buf, ScenePoint2D(pointX, pointY)); + GetController()->GetScene(), layerHolder_, buf, ScenePoint2D(pointX, pointY), 0); +#else + SetTextLayerProperties( + GetController()->GetScene(), layerHolder_, buf, ScenePoint2D(pointX, pointY) , 0); +#endif #if 0 // TODO:make it togglable
--- a/Framework/Scene2DViewport/LayerHolder.cpp Wed Jul 17 16:56:53 2019 +0200 +++ b/Framework/Scene2DViewport/LayerHolder.cpp Wed Jul 17 17:17:34 2019 +0200 @@ -30,9 +30,11 @@ LayerHolder::LayerHolder( boost::weak_ptr<ViewportController> controllerW, int polylineLayerCount, - int textLayerCount) + int textLayerCount, + int infoTextCount) : textLayerCount_(textLayerCount) , polylineLayerCount_(polylineLayerCount) + , infoTextCount_(infoTextCount) , controllerW_(controllerW) , baseLayerIndex_(-1) {
--- a/Framework/Scene2DViewport/LayerHolder.h Wed Jul 17 16:56:53 2019 +0200 +++ b/Framework/Scene2DViewport/LayerHolder.h Wed Jul 17 17:17:34 2019 +0200 @@ -44,7 +44,7 @@ */ LayerHolder( boost::weak_ptr<ViewportController> controllerW, - int polylineLayerCount, int textLayerCount); + int polylineLayerCount, int textLayerCount, int infoTextCount = 0); /** This actually creates the layers @@ -86,13 +86,17 @@ */ TextSceneLayer* GetTextLayer(int index = 0); + //TextSceneLayer* GetTextLayer(int index = 0); + private: int GetPolylineLayerIndex(int index = 0); int GetTextLayerIndex(int index = 0); + int GetInfoTextLayerIndex(int index = 0); Scene2D& GetScene(); int textLayerCount_; int polylineLayerCount_; + int infoTextCount_; boost::weak_ptr<ViewportController> controllerW_; int baseLayerIndex_; };
--- a/Framework/Scene2DViewport/LineMeasureTool.cpp Wed Jul 17 16:56:53 2019 +0200 +++ b/Framework/Scene2DViewport/LineMeasureTool.cpp Wed Jul 17 17:17:34 2019 +0200 @@ -33,7 +33,11 @@ LineMeasureTool::LineMeasureTool( MessageBroker& broker, boost::weak_ptr<ViewportController> controllerW) : MeasureTool(broker, controllerW) +#if ORTHANC_STONE_ENABLE_OUTLINED_TEXT == 1 , layerHolder_(boost::make_shared<LayerHolder>(controllerW, 1, 5)) +#else + , layerHolder_(boost::make_shared<LayerHolder>(controllerW, 1, 1)) +#endif , lineHighlightArea_(LineHighlightArea_None) { @@ -234,8 +238,13 @@ double midX = 0.5 * (end_.GetX() + start_.GetX()); double midY = 0.5 * (end_.GetY() + start_.GetY()); +#if ORTHANC_STONE_ENABLE_OUTLINED_TEXT == 1 SetTextLayerOutlineProperties( - GetController()->GetScene(), layerHolder_, buf, ScenePoint2D(midX, midY)); + GetController()->GetScene(), layerHolder_, buf, ScenePoint2D(midX, midY), 0); +#else + SetTextLayerProperties( + GetController()->GetScene(), layerHolder_, buf, ScenePoint2D(midX, midY), 0); +#endif } } else
--- a/Framework/Scene2DViewport/MeasureToolsToolbox.cpp Wed Jul 17 16:56:53 2019 +0200 +++ b/Framework/Scene2DViewport/MeasureToolsToolbox.cpp Wed Jul 17 17:17:34 2019 +0200 @@ -282,6 +282,7 @@ } #endif +#if ORTHANC_STONE_ENABLE_OUTLINED_TEXT == 1 /** This utility function assumes that the layer holder contains 5 text layers and will use the first four ones for the text background and the fifth one @@ -307,7 +308,7 @@ ORTHANC_ASSERT(textLayer != NULL); textLayer->SetText(text); - if (i == 4) + if (i == startingLayerIndex + 4) { textLayer->SetColor(TEXT_COLOR_RED, TEXT_COLOR_GREEN, @@ -321,11 +322,35 @@ } ScenePoint2D textAnchor; + int offIndex = i - startingLayerIndex; + ORTHANC_ASSERT(offIndex >= 0 && offIndex < 5); textLayer->SetPosition( - p.GetX() + xoffsets[i] * pixelToScene, - p.GetY() + yoffsets[i] * pixelToScene); + p.GetX() + xoffsets[offIndex] * pixelToScene, + p.GetY() + yoffsets[offIndex] * pixelToScene); } } +#else + void SetTextLayerProperties( + Scene2D& scene + , boost::shared_ptr<LayerHolder> layerHolder + , const char* text + , ScenePoint2D p + , int layerIndex) + { + // get the scaling factor + const double pixelToScene = + scene.GetCanvasToSceneTransform().ComputeZoom(); + + TextSceneLayer* textLayer = layerHolder->GetTextLayer(layerIndex); + ORTHANC_ASSERT(textLayer != NULL); + textLayer->SetText(text); + + textLayer->SetColor(TEXT_COLOR_RED, TEXT_COLOR_GREEN, TEXT_COLOR_BLUE); + + ScenePoint2D textAnchor; + textLayer->SetPosition(p.GetX(), p.GetY()); + } +#endif std::ostream& operator<<(std::ostream& os, const ScenePoint2D& p) {
--- a/Framework/Scene2DViewport/MeasureToolsToolbox.h Wed Jul 17 16:56:53 2019 +0200 +++ b/Framework/Scene2DViewport/MeasureToolsToolbox.h Wed Jul 17 17:17:34 2019 +0200 @@ -170,6 +170,7 @@ , const double d); +#if ORTHANC_STONE_ENABLE_OUTLINED_TEXT == 1 /** This helper is used when drawing text with an outline. It set the properties for several text layers at once : first the @@ -177,14 +178,22 @@ layer. The five text layers are supposed to already exist in the scene, starting - from layerIndex, up to (and not including) layerIndex+5. + from startingLayerIndex, up to (and not including) startingLayerIndex+5. */ void SetTextLayerOutlineProperties( Scene2D& scene , boost::shared_ptr<LayerHolder> layerHolder , const char* text , ScenePoint2D p - , int startingLayerIndex = 0); + , int startingLayerIndex); +#else + void SetTextLayerProperties( + Scene2D& scene + , boost::shared_ptr<LayerHolder> layerHolder + , const char* text + , ScenePoint2D p + , int layerIndex); +#endif std::ostream& operator<<(std::ostream& os, const ScenePoint2D& p); }
--- a/Framework/Scene2DViewport/ViewportController.cpp Wed Jul 17 16:56:53 2019 +0200 +++ b/Framework/Scene2DViewport/ViewportController.cpp Wed Jul 17 17:17:34 2019 +0200 @@ -51,27 +51,59 @@ void ViewportController::PushCommand(boost::shared_ptr<TrackerCommand> command) { - GetUndoStack()->PushCommand(command); + boost::shared_ptr<UndoStack> undoStack = undoStackW_.lock(); + if(undoStack.get() != NULL) + undoStack->PushCommand(command); + else + { + LOG(ERROR) << "Internal error: no undo stack in the viewport controller!"; + } } void ViewportController::Undo() { - GetUndoStack()->Undo(); + boost::shared_ptr<UndoStack> undoStack = undoStackW_.lock(); + if (undoStack.get() != NULL) + undoStack->Undo(); + else + { + LOG(ERROR) << "Internal error: no undo stack in the viewport controller!"; + } } void ViewportController::Redo() { - GetUndoStack()->Redo(); + boost::shared_ptr<UndoStack> undoStack = undoStackW_.lock(); + if (undoStack.get() != NULL) + undoStack->Redo(); + else + { + LOG(ERROR) << "Internal error: no undo stack in the viewport controller!"; + } } bool ViewportController::CanUndo() const { - return GetUndoStack()->CanUndo(); + boost::shared_ptr<UndoStack> undoStack = undoStackW_.lock(); + if (undoStack.get() != NULL) + return undoStack->CanUndo(); + else + { + LOG(ERROR) << "Internal error: no undo stack in the viewport controller!"; + return false; + } } bool ViewportController::CanRedo() const { - return GetUndoStack()->CanRedo(); + boost::shared_ptr<UndoStack> undoStack = undoStackW_.lock(); + if (undoStack.get() != NULL) + return undoStack->CanRedo(); + else + { + LOG(ERROR) << "Internal error: no undo stack in the viewport controller!"; + return false; + } } bool ViewportController::HandlePointerEvent(PointerEvent e)