Skip to content

Commit

Permalink
Merge pull request #12417 from alja/table-filter-75
Browse files Browse the repository at this point in the history
  75x Fireworks: Add option to skip filter items in table view
  • Loading branch information
cmsbuild committed Nov 15, 2015
2 parents 0c4cb07 + a4df4a0 commit f56dd6f
Show file tree
Hide file tree
Showing 14 changed files with 144 additions and 33 deletions.
2 changes: 2 additions & 0 deletions Fireworks/Core/interface/CmsShowEDI.h
Expand Up @@ -76,6 +76,7 @@ class CmsShowEDI : public TGTransientFrame
void toggleItemVisible(Bool_t on = kTRUE);
void changeItemOpacity(Int_t opacity);
void runFilter();
void toggleShowFiltered(Bool_t on = true);
void runSelection();
void selectAll();
void deselectAll();
Expand Down Expand Up @@ -109,6 +110,7 @@ class CmsShowEDI : public TGTransientFrame
FWGUIValidatingTextEntry* m_filterExpressionEntry;
FWGUIValidatingTextEntry* m_selectExpressionEntry;
TGTextButton* m_filterButton;
TGCheckButton* m_showFilteredCheckButton;
TGTextButton* m_selectButton;
TGTextButton* m_selectAllButton;
TGTextButton* m_deselectAllButton;
Expand Down
12 changes: 12 additions & 0 deletions Fireworks/Core/interface/FWDisplayProperties.h
Expand Up @@ -43,6 +43,7 @@ class FWDisplayProperties
*/
FWDisplayProperties(Color_t iColor,
bool isVisible,
bool filetrPassed,
Char_t transparency);
//virtual ~FWDisplayProperties();

Expand All @@ -60,9 +61,19 @@ class FWDisplayProperties
return m_isVisible;
}

bool filterPassed() const {
return m_filterPassed;
}

void setFilterPassed(bool x)
{
m_filterPassed = x;
}

bool operator==(const FWDisplayProperties& iRHS) const {
return m_color == iRHS.m_color
&& m_isVisible == iRHS.m_isVisible
&& m_filterPassed == iRHS.m_filterPassed
&& m_transparency == iRHS.m_transparency;
}
bool operator!=(const FWDisplayProperties& iRHS) const {
Expand Down Expand Up @@ -97,6 +108,7 @@ class FWDisplayProperties

Color_t m_color;
bool m_isVisible;
bool m_filterPassed;
Char_t m_transparency;
};

Expand Down
10 changes: 8 additions & 2 deletions Fireworks/Core/interface/FWEventItem.h
Expand Up @@ -75,7 +75,7 @@ class FWEventItem
FWEventItem(fireworks::Context* iContext,
unsigned int iItemId,
boost::shared_ptr<FWItemAccessorBase> iAccessor,
const FWPhysicsObjectDesc& iDesc, const FWConfiguration* pbConf = 0);
const FWPhysicsObjectDesc& iDesc, bool showFiltered = true, const FWConfiguration* pbConf = 0);
virtual ~FWEventItem();

// ---------- const member functions ---------------------
Expand All @@ -96,6 +96,9 @@ class FWEventItem
bool isInBack() const;

const std::string& filterExpression() const;

bool showFilteredEntries() const { return m_showFilteredEntries;}

/**Unique ID for the item. This number starts at 0 and increments by one for each
new item.*/
unsigned int id() const;
Expand Down Expand Up @@ -171,6 +174,8 @@ class FWEventItem
void setDefaultDisplayProperties(const FWDisplayProperties&);
/**Throws an FWExpresionException if there is a problem with the expression */
void setFilterExpression(const std::string& );

void setShowFilteredEntries(bool x);

/**Select the item (i.e. container) itself*/
void selectItem();
Expand Down Expand Up @@ -220,7 +225,7 @@ class FWEventItem

void getPrimaryData() const;
void runFilter();
void handleChange();
void handleChange(bool filterUpdate = true);
// ---------- member data --------------------------------
const fireworks::Context* m_context;
unsigned int m_id;
Expand All @@ -241,6 +246,7 @@ class FWEventItem
FWItemValueGetter m_interestingValueGetter;

FWModelFilter m_filter;
bool m_showFilteredEntries;
mutable bool m_printedErrorThisEvent;
mutable std::string m_errorMessage;

Expand Down
2 changes: 1 addition & 1 deletion Fireworks/Core/interface/FWEventItemsManager.h
Expand Up @@ -64,7 +64,7 @@ class FWEventItemsManager : public FWConfigurable
// ---------- static member functions --------------------

// ---------- member functions ---------------------------
const FWEventItem* add(const FWPhysicsObjectDesc& iItem, const FWConfiguration* pbConf = 0);
const FWEventItem* add(const FWPhysicsObjectDesc& iItem, bool showFilteredInTable = true, const FWConfiguration* pbConf = 0);
void clearItems();

void newEvent(const edm::EventBase* iEvent);
Expand Down
2 changes: 2 additions & 0 deletions Fireworks/Core/interface/FWTableViewTableManager.h
Expand Up @@ -116,6 +116,8 @@ class FWTableViewTableManager : public FWTableManagerBase {
private:
FWTableViewTableManager(const FWTableViewTableManager&); // stop default
const FWTableViewTableManager& operator=(const FWTableViewTableManager&); // stop default

const FWEventItem* collection() const;
};


Expand Down
21 changes: 16 additions & 5 deletions Fireworks/Core/src/CmsShowEDI.cc
Expand Up @@ -75,7 +75,6 @@ CmsShowEDI::CmsShowEDI(const TGWindow* p, UInt_t w, UInt_t h, FWSelectionManager
TGVerticalFrame* vf = new TGVerticalFrame(this);
AddFrame(vf, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 0, 0, 0, 0));
FWDialogBuilder builder(vf);

builder.indent(0)
.addLabel(" ", 14, 2, &m_objectLabel)
.vSpacer()
Expand Down Expand Up @@ -105,8 +104,9 @@ CmsShowEDI::CmsShowEDI(const TGWindow* p, UInt_t w, UInt_t h, FWSelectionManager
.addLabel("Expression", 8)
.addValidatingTextEntry(0, &m_filterExpressionEntry).floatLeft()
.addTextButton("Filter", &m_filterButton).expand(false)
.addTextView("", &m_filterError)
.vSpacer()
.addCheckbox("Hide filtered items in table", &m_showFilteredCheckButton).expand(false)
.addTextView("", &m_filterError).expand(true, true)
//.vSpacer()
.endTab()
.beginTab("Select")
.indent(3)
Expand All @@ -118,7 +118,7 @@ CmsShowEDI::CmsShowEDI(const TGWindow* p, UInt_t w, UInt_t h, FWSelectionManager
.indent(3)
.addLabel("Color Selection", 8)
.addColorPicker(colorMgr, &m_cw).expand(false)
.addTextView("", &m_selectError)
.addTextView("", &m_selectError).expand(true, true)
.vSpacer()
.endTab()
.beginTab("Data")
Expand Down Expand Up @@ -151,6 +151,8 @@ CmsShowEDI::CmsShowEDI(const TGWindow* p, UInt_t w, UInt_t h, FWSelectionManager
m_filterExpressionEntry->setValidator(m_validator);
m_selectExpressionEntry->setValidator(m_validator);

m_showFilteredCheckButton->Connect("Toggled(Bool_t)", "CmsShowEDI", this, "toggleShowFiltered()");

m_colorSelectWidget->Connect("ColorChosen(Color_t)", "CmsShowEDI", this, "changeItemColor(Color_t)");
m_cw->Connect("ColorChosen(Color_t)", "CmsShowEDI", this, "changeSelectionColor(Color_t)");
m_opacitySlider->Connect("PositionChanged(Int_t)", "CmsShowEDI", this, "changeItemOpacity(Int_t)");
Expand All @@ -177,7 +179,7 @@ CmsShowEDI::CmsShowEDI(const TGWindow* p, UInt_t w, UInt_t h, FWSelectionManager
MapSubwindows();
Resize(GetDefaultSize());
Layout();

m_filterExpressionEntry->SetForegroundColor(kOrange);
fillEDIFrame();
}

Expand All @@ -196,6 +198,7 @@ CmsShowEDI::~CmsShowEDI()
m_filterExpressionEntry->Disconnect("ReturnPressed()", this, "runFilter()");
m_selectExpressionEntry->Disconnect("ReturnPressed()", this, "runSelection()");
m_filterButton->Disconnect("Clicked()", this, "runFilter()");
m_showFilteredCheckButton->Disconnect("Toggled(Bool_t)", this, "toggleShowFiltered(Bool_t)");
m_selectButton->Disconnect("Clicked()", this, "runSelection()");
m_selectAllButton->Disconnect("Clicked()", this, "selectAll()");
m_deselectAllButton->Disconnect("Clicked()", this, "deselectAll()");
Expand Down Expand Up @@ -262,6 +265,7 @@ CmsShowEDI::fillEDIFrame() {
m_validator->setType(edm::TypeWithDict(*(iItem->modelType()->GetTypeInfo())));
m_filterExpressionEntry->SetText(iItem->filterExpression().c_str());
m_filterError->Clear();
m_showFilteredCheckButton->SetDisabledAndSelected(!iItem->showFilteredEntries());
m_selectError->Clear();
m_nameEntry->SetText(iItem->name().c_str());
m_typeEntry->SetText(iItem->type()->GetName());
Expand All @@ -274,6 +278,7 @@ CmsShowEDI::fillEDIFrame() {
m_isVisibleButton->SetEnabled(kTRUE);
m_filterExpressionEntry->SetEnabled(kTRUE);
m_selectExpressionEntry->SetEnabled(kTRUE);
m_showFilteredCheckButton->SetEnabled(kTRUE);
m_filterButton->SetEnabled(kTRUE);
m_selectButton->SetEnabled(kTRUE);
m_selectAllButton->SetEnabled(kTRUE);
Expand Down Expand Up @@ -459,6 +464,12 @@ CmsShowEDI::runFilter() {
}
}

void
CmsShowEDI::toggleShowFiltered(Bool_t on) {
m_item->setShowFilteredEntries(!on);
}


void
CmsShowEDI::runSelection() {
FWModelExpressionSelector selector;
Expand Down
37 changes: 32 additions & 5 deletions Fireworks/Core/src/FWCollectionSummaryTableManager.cc
Expand Up @@ -39,7 +39,7 @@ FWCollectionSummaryTableManager::FWCollectionSummaryTableManager(FWEventItem* iI
m_bodyRenderer(iContext, iHighlightContext, FWTextTableCellRenderer::kJustifyRight),
m_widget(iWidget)
{
m_collection->changed_.connect(boost::bind(&FWTableManagerBase::dataChanged,this));
m_collection->changed_.connect(boost::bind(&FWCollectionSummaryTableManager::modelIdChanges,this));
m_collection->itemChanged_.connect(boost::bind(&FWCollectionSummaryTableManager::dataChanged,this));

//try to find the default columns
Expand All @@ -50,6 +50,15 @@ FWCollectionSummaryTableManager::FWCollectionSummaryTableManager(FWEventItem* iI
dataChanged();
}

void FWCollectionSummaryTableManager::modelIdChanges()
{
if (m_collection->showFilteredEntries() || m_collection->filterExpression().empty())
dataChanged();
else
FWTableManagerBase::dataChanged();
}


// FWCollectionSummaryTableManager::FWCollectionSummaryTableManager(const FWCollectionSummaryTableManager& rhs)
// {
// // do actual copying here;
Expand Down Expand Up @@ -82,8 +91,10 @@ namespace {
std::vector<int>& oNewSort) {
int size = iItem.size();
for(int index = 0; index < size; ++index) {
if (iItem.modelInfo(index).displayProperties().filterPassed()) {
iMap.insert(std::make_pair(iGetter.valueFor(iItem.modelData(index), iCol),
index));
}
}
std::vector<int>::iterator itVec = oNewSort.begin();
for(typename std::map<double,int,S>::iterator it = iMap.begin(), itEnd = iMap.end();
Expand Down Expand Up @@ -132,7 +143,20 @@ FWCollectionSummaryTableManager::buttonReleasedInRowHeader(Int_t row, Event_t* e
int
FWCollectionSummaryTableManager::numberOfRows() const
{
return m_collection->size();
int cs= m_collection->size();
if (m_collection->showFilteredEntries() || m_collection->filterExpression().empty())
{
return cs;
}
else
{

int n = 0;
for(int index = 0; index < cs; ++index) {
if (m_collection->modelInfo(index).displayProperties().filterPassed()) { ++n;}
}
return n;
}
}

int
Expand Down Expand Up @@ -184,7 +208,7 @@ FWCollectionSummaryTableManager::hasRowHeaders() const
FWTableCellRendererBase*
FWCollectionSummaryTableManager::rowHeader(int iSortedRowNumber) const
{
if(iSortedRowNumber >= static_cast<int>(m_collection->size())) {
if(iSortedRowNumber >= static_cast<int>(numberOfRows())) {
return 0;
}
int index = m_sortedToUnsortedIndicies[iSortedRowNumber];
Expand All @@ -197,9 +221,12 @@ void
FWCollectionSummaryTableManager::dataChanged()
{
m_sortedToUnsortedIndicies.clear();
m_sortedToUnsortedIndicies.reserve(m_collection->size());
size_t n = numberOfRows();
m_sortedToUnsortedIndicies.reserve(n);
for(int i=0; i< static_cast<int>(m_collection->size());++i) {
m_sortedToUnsortedIndicies.push_back(i);
if (m_collection->filterExpression().empty() || m_collection->showFilteredEntries() || m_collection->modelInfo(i).displayProperties().filterPassed()) {
m_sortedToUnsortedIndicies.push_back(i);
}
}
FWTableManagerBase::dataChanged();
}
Expand Down
2 changes: 1 addition & 1 deletion Fireworks/Core/src/FWCollectionSummaryTableManager.h
Expand Up @@ -53,7 +53,7 @@ class FWCollectionSummaryTableManager : public FWTableManagerBase {

// ---------- member functions ---------------------------
virtual void buttonReleasedInRowHeader(Int_t row, Event_t* event, Int_t relX, Int_t relY);

void modelIdChanges();
protected:
virtual void implSort(int iCol, bool iSortOrder);
private:
Expand Down
4 changes: 3 additions & 1 deletion Fireworks/Core/src/FWDisplayProperties.cc
Expand Up @@ -18,12 +18,14 @@

// A static default property.
const FWDisplayProperties FWDisplayProperties::defaultProperties
(FWColorManager::getDefaultStartColorIndex(), true, 0);
(FWColorManager::getDefaultStartColorIndex(), true, true, 0);

FWDisplayProperties::FWDisplayProperties(Color_t iColor,
bool isVisible,
bool filterPassed,
Char_t transparency)
: m_color(iColor),
m_isVisible(isVisible),
m_filterPassed(filterPassed),
m_transparency(transparency)
{}

0 comments on commit f56dd6f

Please sign in to comment.