Exemplo n.º 1
0
// Plots the raw data as floats, then the events and then the marks.
// Changed with DATE
BOOL CPlotPane::UpdateAxisData(UINT uiAxisIndex, float huge *faCounts, float huge *faDates,
	ULONG ulNumPts, const CGStr &DetName, BOOL bRefreshDisplay,	ULONG ulNumEvents,
	EVENTS1 *aEvents, ULONG ulNumMarks, MARKS1 *aMarks)
{
	const BOOL bCOPY_DATA_TRUE = TRUE;
	BOOL bSuccess;
	
	bSuccess = UpdateAreaData(uiAxisIndex, faDates, faCounts, ulNumPts,
		bCOPY_DATA_TRUE, DetName, bRefreshDisplay);

	ClearHiliteRegions(uiAxisIndex);
	for (ULONG ul = 0; ul < ulNumEvents; ul++) {
//		AddHiliteRegion(uiAxisIndex, aEvents[ul].ulRelDateFirst, aEvents[ul].ulRelDateLast, aEvents[ul].Color, aEvents[ul].Label);
		AddHiliteRegion(uiAxisIndex, aEvents[ul].dRelDateFirst, aEvents[ul].dRelDateLast, aEvents[ul].Color, aEvents[ul].Label);
	}

	ClearMarkers(uiAxisIndex);
	CGStr MarkerLabel;
	
	if (mpPlotDlg != NULL) {
		for (ul = 0; ul < ulNumMarks; ul++) {
//			MarkerLabel = mpPlotDlg->RelDateToTimeStr(aMarks[ul].ulRelDateSec);
//			AddMarker(uiAxisIndex, aMarks[ul].ulRelDateSec, MarkerLabel, CPlotDlg::mMarkerTextColor);
			MarkerLabel = mpPlotDlg->RelDateToTimeStr(aMarks[ul].dRelDateSec);
			AddMarker(uiAxisIndex, aMarks[ul].dRelDateSec, MarkerLabel, CPlotDlg::mMarkerTextColor);
		}
	}

	return(bSuccess);
}
/*virtual*/ void WBCompEldMapMarker::HandleEvent( const WBEvent& Event )
{
	Super::HandleEvent( Event );

	STATIC_HASHED_STRING( OnMoved );
	STATIC_HASHED_STRING( OnTurned );
	STATIC_HASHED_STRING( OnInitializedQueued );
	STATIC_HASHED_STRING( OnDestroyed );

	const HashedString EventName = Event.GetEventName();
	if( EventName == sOnInitializedQueued )
	{
		AddMarker();
		UpdateMarker();
	}
	else if( EventName == sOnMoved || sOnTurned )
	{
		UpdateMarker();
	}
	else if( EventName == sOnDestroyed )
	{
		RemoveMarker();
	}
}
//************************************************************************************
BOOL CBCGPOutlineParser::AddMarker (CBCGPOutlineNode* pMarkerBlock, CBCGPOutlineNode* pParentNode,
									BCGP_EDIT_OUTLINE_CHANGES& changes) const
{
	ASSERT_VALID (pMarkerBlock);
	ASSERT_VALID (pParentNode);
	ASSERT ((pMarkerBlock->m_dwFlags & g_dwOBFLeft) != 0 ||
			(pMarkerBlock->m_dwFlags & g_dwOBFRight) != 0);

	// ---------------------------------------
	// Search for marker fitting for this one:
	// ---------------------------------------
	CBCGPOutlineNode* pComposeWith = FindFittingBlock (pMarkerBlock, pParentNode);

	if (pComposeWith != NULL)
	{
		ASSERT_VALID (pComposeWith);

		// ---------------------------------------------------------
		// Combine new marker with existed block or with pair marker
		// ---------------------------------------------------------
		CBCGPOutlineBaseNode* pLeft = NULL;
		CBCGPOutlineBaseNode* pRight = NULL;

		if ((pMarkerBlock->m_dwFlags & g_dwOBFLeft) != 0)
		{
			ASSERT ((pComposeWith->m_dwFlags & g_dwOBFComplete) != 0 ||
					(pComposeWith->m_dwFlags & g_dwOBFRight) != 0);

			pLeft = pMarkerBlock;
			pRight = pComposeWith;
		}
		else if ((pMarkerBlock->m_dwFlags & g_dwOBFRight) != 0)
		{
			ASSERT ((pComposeWith->m_dwFlags & g_dwOBFComplete) != 0 ||
					(pComposeWith->m_dwFlags & g_dwOBFLeft) != 0);

			pLeft = pComposeWith;
			pRight = pMarkerBlock;
		}
		else
		{
			ASSERT (FALSE);
			return FALSE;
		}

		CBCGPOutlineNode* pParent = pComposeWith->GetParentNode ();
		ASSERT_VALID (pParent);

		if (pLeft != NULL && pRight != NULL)
		{
			ASSERT (pLeft->m_nStart < pRight->m_nEnd);
			ASSERT (pLeft->m_strReplace == pRight->m_strReplace);

			// ---------------
			// Make new block:
			// ---------------
			RemoveNode (pComposeWith, pParent, changes);
			CBCGPOutlineNode* pNewBlock = new CBCGPOutlineNode (*pLeft);
			pNewBlock->m_dwFlags &= ~g_dwOBFLeft;
			pNewBlock->m_dwFlags |= g_dwOBFComplete;
			pNewBlock->m_bCollapsed = FALSE;
			pNewBlock->m_nEnd = pRight->m_nEnd;

			AddNode (pNewBlock, pParent, changes);
		}
		else
		{
			ASSERT (FALSE);
			return FALSE;
		}

		if ((pComposeWith->m_dwFlags & g_dwOBFComplete) != 0)
		{
			// ----------------------------------------------------------------------
			// The rest of old block contains start/close sequence - add it as marker
			// ----------------------------------------------------------------------
			CBCGPOutlineNode* pNewMarker = new CBCGPOutlineNode (*pComposeWith->GetValue ());
			const BlockType* pBlockType = GetBlockType (pNewMarker->m_nBlockType);
			if ((pMarkerBlock->m_dwFlags & g_dwOBFLeft) != 0)
			{
				// add start marker (g_dwOBFLeft):
				const int nOpenStrLen = (pBlockType != NULL) ? pBlockType->m_strOpen.GetLength () : 1;
				pNewMarker->m_dwFlags &= ~g_dwOBFComplete;
				pNewMarker->m_dwFlags |= g_dwOBFLeft;
				pNewMarker->m_bCollapsed = FALSE;
				pNewMarker->m_nEnd = pNewMarker->m_nStart + nOpenStrLen - 1;
			}
			else if ((pMarkerBlock->m_dwFlags & g_dwOBFRight) != 0)
			{
				// add end marker (g_dwOBFRight):
				const int nCloseStrLen = (pBlockType != NULL) ? pBlockType->m_strClose.GetLength () : 1;
				pNewMarker->m_dwFlags &= ~g_dwOBFComplete;
				pNewMarker->m_dwFlags |= g_dwOBFRight;
				pNewMarker->m_bCollapsed = FALSE;
				pNewMarker->m_nStart = pNewMarker->m_nEnd - nCloseStrLen - 1;
				pNewMarker->DestroyData (); // end marker has no data
			}

			// Recursive call:
			AddMarker (pNewMarker, pParent, changes);
		}

		// ------------------
		// Delete old blocks:
		// ------------------
		delete pMarkerBlock;
	}
	else
	{
		// --------------------------------------------
		// Add non-completed block (marker) in the root
		// --------------------------------------------
		CBCGPOutlineNode* pRoot = pParentNode;
		while (pRoot->GetParentNode () != NULL)
		{
			ASSERT_VALID (pRoot);
			pRoot = pRoot->GetParentNode ();
		}
		AddNode (pMarkerBlock, pRoot, changes);
	}

	return TRUE;
}
//************************************************************************************
void CBCGPOutlineParser::UpdateOutlining (CString& strBuffer, int nOffsetFrom, int nCharsCount,
							  CBCGPOutlineNode* pOutlineNode, BCGP_EDIT_OUTLINE_CHANGES& changes)
{
	ASSERT_VALID (this);
	ASSERT (nOffsetFrom >= 0);
	ASSERT (nCharsCount >= 0);
	ASSERT (nOffsetFrom + nCharsCount <= strBuffer.GetLength ());
	ASSERT_VALID (pOutlineNode);

	int nStartOffset = nOffsetFrom;
	int nEndOffset = nOffsetFrom + nCharsCount - 1;
	CBCGPOutlineNode* pChangedNode = GetRangeToReparse (pOutlineNode, nStartOffset, nEndOffset);
	nStartOffset = max (0, nStartOffset);
	nEndOffset = min (strBuffer.GetLength () - 1, nEndOffset);

	if (nStartOffset > nEndOffset)
	{
		return;	// no reparse needed
	}

	changes.m_nStartOffset = min (nStartOffset, changes.m_nStartOffset);
	changes.m_nEndOffset = max (nEndOffset, changes.m_nEndOffset);

	// --------------------------------------------------------------
	// 1) Parse text and find new blocks and part of blocks (markers)
	// --------------------------------------------------------------
	CObList lstBlocks;
	DoParse (strBuffer, nStartOffset, nEndOffset, lstBlocks);

		// ----------------------------------------------------------
		// Reparse text once more
		// if parser found blocks that are greater then parsing range 
		// ----------------------------------------------------------
		int nMin = nStartOffset, nMax = nEndOffset;
		CalcMinMaxBounds (lstBlocks, nMin, nMax);

		if (nMin < nStartOffset || nMax > nEndOffset)
		{
			nStartOffset = min (nMin, nStartOffset);
			nEndOffset = max (nMax, nEndOffset);

			pChangedNode = GetRangeToReparse (pOutlineNode, nStartOffset, nEndOffset);
			nStartOffset = max (0, nStartOffset);
			nEndOffset = min (strBuffer.GetLength () - 1, nEndOffset);

			changes.m_nStartOffset = min (nStartOffset, changes.m_nStartOffset);
			changes.m_nEndOffset = max (nEndOffset, changes.m_nEndOffset);

			while (!lstBlocks.IsEmpty ())
			{
				delete lstBlocks.RemoveTail ();
			}
			DoParse (strBuffer, nStartOffset, nEndOffset, lstBlocks);
		}

	// Update name offsets, start offsets and end offsets:
	DoUpdateOffsets (strBuffer, nStartOffset, nEndOffset, lstBlocks);

	// ------------------------
	// Reconstruct outline tree
	// ------------------------

	// 2) Del old blocks
	pOutlineNode->DeleteBlocksInRange (nStartOffset, nEndOffset, changes); // do not remove user blocks

	for (POSITION pos = lstBlocks.GetHeadPosition (); pos != NULL; )
	{
		POSITION posSave = pos;
		CBCGPOutlineNode* pNode = (CBCGPOutlineNode*) lstBlocks.GetNext (pos);
		ASSERT_VALID (pNode);

		BlockType* pBlockType = m_arrBlockTypes [pNode->m_nBlockType];
		if (pBlockType != NULL && !pBlockType->m_bIgnore)
		{
			if ((pNode->m_dwFlags & g_dwOBFComplete) != 0)
			{
				// 3) Add new blocks
				AddNode (pNode, pOutlineNode, changes);
			}
			else if ((pNode->m_dwFlags & g_dwOBFLeft) != 0 ||
					 (pNode->m_dwFlags & g_dwOBFRight) != 0)
			{
				// it's possible that pChangedNode was removed from outline tree
				POSITION posChangedNode = changes.m_lstRemoved.Find (pChangedNode);
				if (posChangedNode != NULL)
				{
					if ((pNode->m_dwFlags & g_dwOBFLeft) != 0)
					{
						pChangedNode = pOutlineNode->GetInnermostBlock (pNode->m_nStart);
					}
					else if ((pNode->m_dwFlags & g_dwOBFRight) != 0)
					{
						pChangedNode = pOutlineNode->GetInnermostBlock (pNode->m_nEnd);
					}
					if (pChangedNode == NULL)
					{
						pChangedNode = pOutlineNode;
					}
				}

				ASSERT_VALID (pChangedNode);

				// 4) Reconstruct outline tree (add new markers)
				if (!AddMarker (pNode, pChangedNode, changes))
				{
					lstBlocks.RemoveAt (posSave);
					delete pNode;	// to prevent memory leak
				}
			}
		}
		else
		{
			// delete temporary blocks:
			lstBlocks.RemoveAt (posSave);
			delete pNode;
		}
	}
}
Exemplo n.º 5
0
void Plotter::Special(View&, InputSpecial inType, float x, float y, float p1, float p2, float /*p3*/, float /*p4*/, int button_state)
{
    if(inType == InputSpecialScroll) {
        const float d[2] = {p1,-p2};
        const float is[2] = {rview.x.Size(),rview.y.Size() };
        const float df[2] = {is[0]*d[0]/(float)v.w, is[1]*d[1]/(float)v.h};

        ScrollView(-df[0], -df[1]);
    } else if(inType == InputSpecialZoom) {
        float scalex = 1.0;
        float scaley = 1.0;

#ifdef _OSX_
        if (button_state & KeyModifierCmd) {
#else
        if (button_state & KeyModifierCtrl) {
#endif
            scalex = 1-p1;
        }else{
            scaley = 1-p1;
        }

        const float c[2] = {
            track || trigger_edge ? last_track_val[0] : hover[0],
            hover[1]
        };

        ScaleView(scalex, scaley, c[0], c[1]);
    }

    // Update hover status (after potential resizing)
    ScreenToPlot( (int)x, (int)y, hover[0], hover[1]);
}

void Plotter::AddSeries(const std::string& x_expr, const std::string& y_expr,
    DrawingMode drawing_mode, Colour colour,
    const std::string& title, DataLog *log)
{
    if( !std::isfinite(colour.r) ) {
        colour = colour_wheel.GetUniqueColour();
    }
    plotseries.push_back( PlotSeries() );
    plotseries.back().CreatePlot(x_expr, y_expr, colour, (title == "$y") ? y_expr : title);
    plotseries.back().log = log;
    plotseries.back().drawing_mode = (GLenum)drawing_mode;
}

void Plotter::ClearSeries()
{
    plotseries.clear();
}

Marker& Plotter::AddMarker(Marker::Direction d, float value, Marker::Equality leg, Colour c )
{
    return AddMarker(Marker(d,value,leg,c));
}

Marker& Plotter::AddMarker( const Marker& marker )
{
    plotmarkers.push_back( marker );
    return plotmarkers.back();
}