From: <ob...@us...> - 2012-06-25 14:32:39
|
Revision: 1421 http://scstudio.svn.sourceforge.net/scstudio/?rev=1421&view=rev Author: obouda Date: 2012-06-25 14:32:28 +0000 (Mon, 25 Jun 2012) Log Message: ----------- Drawing functions to thicken/thin lines Modified Paths: -------------- trunk/src/view/visio/addon/addon.cpp trunk/src/view/visio/addon/document.cpp trunk/src/view/visio/addon/document.h trunk/src/view/visio/addon/pageutils.cpp trunk/src/view/visio/addon/pageutils.h Modified: trunk/src/view/visio/addon/addon.cpp =================================================================== --- trunk/src/view/visio/addon/addon.cpp 2012-06-23 11:06:32 UTC (rev 1420) +++ trunk/src/view/visio/addon/addon.cpp 2012-06-25 14:32:28 UTC (rev 1421) @@ -327,6 +327,12 @@ case CDocumentMonitor::MENU_REPAINT: TRACE("CStudioAddon::Run() menu item 'Check--Drawing--Repaint'"); return pDocumentMonitor->OnMenuRepaint(vsoApp); + case CDocumentMonitor::MENU_THICKEN_LINES: + TRACE("CStudioAddon::Run() menu item 'Check--Drawing--Thicken Lines'"); + return pDocumentMonitor->OnMenuThickenLines(vsoApp); + case CDocumentMonitor::MENU_THIN_LINES: + TRACE("CStudioAddon::Run() menu item 'Check--Drawing--Thin Lines'"); + return pDocumentMonitor->OnMenuThinLines(vsoApp); case CDocumentMonitor::MENU_FIND_FLOW: TRACE("CStudioAddon::Run() menu item 'Check--Drawing--Find Flow'"); return pDocumentMonitor->OnMenuFindFlow(vsoApp); @@ -342,9 +348,9 @@ case CDocumentMonitor::MENU_CHECK_OPTIONS: TRACE("CStudioAddon::Run() menu item 'Options'"); return DisplayOptions(vsoApp); - case CDocumentMonitor::MENU_HELP: - TRACE("CStudioAddon::Run() menu item 'Help'"); - return pDocumentMonitor->OnHelp(); + case CDocumentMonitor::MENU_HELP: + TRACE("CStudioAddon::Run() menu item 'Help'"); + return pDocumentMonitor->OnHelp(); case CDocumentMonitor::MENU_SELECT_ALL_INSTANCES: TRACE("CStudioAddon::Run() menu item 'Check--Drawing--Select--All Instances'"); return pDocumentMonitor->OnMenuSelectAllInstances(vsoApp, SELECTION_REPLACE); Modified: trunk/src/view/visio/addon/document.cpp =================================================================== --- trunk/src/view/visio/addon/document.cpp 2012-06-23 11:06:32 UTC (rev 1420) +++ trunk/src/view/visio/addon/document.cpp 2012-06-25 14:32:28 UTC (rev 1421) @@ -494,6 +494,16 @@ itemRepaint->AddOnArgs = stringize() << L"/event=" << MENU_REPAINT; itemRepaint->BeginGroup = true; + Visio::IVMenuItemPtr itemThickenLines = itemDrawing->MenuItems->Add(); + itemThickenLines->Caption = "&Thicken Lines"; + itemThickenLines->AddOnName = ADDON_NAME; + itemThickenLines->AddOnArgs = stringize() << L"/event=" << MENU_THICKEN_LINES; + + Visio::IVMenuItemPtr itemThinLines = itemDrawing->MenuItems->Add(); + itemThinLines->Caption = "&Thin Lines"; + itemThinLines->AddOnName = ADDON_NAME; + itemThinLines->AddOnArgs = stringize() << L"/event=" << MENU_THIN_LINES; + for(TransformerPtrList::const_iterator tpos = m_transformers.begin(); tpos != m_transformers.end(); tpos++) { @@ -657,6 +667,18 @@ accelItemVerify->Key = 'C'; accelItemVerify->Control = true; accelItemVerify->Alt = true; + //Thicken Lines + Visio::IVAccelItemPtr accelItemThickenLines = accelTable->AccelItems->Add(); + accelItemThickenLines->CmdNum = itemThickenLines->CmdNum; + accelItemThickenLines->Key = 'T'; + accelItemThickenLines->Control = true; + accelItemThickenLines->Alt = true; + //Thin Lines + Visio::IVAccelItemPtr accelItemThinLines = accelTable->AccelItems->Add(); + accelItemThinLines->CmdNum = itemThinLines->CmdNum; + accelItemThinLines->Key = 'R'; + accelItemThinLines->Control = true; + accelItemThinLines->Alt = true; //Transforms shortcuts if(beautifyIndex >= 0) { @@ -1123,6 +1145,22 @@ return VAORC_SUCCESS; } +VAORC CDocumentMonitor::OnMenuThickenLines(Visio::IVApplicationPtr vsoApp) +{ + long scope_id = vsoApp->BeginUndoScope("Thicken Lines"); + CPageUtils::changeLineWeights(vsoApp->ActivePage, 0.5/72 /* half a point */); + vsoApp->EndUndoScope(scope_id, true); + return VAORC_SUCCESS; +} + +VAORC CDocumentMonitor::OnMenuThinLines(Visio::IVApplicationPtr vsoApp) +{ + long scope_id = vsoApp->BeginUndoScope("Thin Lines"); + CPageUtils::changeLineWeights(vsoApp->ActivePage, -0.5/72 /* half a point */); + vsoApp->EndUndoScope(scope_id, true); + return VAORC_SUCCESS; +} + VAORC CDocumentMonitor::OnMenuTransform(Visio::IVApplicationPtr vsoApp, int index) { // clear the verification report Modified: trunk/src/view/visio/addon/document.h =================================================================== --- trunk/src/view/visio/addon/document.h 2012-06-23 11:06:32 UTC (rev 1420) +++ trunk/src/view/visio/addon/document.h 2012-06-25 14:32:28 UTC (rev 1421) @@ -77,7 +77,7 @@ MENU_FIND_FLOW, MENU_SIMULATION_START, MENU_SIMULATION_STOP, - MENU_HELP, + MENU_HELP, //MENU_SIMULATOR_OPTIONS, MENU_VERIFY = 208, MENU_CHECK_OPTIONS, @@ -91,12 +91,16 @@ MENU_MESSAGE_JUMP_RIGHT_COPY, MENU_ENABLE_MESSAGE_ENUMERATION, MENU_DISABLE_MESSAGE_ENUMERATION, + MENU_THICKEN_LINES, + MENU_THIN_LINES, }; VAORC OnMenuWindowsReporter(Visio::IVApplicationPtr vsoApp); VAORC OnMenuImport(Visio::IVApplicationPtr vsoApp); VAORC OnMenuExport(Visio::IVApplicationPtr vsoApp); VAORC OnMenuRepaint(Visio::IVApplicationPtr vsoApp); + VAORC OnMenuThickenLines(Visio::IVApplicationPtr vsoApp); + VAORC OnMenuThinLines(Visio::IVApplicationPtr vsoApp); VAORC OnMenuTransform(Visio::IVApplicationPtr vsoApp, int index); VAORC OnMenuSelectAllInstances(Visio::IVApplicationPtr vsoApp, SelectionType selType); VAORC OnMenuSelectAllMessages(Visio::IVApplicationPtr vsoApp, SelectionType selType); Modified: trunk/src/view/visio/addon/pageutils.cpp =================================================================== --- trunk/src/view/visio/addon/pageutils.cpp 2012-06-23 11:06:32 UTC (rev 1420) +++ trunk/src/view/visio/addon/pageutils.cpp 2012-06-25 14:32:28 UTC (rev 1421) @@ -172,4 +172,37 @@ return MscPoint(normalVec); } +void CPageUtils::changeLineWeights(Visio::IVPagePtr vsoPage, double step) +{ + Visio::IVShapesPtr shapes = vsoPage->Shapes; + if (shapes->Count == 0) + { + return; + } + + bool thicken = (step > 0); + + // step 1: find the maximal/minimal weight + double extremeWeight = shapes->Item[1]->CellsSRC[visSectionObject][visRowLine][visLineWeight]->Result[0]; + bool allAtSameWeight = true; + for (int i = 2; i <= shapes->Count; i++) + { + double slw = shapes->Item[i]->CellsSRC[visSectionObject][visRowLine][visLineWeight]->Result[0]; + if (abs(slw - extremeWeight) > 1e-6) + { + allAtSameWeight = false; + extremeWeight = (thicken ? max(extremeWeight, slw) : min(extremeWeight, slw)); + } + } + // step 2: get the line weight to set + double newWeight = (allAtSameWeight ? extremeWeight + step : extremeWeight); + newWeight = max(1.0/72, newWeight); // a guard + // step 3: thicken the shapes thinner than the closest step + for (int i = 1; i <= shapes->Count; i++) + { + Visio::IVCellPtr lwCell = shapes->Item[i]->CellsSRC[visSectionObject][visRowLine][visLineWeight]; + lwCell->Result[0] = newWeight; + } +} + // $Id$ Modified: trunk/src/view/visio/addon/pageutils.h =================================================================== --- trunk/src/view/visio/addon/pageutils.h 2012-06-23 11:06:32 UTC (rev 1420) +++ trunk/src/view/visio/addon/pageutils.h 2012-06-25 14:32:28 UTC (rev 1421) @@ -97,6 +97,8 @@ static double GetOriginGridY(Visio::IVPagePtr vsoPage, int units = visPageUnits); static MscPoint getNormalVec(const MscPoint& origVector, double newVectorSize); + + static void changeLineWeights(Visio::IVPagePtr vsoPage, double step); }; // $Id$ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |