Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Ben Boeckel
SMTK
Commits
358b072f
Commit
358b072f
authored
Aug 30, 2017
by
Bob Obara
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'IntegratingSelectionManagerIntoQtModelEntityItem' into release
parents
78ee1008
e477d856
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
13 deletions
+88
-13
smtk/extension/qt/qtAttribute.cxx
smtk/extension/qt/qtAttribute.cxx
+30
-0
smtk/extension/qt/qtDiscreteValueEditor.cxx
smtk/extension/qt/qtDiscreteValueEditor.cxx
+18
-0
smtk/extension/qt/qtModelEntityItem.cxx
smtk/extension/qt/qtModelEntityItem.cxx
+34
-13
smtk/extension/qt/qtModelEntityItem.h
smtk/extension/qt/qtModelEntityItem.h
+6
-0
No files found.
smtk/extension/qt/qtAttribute.cxx
View file @
358b072f
...
...
@@ -162,6 +162,9 @@ void qtAttribute::createBasicLayout(bool includeAssociations)
QLayout
*
layout
=
this
->
m_widget
->
layout
();
qtItem
*
qItem
=
NULL
;
smtk
::
attribute
::
AttributePtr
att
=
this
->
attribute
();
// We want to track the attribute's model entity items so we can decide if we are going
// use the Selection Manager to automatically update them
std
::
vector
<
qtModelEntityItem
*>
mitems
;
// If there are model assocications for the attribute, create UI for them if requested.
// This will be the same widget used for ModelEntityItem.
if
(
includeAssociations
&&
att
->
associations
())
...
...
@@ -171,6 +174,11 @@ void qtAttribute::createBasicLayout(bool includeAssociations)
{
layout
->
addWidget
(
qItem
->
widget
());
this
->
addItem
(
qItem
);
auto
mitem
=
dynamic_cast
<
qtModelEntityItem
*>
(
qItem
);
if
(
mitem
)
{
mitems
.
push_back
(
mitem
);
}
}
}
// Now go through all child items and create ui components.
...
...
@@ -183,8 +191,30 @@ void qtAttribute::createBasicLayout(bool includeAssociations)
{
layout
->
addWidget
(
qItem
->
widget
());
this
->
addItem
(
qItem
);
auto
mitem
=
dynamic_cast
<
qtModelEntityItem
*>
(
qItem
);
if
(
mitem
)
{
mitems
.
push_back
(
mitem
);
}
}
}
// if we found no model entities then there is nothing to do
if
(
!
mitems
.
size
())
{
return
;
}
// Currently we are supporting the simple case of only one model entity item being automatically
// updated by the Selection Manager. The issue we want to avoid is multiple model entity items that overlap
// in terms of the types of entities they can hold, being updated at the same time from the Selection
// Manager. In the future we can either make the model entity item "smarter" or we could atleast
// compare the bit masks of the underlying item to determine if we would have a problem using the
// Selection Manager. Note that there is a potential issue of multiple model entity items owned
// by internal items. This check would not catch it.
if
(
mitems
.
size
()
==
1
)
{
// Simple case - there is only 1 - go ahead and set it to use the new selection manager support
mitems
.
at
(
0
)
->
useSelectionManager
();
}
}
void
qtAttribute
::
onRequestEntityAssociation
()
...
...
smtk/extension/qt/qtDiscreteValueEditor.cxx
View file @
358b072f
...
...
@@ -24,6 +24,7 @@
#include "smtk/attribute/ValueItemDefinition.h"
#include "smtk/extension/qt/qtAttribute.h"
#include "smtk/extension/qt/qtBaseView.h"
#include "smtk/extension/qt/qtModelEntityItem.h"
#include "smtk/extension/qt/qtUIManager.h"
using
namespace
smtk
::
extension
;
...
...
@@ -221,6 +222,7 @@ void qtDiscreteValueEditor::onInputValueChanged()
QList
<
smtk
::
attribute
::
ItemDefinitionPtr
>
activeChildDefs
;
std
::
size_t
i
,
m
=
item
->
numberOfActiveChildrenItems
();
std
::
vector
<
qtModelEntityItem
*>
mitems
;
for
(
i
=
0
;
i
<
m
;
i
++
)
{
smtk
::
attribute
::
ConstItemDefinitionPtr
itDef
=
...
...
@@ -251,8 +253,24 @@ void qtDiscreteValueEditor::onInputValueChanged()
this
->
Internals
->
m_childItems
.
push_back
(
childItem
);
connect
(
childItem
,
SIGNAL
(
modified
()),
this
->
Internals
->
m_inputItem
,
SLOT
(
onChildItemModified
()));
// Is this a model entity item? - if so lets put it in the vector so we can decide later
// if we are going to automatically update it via the Selection Manager
auto
mitem
=
dynamic_cast
<
qtModelEntityItem
*>
(
childItem
);
if
(
mitem
)
{
mitems
.
push_back
(
mitem
);
}
}
}
if
(
!
mitems
.
size
())
{
return
;
}
if
(
mitems
.
size
()
==
1
)
{
// Simple case - there is only 1 - go ahead and set it to use the new selection manager support
mitems
.
at
(
0
)
->
useSelectionManager
();
}
this
->
Internals
->
m_inputItem
->
baseView
()
->
setFixedLabelWidth
(
currentLen
);
this
->
Internals
->
m_hintChildWidth
=
this
->
Internals
->
m_childrenFrame
->
width
();
this
->
Internals
->
m_hintChildHeight
=
this
->
Internals
->
m_childrenFrame
->
height
();
...
...
smtk/extension/qt/qtModelEntityItem.cxx
View file @
358b072f
...
...
@@ -74,16 +74,6 @@ qtModelEntityItem::qtModelEntityItem(smtk::attribute::ItemPtr dataObj, QWidget*
std
::
cerr
<<
"register selection source "
<<
this
->
m_selectionSourceName
<<
"failed. Already existed!"
<<
std
::
endl
;
}
// If there is a selection manager then lets see if we can set the checkbox widget to
// match the current selection state
if
(
qtActiveObjects
::
instance
().
smtkSelectionManager
())
{
smtk
::
model
::
EntityRefs
selEntities
;
qtActiveObjects
::
instance
().
smtkSelectionManager
()
->
getSelectedEntitiesAsEntityRefs
(
selEntities
);
this
->
associateEntities
(
selEntities
,
false
);
}
}
qtModelEntityItem
::~
qtModelEntityItem
()
...
...
@@ -96,6 +86,30 @@ qtModelEntityItem::~qtModelEntityItem()
delete
this
->
Internals
;
}
// This method will tie the object to the Selection Manager in terms of both
// initializing based on the current selection as well as future selections
void
qtModelEntityItem
::
useSelectionManager
()
{
// If there is a selection manager then lets see if we can set the checkbox widget to
// match the current selection state
if
(
!
qtActiveObjects
::
instance
().
smtkSelectionManager
())
{
return
;
// There is no selection manager available
}
smtk
::
model
::
EntityRefs
selEntities
;
qtActiveObjects
::
instance
().
smtkSelectionManager
()
->
getSelectedEntitiesAsEntityRefs
(
selEntities
);
this
->
associateEntities
(
selEntities
,
false
);
connect
(
qtActiveObjects
::
instance
().
smtkSelectionManager
().
get
(),
SIGNAL
(
broadcastToReceivers
(
const
smtk
::
model
::
EntityRefs
&
,
const
smtk
::
mesh
::
MeshSets
&
,
const
smtk
::
model
::
DescriptivePhrases
&
,
const
std
::
string
&
)),
this
,
SLOT
(
updateSelection
(
const
smtk
::
model
::
EntityRefs
&
,
const
smtk
::
mesh
::
MeshSets
&
,
const
smtk
::
model
::
DescriptivePhrases
&
,
const
std
::
string
&
)));
this
->
Internals
->
LinkSelectionButton
->
hide
();
this
->
Internals
->
ClearButton
->
hide
();
}
smtk
::
attribute
::
ModelEntityItemPtr
qtModelEntityItem
::
modelEntityItem
()
{
return
dynamic_pointer_cast
<
ModelEntityItem
>
(
this
->
getObject
());
...
...
@@ -372,6 +386,12 @@ void qtModelEntityItem::setOutputOptional(int state)
}
}
void
qtModelEntityItem
::
updateSelection
(
const
smtk
::
model
::
EntityRefs
&
selEntities
,
const
smtk
::
mesh
::
MeshSets
&
,
const
smtk
::
model
::
DescriptivePhrases
&
,
const
std
::
string
&
)
{
this
->
associateEntities
(
selEntities
);
}
void
qtModelEntityItem
::
associateEntities
(
const
smtk
::
model
::
EntityRefs
&
selEntityRefs
,
bool
resetExisting
)
{
...
...
@@ -399,9 +419,9 @@ void qtModelEntityItem::associateEntities(
(
numEnts
>
def
->
maxNumberOfValues
())))
&&
(
numEnts
>
def
->
numberOfRequiredValues
())))
{
std
::
cerr
<<
"Not Setting ModelEntityItem, numEnts = "
<<
numEnts
<<
" Def isExtensible = "
<<
def
->
isExtensible
()
<<
" Num Vals = "
<<
def
->
numberOfRequiredValues
()
<<
std
::
endl
;
//
std::cerr << "Not Setting ModelEntityItem, numEnts = " << numEnts
//
<< " Def isExtensible = " << def->isExtensible()
//
<< " Num Vals = " << def->numberOfRequiredValues() << std::endl;
return
;
}
...
...
@@ -434,6 +454,7 @@ void qtModelEntityItem::associateEntities(
{
this
->
Internals
->
EntityItemCombo
->
init
();
}
emit
modified
();
}
void
qtModelEntityItem
::
clearEntityAssociations
()
...
...
smtk/extension/qt/qtModelEntityItem.h
View file @
358b072f
...
...
@@ -44,6 +44,8 @@ public:
bool
add
(
const
smtk
::
model
::
EntityRef
&
val
);
bool
remove
(
const
smtk
::
model
::
EntityRef
&
val
);
/// Automatically update the item when the selection is changed via the Manager
void
useSelectionManager
();
public
slots
:
void
setOutputOptional
(
int
);
...
...
@@ -51,6 +53,10 @@ public slots:
void
onExpungeEntities
(
const
smtk
::
model
::
EntityRefs
&
expungedEnts
);
/// when active model changed, entityAssociations would be cleared
virtual
void
clearEntityAssociations
();
/// used by the Selection Manager if useSelectionManager method has been called
void
updateSelection
(
const
smtk
::
model
::
EntityRefs
&
selEntities
,
const
smtk
::
mesh
::
MeshSets
&
selMeshes
,
const
smtk
::
model
::
DescriptivePhrases
&
DesPhrases
,
const
std
::
string
&
incomingSelectionSource
);
signals:
void
requestEntityAssociation
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment