예제 #1
0
void DebugLines::AddQuad ( const glm::vec3 &pVecA, const glm::vec3 &pVecB, const glm::vec3 &pVecC, const glm::vec3 &pVecD, const glm::vec3 &pColor )
{
    AddLines ( pVecA, pVecB, pColor );
    AddLines ( pVecB, pVecC, pColor );
    AddLines ( pVecC, pVecD, pColor );
    AddLines ( pVecD, pVecA, pColor );
}
예제 #2
0
void CMapGridPainter::AddRegion (const CVector &vCenter, Metric rWidth, Metric rHeight)

//	AddRegion
//
//	Adds a rectangular region to paint. We combine this appropriately with any
//	previously added regions.

	{
	int x, y;

	Metric rHalfWidth = 0.5 * rWidth;
	Metric rHalfHeight = 0.5 * rHeight;

	int xFrom = (int)floor((vCenter.GetX() - rHalfWidth) / GRID_SIZE);
	int xTo = (int)floor((vCenter.GetX() + rHalfWidth) / GRID_SIZE);
	int yFrom = (int)floor((vCenter.GetY() - rHalfHeight) / GRID_SIZE);
	int yTo = (int)floor((vCenter.GetY() + rHalfHeight) / GRID_SIZE);

	//	Null case

	if (xFrom == xTo || yFrom == yTo)
		return;

	//	Start with vertical lines

	TArray<SLine> NewLines;
	for (x = xFrom; x <= xTo; x++)
		{
		SLine *pNewLine = NewLines.Insert();
		pNewLine->xyKey = x;
		pNewLine->xyFrom = yFrom;
		pNewLine->xyTo = yTo;
		}

	AddLines(NewLines, &m_VertLines);

	//	Add horizontal lines

	NewLines.DeleteAll();
	for (y = yFrom; y <= yTo; y++)
		{
		SLine *pNewLine = NewLines.Insert();
		pNewLine->xyKey = y;
		pNewLine->xyFrom = xFrom;
		pNewLine->xyTo = xTo;
		}

	AddLines(NewLines, &m_HorzLines);

	m_bRecalcNeeded = true;
	}
예제 #3
0
   void OSGDebugDrawInterface::AddAxes(const dtEntity::Matrix& m, const dtEntity::Vec4f& color, 
      float size, float duration, bool depthTestEnabled)
   {
      float arroww = 0.1f;
      osg::Vec3 p0(0, 0, 0);
      osg::Vec3 p1(0, 0, 1);
      osg::Vec3 p2(0, 1, 0);
      osg::Vec3 p3(1, 0, 0);

      osg::Vec3 p1a(arroww, 0, 1 - arroww);
      osg::Vec3 p1b(-arroww, 0, 1 - arroww);

      osg::Vec3 p2a(arroww, 1 - arroww, 0);
      osg::Vec3 p2b(-arroww, 1 - arroww, 0);

      osg::Vec3 p3a(1 - arroww, 0, arroww);
      osg::Vec3 p3b(1 - arroww, 0, -arroww);

      std::vector<osg::Vec3> lines(18);
      lines[0] = m * p0; lines[1] = m * p1;
      lines[2] = m * p0; lines[3] = m * p2;
      lines[4] = m * p0; lines[5] = m * p3;

      lines[6] = m * p1; lines[7] = m * p1a;
      lines[8] = m * p1; lines[9] = m * p1b;

      lines[10] = m * p2; lines[11] = m * p2a;
      lines[12] = m * p2; lines[13] = m * p2b;

      lines[14] = m * p3; lines[15] = m * p3a;
      lines[16] = m * p3; lines[17] = m * p3b;

      AddLines(lines, color, size, duration, depthTestEnabled);
   }
