/** * Contructor for the Point Error filter. It * creates the Error filter window found in the * navtool * * @param parent The parent widget for the point * error filter * * @internal * @history 2008-08-06 Tracie Sucharski - Added functionality of filtering * range of errors. */ QnetPointErrorFilter::QnetPointErrorFilter (QWidget *parent) : QnetFilter(parent) { // Create the components for the filter window QLabel *label = new QLabel("Filter bundle-adjustment error"); p_lessThanCB = new QCheckBox("Less than (undercontrolled)"); p_lessErrorEdit = new QLineEdit(); p_greaterThanCB = new QCheckBox("Greater than (overcontrolled)"); p_greaterErrorEdit = new QLineEdit(); QLabel *pixels = new QLabel ("pixels"); QLabel *pad = new QLabel(); p_greaterThanCB->setChecked(true); connect(p_lessThanCB,SIGNAL(clicked()),this,SLOT(clearEdit())); connect(p_greaterThanCB,SIGNAL(clicked()),this,SLOT(clearEdit())); // Create the layout and add the components to it QGridLayout *gridLayout = new QGridLayout(); gridLayout->addWidget(label,0,0,1,2); gridLayout->addWidget(p_lessThanCB,1,0,1,2); gridLayout->addWidget(p_lessErrorEdit,2,0); gridLayout->addWidget(pixels,2,1); gridLayout->addWidget(p_greaterThanCB,3,0,1,2); gridLayout->addWidget(p_greaterErrorEdit,4,0); gridLayout->addWidget(pixels,4,1); gridLayout->addWidget(pad,5,0); gridLayout->setRowStretch(5,50); this->setLayout(gridLayout); }
/** * Contructor for the Point Goodness of Fit filter. It creates * the Goodness of Fit filter window found in the navtool * * @param parent The parent widget for the point type * filter * @internal * @history 2010-06-02 Jeannie Walldren - Modify default * settings of checkboxes and line edits * @history 2010-06-03 Jeannie Walldren - Initialized pointers * to null in constructor. * */ QnetPointGoodnessFilter::QnetPointGoodnessFilter (QnetNavTool *navTool, QWidget *parent) : QnetFilter(navTool, parent) { m_lessThanCB = NULL; m_greaterThanCB = NULL; m_maxValueEdit = NULL; m_minValueEdit = NULL; // Create the components for the filter window m_lessThanCB = new QCheckBox("Less than "); m_maxValueEdit = new QLineEdit(); m_greaterThanCB = new QCheckBox("Greater than "); m_minValueEdit = new QLineEdit(); QLabel *pad = new QLabel; m_lessThanCB->setChecked(false); m_maxValueEdit->setEnabled(false); m_greaterThanCB->setChecked(false); m_minValueEdit->setEnabled(false); connect(m_lessThanCB,SIGNAL(clicked()),this,SLOT(clearEdit())); connect(m_greaterThanCB,SIGNAL(clicked()),this,SLOT(clearEdit())); // Create the layout and add the components to it QGridLayout *gridLayout = new QGridLayout(); //gridLayout->addWidget(label,0,0,1,2); gridLayout->addWidget(m_lessThanCB,1,0,1,2); gridLayout->addWidget(m_maxValueEdit,2,0); gridLayout->addWidget(m_greaterThanCB,3,0,1,2); gridLayout->addWidget(m_minValueEdit,4,0); gridLayout->addWidget(pad,5,0); gridLayout->setRowStretch(5,50); this->setLayout(gridLayout); }
ScoreInfoDialog::ScoreInfoDialog(NMainFrameWidget *parent) : KDialogBase (Tabbed, // dialogFace kapp->makeStdCaption(i18n("Score information")), Help | User1 | User2 | Ok | Apply | Cancel, Ok, // defaultButton parent, // parent "ScoreInfoDialog", // name (for internal use only) true, // modal true, // separator i18n("&Revert"), // User1 i18n("Cl&ear all") // User1 ), mainWidget(parent) { kapp->config()->setGroup("ScoreInfo"); // GENERAL QFrame *pageGeneral = addPage(i18n("&General")); QGridLayout *layoutGeneral = new QGridLayout(pageGeneral, 5, 2); layoutGeneral->setSpacing(KDialog::spacingHint()); layoutGeneral->setColStretch(1 /* the right column */, 1 /*factor*/); // Title title = new KHistoryCombo(pageGeneral); title->setHistoryItems(kapp->config()->readListEntry("TitleHistory"), true); title->setEditText(mainWidget->scTitle_); layoutGeneral->addWidget(title, 0, 1); QLabel *titleLabel = new QLabel(title, i18n("&Title:"), pageGeneral); layoutGeneral->addWidget(titleLabel, 0, 0); // Subject subject = new KHistoryCombo(pageGeneral); subject->setHistoryItems (kapp->config()->readListEntry("SubjectHistory"), true); subject->setEditText(mainWidget->scSubtitle_); layoutGeneral->addWidget(subject, 1, 1); QLabel *subjectLabel = new QLabel(subject, i18n("&Subject:"), pageGeneral); layoutGeneral->addWidget(subjectLabel, 1, 0); // Author author = new KHistoryCombo(pageGeneral); author->setHistoryItems (kapp->config()->readListEntry("AuthorHistory"), true); author->setEditText(mainWidget->scAuthor_); layoutGeneral->addWidget(author, 2, 1); QLabel *authorLabel = new QLabel(author, i18n("A&uthor:"), pageGeneral); layoutGeneral->addWidget(authorLabel, 2, 0); // Last author lastAuthor = new KHistoryCombo(pageGeneral); lastAuthor->setHistoryItems (kapp->config()->readListEntry("LastAuthorHistory"), true); lastAuthor->setEditText(mainWidget->scLastAuthor_); layoutGeneral->addWidget(lastAuthor, 3, 1); QLabel *lastAuthorLabel = new QLabel (lastAuthor, i18n("&Last author:"), pageGeneral); layoutGeneral->addWidget(lastAuthorLabel, 3, 0); // Copyright copyright = new KHistoryCombo(pageGeneral); copyright->setHistoryItems (kapp->config()->readListEntry("Copyright"), true); copyright->setEditText(mainWidget->scCopyright_); layoutGeneral->addWidget(copyright, 4, 1); QLabel *copyrightLabel = new QLabel (lastAuthor, i18n("&Copyright:"), pageGeneral); layoutGeneral->addWidget(copyrightLabel, 4, 0); // COMMENTS QGrid *pageComments = addGridPage(1, QGrid::Horizontal, i18n("Co&mments")); comments = new QMultiLineEdit(pageComments); comments->setText(mainWidget->scComment_); comments->setSizePolicy (QSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding) ); connect(this, SIGNAL(finished()), this, SLOT(saveComboData())); connect(this, SIGNAL(user2Clicked()), title, SLOT(clearEdit())); connect(this, SIGNAL(user2Clicked()), subject, SLOT(clearEdit())); connect(this, SIGNAL(user2Clicked()), author, SLOT(clearEdit())); connect(this, SIGNAL(user2Clicked()), lastAuthor, SLOT(clearEdit())); connect(this, SIGNAL(user2Clicked()), copyright, SLOT(clearEdit())); connect(this, SIGNAL(user2Clicked()), comments, SLOT(clear())); connect(this, SIGNAL(okClicked()), this, SLOT(slotApply())); connect(this, SIGNAL(okClicked()), this, SLOT(hide())); }
bool compareNew() { clearWindow(nppData._scintillaMainHandle, true); clearWindow(nppData._scintillaSecondHandle, true); active = true; int doc1Length; int *lineNum1; char **doc1 = getAllLines(nppData._scintillaMainHandle, &doc1Length, &lineNum1); if(doc1Length < 1) { return true; } int doc2Length; int *lineNum2; char **doc2 = getAllLines(nppData._scintillaSecondHandle, &doc2Length, &lineNum2); if(doc2Length < 1) { return true; } int doc1Changed = 0; int doc2Changed = 0; diff_edit *doc1Changes = NULL; diff_edit *doc2Changes = NULL; unsigned int *doc1Hashes = computeHashes(doc1, doc1Length, Settings.IncludeSpace); unsigned int *doc2Hashes = computeHashes(doc2, doc2Length, Settings.IncludeSpace); /* make diff */ int sn; struct varray *ses = varray_new(sizeof(struct diff_edit), NULL); int result = (diff(doc1Hashes, 0, doc1Length, doc2Hashes, 0, doc2Length, (idx_fn)(getLineFromIndex), (cmp_fn)(compareLines), NULL, 0, ses, &sn, NULL)); int changeOffset = 0; shift_boundries(ses, sn, doc1Hashes, doc2Hashes, doc1Length, doc2Length); find_moves(ses, sn, doc1Hashes, doc2Hashes, Settings.DetectMove); /* * - insert empty lines * - count changed lines */ doc1Changed = 0; doc2Changed = 0; for (int i = 0; i < sn; i++) { struct diff_edit *e =(diff_edit*) varray_get(ses, i); if(e->op == DIFF_DELETE) { e->changeCount = 0; doc1Changed += e->len; struct diff_edit *e2 =(diff_edit*) varray_get(ses, i+1); e2->changeCount = 0; if(e2->op == DIFF_INSERT) { //see if the DELETE/INSERT COMBO includes changed lines or if its a completely new block if(compareWords(e, e2, doc1, doc2, Settings.IncludeSpace)) { e->op = DIFF_CHANGE1; e2->op = DIFF_CHANGE2; doc2Changed += e2->len; } } } else if(e->op == DIFF_INSERT) { e->changeCount = 0; doc2Changed += e->len; } } int doc1CurrentChange = 0; int doc2CurrentChange = 0; changeOffset = 0; doc1Changes = new diff_edit[doc1Changed]; doc2Changes = new diff_edit[doc2Changed]; int doc1Offset = 0; int doc2Offset = 0; //switch from blocks of lines to one change per line. Change CHANGE to DELETE or INSERT if there are no changes on that line int added; for (int i = 0; i < sn; i++) { struct diff_edit *e =(diff_edit*) varray_get(ses, i); e->set = i; switch(e->op) { case DIFF_CHANGE1: case DIFF_DELETE: added = setDiffLines(e, doc1Changes, &doc1CurrentChange, DIFF_DELETE, e->off + doc2Offset); doc2Offset -= added; doc1Offset += added; break; case DIFF_INSERT: case DIFF_CHANGE2: added = setDiffLines(e, doc2Changes, &doc2CurrentChange, DIFF_INSERT, e->off + doc1Offset); doc1Offset -= added; doc2Offset += added; break; } } if (result != -1) { int textIndex; different = (doc1Changed > 0) || (doc2Changed > 0); for(int i = 0; i < doc1Changed; i++) { switch(doc1Changes[i].op) { case DIFF_DELETE: markAsRemoved(nppData._scintillaMainHandle, doc1Changes[i].off); break; case DIFF_CHANGE1: markAsChanged(nppData._scintillaMainHandle, doc1Changes[i].off); textIndex = lineNum1[doc1Changes[i].off]; for(int k = 0; k < doc1Changes[i].changeCount; k++) { struct diff_change *change = (diff_change*)varray_get(doc1Changes[i].changes, k); markTextAsChanged(nppData._scintillaMainHandle, textIndex + change->off, change->len); } break; case DIFF_MOVE: markAsMoved(nppData._scintillaMainHandle, doc1Changes[i].off); break; } } for(int i = 0; i < doc2Changed; i++) { switch(doc2Changes[i].op) { case DIFF_INSERT: markAsAdded(nppData._scintillaSecondHandle, doc2Changes[i].off); break; case DIFF_CHANGE2: markAsChanged(nppData._scintillaSecondHandle, doc2Changes[i].off); textIndex = lineNum2[doc2Changes[i].off]; for(int k = 0; k < doc2Changes[i].changeCount; k++) { struct diff_change *change=(diff_change*)varray_get(doc2Changes[i].changes, k); markTextAsChanged(nppData._scintillaSecondHandle, textIndex+change->off, change->len); } break; case DIFF_MOVE: markAsMoved(nppData._scintillaSecondHandle,doc2Changes[i].off); break; } } doc1Offset = 0; doc2Offset = 0; if(Settings.AddLine) { int length = 0; int off = -1; for(int i = 0; i < doc1Changed; i++) { switch(doc1Changes[i].op) { case DIFF_DELETE: case DIFF_MOVE: if(doc1Changes[i].altLocation == off) { length++; } else { addEmptyLines(nppData._scintillaSecondHandle, off + doc2Offset, length); doc2Offset += length; off = doc1Changes[i].altLocation; length = 1; } break; } } addEmptyLines(nppData._scintillaSecondHandle, off + doc2Offset, length); if(doc2Offset > 0) { clearUndoBuffer(nppData._scintillaSecondHandle); } length = 0; off = 0; doc1Offset = 0; for(int i = 0; i < doc2Changed; i++) { switch(doc2Changes[i].op) { case DIFF_INSERT: case DIFF_MOVE: if(doc2Changes[i].altLocation == off) { length++; } else { addEmptyLines(nppData._scintillaMainHandle, off + doc1Offset, length); doc1Offset += length; off = doc2Changes[i].altLocation; length = 1; } break; } } addEmptyLines(nppData._scintillaMainHandle, off + doc1Offset, length); if(doc1Offset > 0) { clearUndoBuffer(nppData._scintillaMainHandle); } } //clean up resources #if CLEANUP for(int i = 0; i < doc1Length; i++) { if(*doc1[i] != 0) { delete[] doc1[i]; } } delete[] doc1; delete[] lineNum1; for(int i = 0; i < doc2Length; i++) { if(*doc2[i] != 0) { delete[] doc2[i]; } } delete[] doc2; delete lineNum2; delete[] doc1Hashes; delete[] doc2Hashes; clearEdits(ses, sn); for(int i = 0; i < doc1Changed; i++) { clearEdit(doc1Changes + (i)); } delete[] doc1Changes; for(int i = 0; i < doc2Changed; i++) { clearEdit(doc2Changes+(i)); } delete[] doc2Changes; #endif // CLEANUP if(!different) { ::MessageBox(nppData._nppHandle, TEXT("Files Match"), TEXT("Results :"), MB_OK); return true; } ::SendMessageA(nppData._scintillaMainHandle, SCI_SHOWLINES, 0, (LPARAM)1); ::SendMessageA(nppData._scintillaSecondHandle, SCI_SHOWLINES, 0, (LPARAM)1); return false; } return false; }