Skip to content

Commit cc5f6fa

Browse files
committed
Fix invertMask and hasMask methods.
Invert also the ("ALL", i) pair-masks. Clear the ("ALL", i) pair-mask records when switching to type-based masking. Improve the hasMask function to check all mask records.
1 parent a03dcb7 commit cc5f6fa

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/diffpy/srreal/PairQuantity.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ void PairQuantity::invertMask()
195195
{
196196
mticker.click();
197197
mdefaultpairmask = !mdefaultpairmask;
198+
boost::unordered_map<int, bool>::iterator mm;
199+
for (mm = msiteallmask.begin(); mm != msiteallmask.end(); ++mm)
200+
{
201+
mm->second = !(mm->second);
202+
}
198203
TypeMaskStorage::iterator tpmsk;
199204
for (tpmsk = mtypemask.begin(); tpmsk != mtypemask.end(); ++tpmsk)
200205
{
@@ -275,6 +280,9 @@ setTypeMask(string smbli, string smblj, bool mask)
275280
this->maskAllPairs(mask);
276281
return;
277282
}
283+
// msiteallmask is only relevant for index-based masking.
284+
// clean it up to avoid unexpected effects when switching to index masks.
285+
msiteallmask.clear();
278286
bool modified = false;
279287
// when all is used, remove all typemask elements with the other type
280288
if (ALLATOMSSTR == smbli || ALLATOMSSTR == smblj)
@@ -359,7 +367,8 @@ int PairQuantity::countSites() const
359367

360368
bool PairQuantity::hasMask() const
361369
{
362-
bool rv = !(mdefaultpairmask && minvertpairmask.empty());
370+
bool rv = !(mdefaultpairmask && minvertpairmask.empty() &&
371+
msiteallmask.empty() && mtypemask.empty());
363372
return rv;
364373
}
365374

0 commit comments

Comments
 (0)