예제 #4
0
   void OSGDebugDrawInterface::AddAABB(const dtEntity::Vec3f& minCoords, 
      const dtEntity::Vec3f& maxCoords, const dtEntity::Vec4f& color,
      int lineWidth, float duration, bool depthTestEnabled)
   {
      if(!mEnabled)
         return;
      osg::Vec3 p000(minCoords);
      osg::Vec3 p111(maxCoords);
      osg::Vec3 p001(minCoords[0], minCoords[1], maxCoords[2]);
      osg::Vec3 p010(minCoords[0], maxCoords[1], minCoords[2]);
      osg::Vec3 p100(maxCoords[0], minCoords[1], minCoords[2]);
      osg::Vec3 p011(minCoords[0], maxCoords[1], maxCoords[2]);
      osg::Vec3 p101(maxCoords[0], minCoords[1], maxCoords[2]);
      osg::Vec3 p110(maxCoords[0], maxCoords[1], minCoords[2]);
      
      std::vector<osg::Vec3> lines(24);
      lines[0] = p000; lines[1] = p100;
      lines[2] = p100; lines[3] = p101;
      lines[4] = p101; lines[5] = p001;
      lines[6] = p001; lines[7] = p000;

      lines[8] = p001; lines[9] = p011;
      lines[10] = p101; lines[11] = p111;
      lines[12] = p100; lines[13] = p110;
      lines[14] = p000; lines[15] = p010;

      lines[16] = p011; lines[17] = p111;
      lines[18] = p010; lines[19] = p011;
      lines[20] = p111; lines[21] = p110;
      lines[22] = p010; lines[23] = p110;

      
      AddLines(lines, color, lineWidth, duration, depthTestEnabled);
   }      
예제 #5
0
   void OSGDebugDrawInterface::AddCircle(const dtEntity::Vec3f& position, 
      const dtEntity::Vec3f& planeNormal, float radius, const dtEntity::Vec4f& color,
      float duration, bool depthTestEnabled)
   {
      if(!mEnabled)
         return;
       
       int smallestAxis = 0;
       if(abs(planeNormal[1]) < abs(planeNormal[smallestAxis])) smallestAxis = 1;
       if(abs(planeNormal[2]) < abs(planeNormal[smallestAxis])) smallestAxis = 2;
       osg::Vec3 base1(0,0,0);
       base1[smallestAxis] = 1;
       osg::Vec3 ortho1 = planeNormal ^ base1; ortho1.normalize();
       osg::Vec3 ortho2 = planeNormal ^ ortho1;ortho2.normalize();
       
       std::vector<osg::Vec3> lines;
       lines.push_back(osg::Vec3());
       unsigned int numPoints = 16;
       
       for(unsigned int i = 0; i < numPoints; ++i)
       {
          float angle = (static_cast<float>(i) / static_cast<float>(numPoints)) * osg::PI * 2;
          osg::Vec3 p = position + ortho1 * sin(angle) * -1 * radius + ortho2 * cos(angle) * radius;
          lines.push_back(p);
          if(numPoints != i + 1)
          {
            lines.push_back(p);
          }
       }
       lines[0] = lines.back();

       AddLines(lines, color, 1, duration, depthTestEnabled);
   }
