MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / onSelectionChanged

Method onSelectionChanged

Gui/MultiInstancePanel.cpp:1114–1264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1112}
1113
1114void
1115MultiInstancePanel::onSelectionChanged(const QItemSelection & newSelection,
1116 const QItemSelection & oldSelection)
1117{
1118 std::list<std::pair<Node*, bool> > previouslySelectedInstances;
1119 QModelIndexList oldIndexes = oldSelection.indexes();
1120
1121 _imp->getNodesFromSelection(oldIndexes, &previouslySelectedInstances);
1122
1123 bool copyOnUnSlave = previouslySelectedInstances.size() <= 1;
1124
1125 /// new selection
1126 std::list<std::pair<Node*, bool> > newlySelectedInstances;
1127 QModelIndexList newIndexes = newSelection.indexes();
1128 _imp->getNodesFromSelection(newIndexes, &newlySelectedInstances);
1129
1130 ///Don't consider items that are in both previouslySelectedInstances && newlySelectedInstances
1131
1132 QModelIndexList rows = _imp->view->selectionModel()->selectedRows();
1133 bool setDirty = rows.count() > 1;
1134 std::list<std::pair<Node*, bool> >::iterator nextPreviouslySelected = previouslySelectedInstances.begin();
1135 if ( nextPreviouslySelected != previouslySelectedInstances.end() ) {
1136 ++nextPreviouslySelected;
1137 }
1138
1139
1140 for (std::list<std::pair<Node*, bool> >::iterator it = previouslySelectedInstances.begin();
1141 it != previouslySelectedInstances.end(); ++it) {
1142 ///if the item is in the new selection, don't consider it
1143 bool skip = false;
1144 for (std::list<std::pair<Node*, bool> >::iterator it2 = newlySelectedInstances.begin();
1145 it2 != newlySelectedInstances.end(); ++it2) {
1146 if (it2->first == it->first) {
1147 skip = true;
1148 break;
1149 }
1150 } // for(it2)
1151 ///disconnect all the knobs
1152 if (!it->second || skip) {
1153 continue;
1154 }
1155
1156 it->first->hideKeyframesFromTimeline( nextPreviouslySelected == previouslySelectedInstances.end() );
1157
1158 it->first->getEffectInstance()->beginChanges();
1159 const std::vector<KnobIPtr> & knobs = it->first->getKnobs();
1160 for (U32 i = 0; i < knobs.size(); ++i) {
1161 if ( knobs[i]->isDeclaredByPlugin() && !knobs[i]->isInstanceSpecific() && !knobs[i]->getIsSecret() ) {
1162 for (int j = 0; j < knobs[i]->getDimension(); ++j) {
1163 if ( knobs[i]->isSlave(j) ) {
1164 knobs[i]->blockValueChanges();
1165 knobs[i]->unSlave(j, copyOnUnSlave);
1166 knobs[i]->unblockValueChanges();
1167 }
1168 }
1169 }
1170 } // for(i)
1171 it->first->getEffectInstance()->endChanges();

Callers

nothing calls this directly

Calls 15

getGuiFunction · 0.85
getNodesFromSelectionMethod · 0.80
getEffectInstanceMethod · 0.80
isDeclaredByPluginMethod · 0.80
isInstanceSpecificMethod · 0.80
getIsSecretMethod · 0.80
isSlaveMethod · 0.80
blockValueChangesMethod · 0.80
unSlaveMethod · 0.80
unblockValueChangesMethod · 0.80

Tested by

no test coverage detected