void DiffSideBySidePanel::PrepareViews() { // Prepare the views by selecting the proper syntax highlight wxFileName fnLeft(m_filePickerLeft->GetPath()); wxFileName fnRight(m_filePickerRight->GetPath()); bool useRightSideLexer = false; if(fnLeft.GetExt() == "svn-base") { // doing svn diff, use the lexer for the right side file useRightSideLexer = true; } LexerConf::Ptr_t leftLexer = EditorConfigST::Get()->GetLexerForFile(useRightSideLexer ? fnRight.GetFullName() : fnLeft.GetFullName()); wxASSERT(leftLexer); LexerConf::Ptr_t rightLexer = EditorConfigST::Get()->GetLexerForFile(fnRight.GetFullName()); wxASSERT(rightLexer); leftLexer->Apply(m_stcLeft, true); rightLexer->Apply(m_stcRight, true); // Create the markers we need DefineMarkers(m_stcLeft); DefineMarkers(m_stcRight); // Turn off PP highlighting m_stcLeft->SetProperty("lexer.cpp.track.preprocessor", "0"); m_stcLeft->SetProperty("lexer.cpp.update.preprocessor", "0"); m_stcRight->SetProperty("lexer.cpp.track.preprocessor", "0"); m_stcRight->SetProperty("lexer.cpp.update.preprocessor", "0"); }
void DirichletPoisson<T>::generate(IMathMatrix<T>& A, MathVector<T>& b) const { int xdir, ydir; T h = length / numDivs; for (int x = 1; x < numDivs; ++x) { for (int y = 1; y < numDivs; ++y) { int pointOffset = getPointOffset(x, y); A(pointOffset, pointOffset) = 1; // Check the left direction point xdir = x - 1; ydir = y; if (xdir == 0) { // Update the b for the current point b[pointOffset] += 0.25*(fnLeft(yLow + ydir*h)); } else { // Update A at [currentpoint][directionPoint] = -1/4 A(pointOffset, getPointOffset(xdir, ydir)) = -0.25; } // Check the right direction point xdir = x + 1; if (xdir == numDivs) { // Update the b for the current point b[pointOffset] += 0.25*(fnRight(yLow + ydir*h)); } else { A(pointOffset, getPointOffset(xdir, ydir)) = -0.25; } // Check the up direction point xdir = x; ydir = y + 1; if (ydir == numDivs) { b[pointOffset] += 0.25*(fnHigh(xLow + xdir*h)); } else { A(pointOffset, getPointOffset(xdir, ydir)) = -0.25; } // Check the down direction point ydir = y - 1; if (ydir == 0) { b[pointOffset] += 0.25*(fnLow(xLow + xdir*h)); } else { A(pointOffset, getPointOffset(xdir, ydir)) = -0.25; } // Subtract the forcing function from b b[pointOffset] -= ((h*h)*(fnForce(xLow + x*h, yLow + y*h)))/4.0; } } }
void DiffSideBySidePanel::Diff() { wxFileName fnLeft(m_filePickerLeft->GetPath()); wxFileName fnRIght(m_filePickerRight->GetPath()); if(!fnLeft.Exists()) { ::wxMessageBox(wxString() << _("Left Side File:\n") << fnLeft.GetFullPath() << _(" does not exist!"), "CodeLite", wxICON_ERROR | wxCENTER | wxOK); return; } if(!fnRIght.Exists()) { ::wxMessageBox(wxString() << _("Right Side File:\n") << fnRIght.GetFullPath() << _(" does not exist!"), "CodeLite", wxICON_ERROR | wxCENTER | wxOK); return; } // Cleanup DoClean(); // Prepare the views PrepareViews(); // Prepare the diff clDTL d; d.Diff(m_filePickerLeft->GetPath(), m_filePickerRight->GetPath(), m_config.IsSingleViewMode() ? clDTL::kOnePane : clDTL::kTwoPanes); const clDTL::LineInfoVec_t& resultLeft = d.GetResultLeft(); const clDTL::LineInfoVec_t& resultRight = d.GetResultRight(); m_sequences = d.GetSequences(); if(m_sequences.empty()) { // Files are the same ! m_stcLeft->SetReadOnly(false); m_stcRight->SetReadOnly(false); m_stcLeft->LoadFile(fnLeft.GetFullPath()); m_stcRight->LoadFile(fnRIght.GetFullPath()); m_stcLeft->SetSavePoint(); m_stcRight->SetSavePoint(); m_stcLeft->SetReadOnly(true); m_stcRight->SetReadOnly(true); return; } m_cur_sequence = 0; // the first line of the sequence // Create 2 strings "left" and "right" wxString leftContent, rightContent; // The left pane is always the one with the deletions "-" for(size_t i = 0; i < resultLeft.size(); ++i) { if(resultLeft.at(i).m_type == clDTL::LINE_ADDED) { leftContent << resultLeft.at(i).m_line; m_leftGreenMarkers.push_back(i); } else if(resultLeft.at(i).m_type == clDTL::LINE_REMOVED) { leftContent << resultLeft.at(i).m_line; m_leftRedMarkers.push_back(i); } else if(resultLeft.at(i).m_type == clDTL::LINE_PLACEHOLDER) { // PLACEHOLDER leftContent << resultLeft.at(i).m_line; m_leftPlaceholdersMarkers.push_back(i); } else { // COMMON leftContent << resultLeft.at(i).m_line; } } // The right pane is always with the new additions "+" for(size_t i = 0; i < resultRight.size(); ++i) { if(resultRight.at(i).m_type == clDTL::LINE_REMOVED) { rightContent << resultRight.at(i).m_line; m_rightRedMarkers.push_back(i); } else if(resultRight.at(i).m_type == clDTL::LINE_ADDED) { rightContent << resultRight.at(i).m_line; m_rightGreenMarkers.push_back(i); } else if(resultRight.at(i).m_type == clDTL::LINE_PLACEHOLDER) { rightContent << resultRight.at(i).m_line; m_rightPlaceholdersMarkers.push_back(i); } else { // COMMON rightContent << resultRight.at(i).m_line; } } UpdateViews(leftContent, rightContent); m_stcLeft->SetSavePoint(); m_stcRight->SetSavePoint(); // Select the first diff wxRibbonButtonBarEvent dummy; m_cur_sequence = -1; OnNextDiffSequence(dummy); }