예제 #6
0
static void DoSubsector(subsector_t * sub)
{
	int i;
	sector_t * sector;
	sector_t * fakesector;
	sector_t fake;
	GLFlat glflat;
	GLSprite glsprite;
	
	// check for visibility of this entire subsector! This requires GL nodes!
	if (!clipper.CheckBox(sub->bbox)) return;

#ifdef _MSC_VER
#ifdef _DEBUG
	if (sub->sector-sectors==931)
	{
		__asm nop
	}
#endif
#endif

	sector=sub->sector;
	if (!sector) return;

	sector->MoreFlags |= SECF_DRAWN;
	fakesector=gl_FakeFlat(sector, &fake, false);

	// [RH] Add particles
	//int shade = LIGHT2SHADE((floorlightlevel + ceilinglightlevel)/2 + r_actualextralight);
	for (i = ParticlesInSubsec[sub-subsectors]; i != NO_PARTICLE; i = Particles[i].snext)
	{
		glsprite.ProcessParticle(Particles + i, fakesector);//, 0, 0);
	}
	AddLines(sub, fakesector);
	RenderThings(sub, fakesector);

	// Subsectors with only 2 lines cannot have any area!
	if (sub->numlines>2 || (sub->hacked&1)) 
	{
		// Exclude the case when it tries to render a sector with a heightsec
		// but undetermined heightsec state. This can only happen if the
		// subsector is obstructed but not excluded due to a large bounding box.
		// Due to the way a BSP works such a subsector can never be visible
		if (!sector->heightsec || sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC || in_area!=area_default)
		{
			if (sector != sub->render_sector)
			{
				sector = sub->render_sector;
				// the planes of this subsector are faked to belong to another sector
				// This means we need the heightsec parts and light info of the render sector, not the actual one!
				fakesector = gl_FakeFlat(sector, &fake, false);
			}
			SetupFlat.Clock();
			glflat.ProcessSector(fakesector, sub);
			SetupFlat.Unclock();
		}
	}
}
예제 #7
0
void CFDE_Path::AddPolygon(const CFX_PointsF& points) {
  int32_t iCount = points.GetSize();
  if (iCount < 2)
    return;

  AddLines(points);
  const CFX_PointF* p = points.GetData();
  if (FXSYS_fabs(p[0].x - p[iCount - 1].x) < 0.01f ||
      FXSYS_fabs(p[0].y - p[iCount - 1].y) < 0.01f) {
    LineTo(p[0]);
  }
  CloseFigure();
}
예제 #8
0
int GUIConsole::Update(void)
{
	if (mSlideout && mSlideoutState != visible)
	{
		if (mSlideoutState == hidden)
			return 0;

		if (mSlideoutState == request_hide)
			mSlideoutState = hidden;

		if (mSlideoutState == request_show)
			mSlideoutState = visible;

		// Any time we activate the console, we reset the position
		SetVisibleListLocation(rConsole.size() - 1);
		mUpdate = 1;
		scrollToEnd = true;
	}

	if (AddLines()) {
		// someone added new text
		// at least the scrollbar must be updated, even if the new lines are currently not visible
		mUpdate = 1;
	}

	if (scrollToEnd) {
		// keep the last line in view
		SetVisibleListLocation(rConsole.size() - 1);
	}

	GUIScrollList::Update();

	if (mUpdate) {
		mUpdate = 0;
		if (Render() == 0)
			return 2;
	}
	return 0;
}
예제 #9
0
int GUIConsole::RenderConsole(void)
{
	AddLines();
	GUIScrollList::Render();

	// if last line is fully visible, keep tracking the last line when new lines are added
	int bottom_offset = GetDisplayRemainder() - actualItemHeight;
	bool isAtBottom = firstDisplayedItem == GetItemCount() - GetDisplayItemCount() - (bottom_offset != 0) && y_offset == bottom_offset;
	if (isAtBottom)
		scrollToEnd = true;
#if 0
	// debug - show if we are tracking the last line
	if (scrollToEnd) {
		gr_color(0,255,0,255);
		gr_fill(mRenderX+mRenderW-5, mRenderY+mRenderH-5, 5, 5);
	} else {
		gr_color(255,0,0,255);
		gr_fill(mRenderX+mRenderW-5, mRenderY+mRenderH-5, 5, 5);
	}
#endif
	return (mSlideout ? RenderSlideout() : 0);
}
예제 #10
0
/// @brief List all files of given extension-list
u32 FindFiles( Container& out, const stringc& rootDir, const Container& fileTypes )
{
	if (rootDir.size()==0)
		return 0;

	if (fileTypes.size()==0)
		return 0;

	const u32 old_size = out.size();

	for (u32 i=0; i<fileTypes.size(); i++)
	{
		core::stringc command;
		command = "find ";
		command += rootDir;
		command += " -iname '*.";
		command += fileTypes[i];
		command += "' | sort";
		AddLines( out, command );
	}
	return out.size() - old_size; // return Number of added lines(stringc) to container 'out'.
}
예제 #11
0
LTBOOL CLineSystemFX::Update()
{
    if (!m_hObject || !m_pClientDE || m_bWantRemove) return LTFALSE;

    LTFLOAT fTime = m_pClientDE->GetTime();

	// Hide/show the line system if necessary...

	if (m_hServerObject)
	{
        uint32 dwUserFlags;
		g_pCommonLT->GetObjectFlags(m_hServerObject, OFT_User, dwUserFlags);

		if (!(dwUserFlags & USRFLG_VISIBLE))
		{
			g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, 0, FLAG_VISIBLE);
			m_fLastTime = fTime;
            return LTTRUE;
		}
		else
		{
			g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE);
		}
	}

	// Debugging aid...

	if (s_cvarTweak.GetFloat() > 0)
	{
		TweakSystem();
	}


	if (m_bFirstUpdate)
	{
		m_fLastTime = fTime;
        m_bFirstUpdate = LTFALSE;
	}
	else
	{
		UpdateSystem();
	}

	// Make sure it is time to update...

	if (fTime < m_fLastTime + m_fNextUpdate)
	{
        return LTTRUE;
	}


	// Ok, how many to add this frame....

	float fTimeDelta = fTime - m_fLastTime;

	// Make sure delta time is no less than 15 frames/sec if we're
	// continuously adding lines...

	if (m_bContinuous)
	{
		fTimeDelta = fTimeDelta > 0.0666f ? 0.0666f : fTimeDelta;
	}

	int nToAdd = (int) floor(m_cs.fLinesPerSecond * fTimeDelta);
    nToAdd = LTMIN(nToAdd, (int)(MAX_LINES_PER_SECOND * fTimeDelta));


	// Add new lines...

	AddLines(nToAdd);


	// Determine when next update should occur...

	if (m_cs.fBurstWait > 0.001f)
	{
		m_fNextUpdate = m_cs.fBurstWait * GetRandom(m_cs.fBurstWaitMin, m_cs.fBurstWaitMax);
	}
	else
	{
		m_fNextUpdate = 0.001f;
	}

	m_fLastTime = fTime;

    return LTTRUE;
}
예제 #12
0
bool
CDiffData::DoThreeWayDiff(const CString& sBaseFilename, const CString& sYourFilename, const CString& sTheirFilename, DWORD dwIgnoreWS, bool bIgnoreEOL, bool bIgnoreCase, apr_pool_t * pool)
{
    // the following three arrays are used to check for conflicts even in case the
    // user has ignored spaces/eols.
    CStdDWORDArray              m_arDiff3LinesBase;
    CStdDWORDArray              m_arDiff3LinesYour;
    CStdDWORDArray              m_arDiff3LinesTheir;
#define AddLines(baseline, yourline, theirline) m_arDiff3LinesBase.Add(baseline), m_arDiff3LinesYour.Add(yourline), m_arDiff3LinesTheir.Add(theirline)
    int lengthHint = GetLineCount();

    m_arDiff3LinesBase.Reserve(lengthHint);
    m_arDiff3LinesYour.Reserve(lengthHint);
    m_arDiff3LinesTheir.Reserve(lengthHint);

    CRegDWORD contextLines = CRegDWORD(_T("Software\\TortoiseMerge\\ContextLines"), 3);
    svn_diff_file_options_t * options = CreateDiffFileOptions(dwIgnoreWS, bIgnoreEOL, pool);

    // convert CString filenames (UTF-16 or ANSI) to UTF-8
    CStringA sBaseFilenameUtf8  = CUnicodeUtils::GetUTF8(sBaseFilename);
    CStringA sYourFilenameUtf8  = CUnicodeUtils::GetUTF8(sYourFilename);
    CStringA sTheirFilenameUtf8 = CUnicodeUtils::GetUTF8(sTheirFilename);

    svn_diff_t * diffTheirYourBase = NULL;
    svn_error_t * svnerr = svn_diff_file_diff3_2(&diffTheirYourBase, sBaseFilenameUtf8, sTheirFilenameUtf8, sYourFilenameUtf8, options, pool);
    if (svnerr)
        return HandleSvnError(svnerr);

    svn_diff_t * tempdiff = diffTheirYourBase;
    LONG baseline = 0;
    LONG yourline = 0;
    LONG theirline = 0;
    LONG resline = 0;
    // common viewdata
    const viewdata emptyConflictEmpty(_T(""), DIFFSTATE_CONFLICTEMPTY, DIFF_EMPTYLINENUMBER, EOL_NOENDING, HIDESTATE_SHOWN);
    const viewdata emptyIdenticalRemoved(_T(""), DIFFSTATE_IDENTICALREMOVED, DIFF_EMPTYLINENUMBER, EOL_NOENDING, HIDESTATE_SHOWN);
    while (tempdiff)
    {
        if (tempdiff->type == svn_diff__type_common)
        {
            ASSERT((tempdiff->latest_length == tempdiff->modified_length) && (tempdiff->modified_length == tempdiff->original_length));
            for (int i=0; i<tempdiff->original_length; i++)
            {
                if ((m_arYourFile.GetCount() > yourline)&&(m_arTheirFile.GetCount() > theirline))
                {
                    AddLines(baseline, yourline, theirline);

                    m_Diff3.AddData(m_arYourFile.GetAt(yourline), DIFFSTATE_NORMAL, resline, m_arYourFile.GetLineEnding(yourline), HIDESTATE_HIDDEN, -1);
                    m_YourBaseBoth.AddData(m_arYourFile.GetAt(yourline), DIFFSTATE_NORMAL, yourline, m_arYourFile.GetLineEnding(yourline), HIDESTATE_HIDDEN, -1);
                    m_TheirBaseBoth.AddData(m_arTheirFile.GetAt(theirline), DIFFSTATE_NORMAL, theirline, m_arTheirFile.GetLineEnding(theirline), HIDESTATE_HIDDEN, -1);

                    baseline++;
                    yourline++;
                    theirline++;
                    resline++;
                }
            }
        }
        else if (tempdiff->type == svn_diff__type_diff_common)
        {
            ASSERT(tempdiff->latest_length == tempdiff->modified_length);
            //both theirs and yours have lines replaced
            for (int i=0; i<tempdiff->original_length; i++)
            {
                if (m_arBaseFile.GetCount() > baseline)
                {
                    AddLines(baseline, yourline, theirline);

                    m_Diff3.AddData(m_arBaseFile.GetAt(baseline), DIFFSTATE_IDENTICALREMOVED, DIFF_EMPTYLINENUMBER, m_arBaseFile.GetLineEnding(baseline), HIDESTATE_SHOWN, -1);
                    m_YourBaseBoth.AddData(m_arBaseFile.GetAt(baseline), DIFFSTATE_IDENTICALREMOVED, DIFF_EMPTYLINENUMBER, EOL_NOENDING, HIDESTATE_SHOWN, -1);
                    m_TheirBaseBoth.AddData(m_arBaseFile.GetAt(baseline), DIFFSTATE_IDENTICALREMOVED, DIFF_EMPTYLINENUMBER, EOL_NOENDING, HIDESTATE_SHOWN, -1);

                    baseline++;
                }
            }
            for (int i=0; i<tempdiff->modified_length; i++)
            {
                if ((m_arYourFile.GetCount() > yourline)&&(m_arTheirFile.GetCount() > theirline))
                {
                    AddLines(baseline, yourline, theirline);

                    m_Diff3.AddData(m_arYourFile.GetAt(yourline), DIFFSTATE_IDENTICALADDED, resline, m_arYourFile.GetLineEnding(yourline), HIDESTATE_SHOWN, -1);
                    m_YourBaseBoth.AddData(m_arYourFile.GetAt(yourline), DIFFSTATE_IDENTICALADDED, yourline, m_arYourFile.GetLineEnding(yourline), HIDESTATE_SHOWN, -1);
                    m_TheirBaseBoth.AddData(m_arTheirFile.GetAt(theirline), DIFFSTATE_IDENTICALADDED, resline, m_arTheirFile.GetLineEnding(theirline), HIDESTATE_SHOWN, -1);

                    yourline++;
                    theirline++;
                    resline++;
                }
            }
        }
        else if (tempdiff->type == svn_diff__type_conflict)
        {
            apr_off_t length = max(tempdiff->original_length, tempdiff->modified_length);
            length = max(tempdiff->latest_length, length);
            apr_off_t original = tempdiff->original_length;
            apr_off_t modified = tempdiff->modified_length;
            apr_off_t latest = tempdiff->latest_length;

            apr_off_t originalresolved = 0;
            apr_off_t modifiedresolved = 0;
            apr_off_t latestresolved = 0;

            LONG base = baseline;
            LONG your = yourline;
            LONG their = theirline;
            if (tempdiff->resolved_diff)
            {
                originalresolved = tempdiff->resolved_diff->original_length;
                modifiedresolved = tempdiff->resolved_diff->modified_length;
                latestresolved = tempdiff->resolved_diff->latest_length;
            }
            for (int i=0; i<length; i++)
            {
                EOL endingBase = m_arBaseFile.GetCount() > baseline ? m_arBaseFile.GetLineEnding(baseline) : EOL_AUTOLINE;
                if (original)
                {
                    if (m_arBaseFile.GetCount() > baseline)
                    {
                        AddLines(baseline, yourline, theirline);

                        m_Diff3.AddData(m_arBaseFile.GetAt(baseline), DIFFSTATE_IDENTICALREMOVED, DIFF_EMPTYLINENUMBER, endingBase , HIDESTATE_SHOWN, -1);
                        m_YourBaseBoth.AddData(m_arBaseFile.GetAt(baseline), DIFFSTATE_IDENTICALREMOVED, DIFF_EMPTYLINENUMBER, endingBase , HIDESTATE_SHOWN, -1);
                        m_TheirBaseBoth.AddData(m_arBaseFile.GetAt(baseline), DIFFSTATE_IDENTICALREMOVED, DIFF_EMPTYLINENUMBER, endingBase , HIDESTATE_SHOWN, -1);
                    }
                }
                else if ((originalresolved)||((modifiedresolved)&&(latestresolved)))
                {
                    AddLines(baseline, yourline, theirline);

                    m_Diff3.AddData(emptyIdenticalRemoved);
                    if ((latestresolved)&&(modifiedresolved))
                    {
                        m_YourBaseBoth.AddData(emptyIdenticalRemoved);
                        m_TheirBaseBoth.AddData(emptyIdenticalRemoved);
                    }
                }
                if (original)
                {
                    original--;
                    baseline++;
                }
                if (originalresolved)
                    originalresolved--;

                if (modified)
                {
                    modified--;
                    theirline++;
                }
                if (modifiedresolved)
                    modifiedresolved--;
                if (latest)
                {
                    latest--;
                    yourline++;
                }
                if (latestresolved)
                    latestresolved--;
            }
            original = tempdiff->original_length;
            modified = tempdiff->modified_length;
            latest = tempdiff->latest_length;
            baseline = base;
            yourline = your;
            theirline = their;
            if (tempdiff->resolved_diff)
            {
                originalresolved = tempdiff->resolved_diff->original_length;
                modifiedresolved = tempdiff->resolved_diff->modified_length;
                latestresolved = tempdiff->resolved_diff->latest_length;
            }
            for (int i=0; i<length; i++)
            {
                if ((latest)||(modified))
                {
                    AddLines(baseline, yourline, theirline);

                    m_Diff3.AddData(_T(""), DIFFSTATE_CONFLICTED, resline, EOL_NOENDING, HIDESTATE_SHOWN, -1);

                    resline++;
                }

                if (latest)
                {
                    if (m_arYourFile.GetCount() > yourline)
                    {
                        m_YourBaseBoth.AddData(m_arYourFile.GetAt(yourline), DIFFSTATE_CONFLICTADDED, yourline, m_arYourFile.GetLineEnding(yourline), HIDESTATE_SHOWN, -1);
                    }
                }
                else if ((latestresolved)||(modified)||(modifiedresolved))
                {
                    m_YourBaseBoth.AddData(emptyConflictEmpty);
                }
                if (modified)
                {
                    if (m_arTheirFile.GetCount() > theirline)
                    {
                        m_TheirBaseBoth.AddData(m_arTheirFile.GetAt(theirline), DIFFSTATE_CONFLICTADDED, theirline, m_arTheirFile.GetLineEnding(theirline), HIDESTATE_SHOWN, -1);
                    }
                }
                else if ((modifiedresolved)||(latest)||(latestresolved))
                {
                    m_TheirBaseBoth.AddData(emptyConflictEmpty);
                }
                if (original)
                {
                    original--;
                    baseline++;
                }
                if (originalresolved)
                    originalresolved--;
                if (modified)
                {
                    modified--;
                    theirline++;
                }
                if (modifiedresolved)
                    modifiedresolved--;
                if (latest)
                {
                    latest--;
                    yourline++;
                }
                if (latestresolved)
                    latestresolved--;
            }
        }
        else if (tempdiff->type == svn_diff__type_diff_modified)
        {
            //deleted!
            for (int i=0; i<tempdiff->original_length; i++)
            {
                if ((m_arBaseFile.GetCount() > baseline)&&(m_arYourFile.GetCount() > yourline))
                {
                    AddLines(baseline, yourline, theirline);

                    m_Diff3.AddData(m_arBaseFile.GetAt(baseline), DIFFSTATE_THEIRSREMOVED, DIFF_EMPTYLINENUMBER, m_arBaseFile.GetLineEnding(baseline), HIDESTATE_SHOWN, -1);
                    m_YourBaseBoth.AddData(m_arYourFile.GetAt(yourline), DIFFSTATE_NORMAL, yourline, m_arYourFile.GetLineEnding(yourline), HIDESTATE_SHOWN, -1);
                    m_TheirBaseBoth.AddData(m_arBaseFile.GetAt(baseline), DIFFSTATE_THEIRSREMOVED, DIFF_EMPTYLINENUMBER, EOL_NOENDING, HIDESTATE_SHOWN, -1);

                    baseline++;
                    yourline++;
                }
            }
            //added
            for (int i=0; i<tempdiff->modified_length; i++)
            {
                if (m_arTheirFile.GetCount() > theirline)
                {
                    AddLines(baseline, yourline, theirline);

                    m_Diff3.AddData(m_arTheirFile.GetAt(theirline), DIFFSTATE_THEIRSADDED, resline, m_arTheirFile.GetLineEnding(theirline), HIDESTATE_SHOWN, -1);
                    m_YourBaseBoth.AddEmpty();
                    m_TheirBaseBoth.AddData(m_arTheirFile.GetAt(theirline), DIFFSTATE_THEIRSADDED, theirline, m_arTheirFile.GetLineEnding(theirline), HIDESTATE_SHOWN, -1);

                    theirline++;
                    resline++;
                }
            }
        }
        else if (tempdiff->type == svn_diff__type_diff_latest)
        {
            //YOURS differs from base

            for (int i=0; i<tempdiff->original_length; i++)
            {
                if ((m_arBaseFile.GetCount() > baseline)&&(m_arTheirFile.GetCount() > theirline))
                {
                    AddLines(baseline, yourline, theirline);

                    m_Diff3.AddData(m_arBaseFile.GetAt(baseline), DIFFSTATE_YOURSREMOVED, DIFF_EMPTYLINENUMBER, m_arBaseFile.GetLineEnding(baseline), HIDESTATE_SHOWN, -1);
                    m_YourBaseBoth.AddData(m_arBaseFile.GetAt(baseline), DIFFSTATE_YOURSREMOVED, DIFF_EMPTYLINENUMBER, m_arBaseFile.GetLineEnding(baseline), HIDESTATE_SHOWN, -1);
                    m_TheirBaseBoth.AddData(m_arTheirFile.GetAt(theirline), DIFFSTATE_NORMAL, theirline, m_arTheirFile.GetLineEnding(theirline), HIDESTATE_HIDDEN, -1);

                    baseline++;
                    theirline++;
                }
            }
            for (int i=0; i<tempdiff->latest_length; i++)
            {
                if (m_arYourFile.GetCount() > yourline)
                {
                    AddLines(baseline, yourline, theirline);

                    m_Diff3.AddData(m_arYourFile.GetAt(yourline), DIFFSTATE_YOURSADDED, resline, m_arYourFile.GetLineEnding(yourline), HIDESTATE_SHOWN, -1);
                    m_YourBaseBoth.AddData(m_arYourFile.GetAt(yourline), DIFFSTATE_IDENTICALADDED, yourline, m_arYourFile.GetLineEnding(yourline), HIDESTATE_SHOWN, -1);
                    m_TheirBaseBoth.AddEmpty();

                    yourline++;
                    resline++;
                }
            }
        }
        else
        {
            TRACE(_T("something bad happened during diff!\n"));
        }
        tempdiff = tempdiff->next;

    } // while (tempdiff)

    if ((options->ignore_space != svn_diff_file_ignore_space_none)||(bIgnoreCase)||(bIgnoreEOL))
    {
        // If whitespaces are ignored, a conflict could have been missed
        // We now go through all lines again and check if they're identical.
        // If they're not, then that means it is a conflict, and we
        // mark the conflict with the proper colors.
        for (long i=0; i<m_Diff3.GetCount(); ++i)
        {
            DiffStates state1 = m_YourBaseBoth.GetState(i);
            DiffStates state2 = m_TheirBaseBoth.GetState(i);

            if (((state1 == DIFFSTATE_IDENTICALADDED)||(state1 == DIFFSTATE_NORMAL))&&
                ((state2 == DIFFSTATE_IDENTICALADDED)||(state2 == DIFFSTATE_NORMAL)))
            {
                LONG lineyour = m_arDiff3LinesYour.GetAt(i);
                LONG linetheir = m_arDiff3LinesTheir.GetAt(i);
                LONG linebase = m_arDiff3LinesBase.GetAt(i);
                if ((lineyour < m_arYourFile.GetCount()) &&
                    (linetheir < m_arTheirFile.GetCount()) &&
                    (linebase < m_arBaseFile.GetCount()))
                {
                    if (((m_arYourFile.GetLineEnding(lineyour)!=m_arBaseFile.GetLineEnding(linebase))&&
                        (m_arTheirFile.GetLineEnding(linetheir)!=m_arBaseFile.GetLineEnding(linebase))&&
                        (m_arYourFile.GetLineEnding(lineyour)!=m_arTheirFile.GetLineEnding(linetheir))) ||
                        ((m_arYourFile.GetAt(lineyour).Compare(m_arBaseFile.GetAt(linebase))!=0)&&
                        (m_arTheirFile.GetAt(linetheir).Compare(m_arBaseFile.GetAt(linebase))!=0)&&
                        (m_arYourFile.GetAt(lineyour).Compare(m_arTheirFile.GetAt(linetheir))!=0)))
                    {
                        m_Diff3.SetState(i, DIFFSTATE_CONFLICTED_IGNORED);
                        m_YourBaseBoth.SetState(i, DIFFSTATE_CONFLICTADDED);
                        m_TheirBaseBoth.SetState(i, DIFFSTATE_CONFLICTADDED);
                    }
                }
            }
        }
    }
    ASSERT(m_Diff3.GetCount() == m_YourBaseBoth.GetCount());
    ASSERT(m_TheirBaseBoth.GetCount() == m_YourBaseBoth.GetCount());

    TRACE(_T("done with 3-way diff\n"));

    HideUnchangedSections(&m_Diff3, &m_YourBaseBoth, &m_TheirBaseBoth);

    return true;
}
예제 #13
0
void DebugLines::AddTriangle ( const glm::vec3 &pVecA, const glm::vec3 &pVecB, const glm::vec3 &pVecC, const glm::vec3 &pColor )
{
    AddLines ( pVecA, pVecB, pColor );
    AddLines ( pVecB, pVecC, pColor );
    AddLines ( pVecC, pVecA, pColor );
}
예제 #14
0
// Performs line segmentation
bool CubeLineSegmenter::LineSegment() {
  // Use full image morphology to find columns
  // This only works for simple layouts where each column
  // of text extends the full height of the input image.
  Pix *pix_temp1 = pixMorphCompSequence(img_, "c5.500", 0);
  if (pix_temp1 == NULL) {
    return false;
  }

  // Mask with a single component over each column
  Pixa *pixam;
  Boxa *boxa = pixConnComp(pix_temp1, &pixam, 8);

  if (boxa == NULL) {
    return false;
  }

  int init_morph_min_hgt = kLineSepMorphMinHgt;
  char sequence_str[16];
  sprintf(sequence_str, "c100.%d", init_morph_min_hgt);

  // Use selective region-based morphology to get the textline mask.
  Pixa *pixad = pixaMorphSequenceByRegion(img_, pixam, sequence_str, 0, 0);
  if (pixad == NULL) {
    return false;
  }

  // for all columns
  int col_cnt = boxaGetCount(boxa);

  // create columns
  columns_ = pixaaCreate(col_cnt);
  if (columns_ == NULL) {
    return false;
  }

  // index columns based on readind order (RTL)
  int *col_order = IndexRTL(pixad);
  if (col_order == NULL) {
    return false;
  }

  line_cnt_ = 0;

  for (int col_idx = 0; col_idx < col_cnt; col_idx++) {
    int col = col_order[col_idx];

    // get the pix and box corresponding to the column
    Pix *pixt3 = pixaGetPix(pixad, col, L_CLONE);
    if (pixt3 == NULL) {
      return false;
    }

    Box *col_box = pixad->boxa->box[col];

    Pixa *pixac;
    Boxa *boxa2 = pixConnComp(pixt3, &pixac, 8);
    if (boxa2 == NULL) {
      return false;
    }

    // offset the boxes by the column box
    for (int line = 0; line < pixac->n; line++) {
      pixac->boxa->box[line]->x += col_box->x;
      pixac->boxa->box[line]->y += col_box->y;
    }

    // add the lines
    if (AddLines(pixac) == true) {
      if (pixaaAddBox(columns_, col_box, L_CLONE) != 0) {
        return false;
      }
    }

    pixDestroy(&pixt3);
    boxaDestroy(&boxa2);

    line_cnt_ += columns_->pixa[col_idx]->n;
  }

  pixaDestroy(&pixam);
  pixaDestroy(&pixad);
  boxaDestroy(&boxa);

  delete []col_order;
  pixDestroy(&pix_temp1);

  return true;
}