Skip to content

Commit

Permalink
ViewProvider: add set/getElementColors() API
Browse files Browse the repository at this point in the history
The API is to expose element color mangement to the core. This patch
provides implementation in Gui::ViewProviderLink and
PartGui::ViewProviderPartExt. ViewProviderLink uses this API to support
color and visibility override functionality, which is required to
implement STEP SHUO (Specified Higher Usage Occurrence) styling.
  • Loading branch information
realthunder committed Jun 1, 2018
1 parent fd84efa commit 2fcef03
Show file tree
Hide file tree
Showing 18 changed files with 1,627 additions and 547 deletions.
16 changes: 16 additions & 0 deletions src/App/DocumentObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,3 +958,19 @@ std::string DocumentObject::getElementMapVersion(const App::Property *_prop) con
ss << prop->getComplexData()->getElementMapVersion();
return ss.str();
}

const std::string &DocumentObject::hiddenMarker() {
static std::string marker("!hide");
return marker;
}

const char *DocumentObject::hasHiddenMarker(const char *subname) {
if(!subname) return 0;
const char *marker = strrchr(subname,'.');
if(!marker)
marker = subname;
else
++marker;
return hiddenMarker()==marker?marker:0;
}

9 changes: 9 additions & 0 deletions src/App/DocumentObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,15 @@ class AppExport DocumentObject: public App::TransactionalObject

virtual void onUpdateElementReference(const Property *) {}

/** Sepecial marker to mark the object has hidden
*
* It is used by Gui::ViewProvider::getElementColors(), but exposed here
* for convenience
*/
static const std::string &hiddenMarker();
/// Check if the subname reference ends with hidden marker.
static const char *hasHiddenMarker(const char *subname);

protected:
/// recompute only this object
virtual App::DocumentObjectExecReturn *recompute(void);
Expand Down
13 changes: 10 additions & 3 deletions src/App/Link.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ class AppExport LinkBaseExtension : public App::DocumentObjectExtension
#define LINK_PARAM_MODE(...) \
(LinkMode, long, App::PropertyEnumeration, ((long)0), "Link group mode", ##__VA_ARGS__)

#define LINK_PARAM_COLORED_ELEMENTS(...) \
(ColoredElements, App::DocumentObject*, App::PropertyLinkSubHidden, \
0, "Link colored elements", ##__VA_ARGS__)

#define LINK_PARAM(_param) (LINK_PARAM_##_param())

#define LINK_PNAME(_param) BOOST_PP_TUPLE_ELEM(0,_param)
Expand All @@ -145,7 +149,8 @@ class AppExport LinkBaseExtension : public App::DocumentObjectExtension
LINK_PARAM(COUNT)\
LINK_PARAM(ELEMENTS)\
LINK_PARAM(SHOW_ELEMENT)\
LINK_PARAM(MODE)
LINK_PARAM(MODE)\
LINK_PARAM(COLORED_ELEMENTS)

enum PropIndex {
#define LINK_PINDEX_DEFINE(_1,_2,_param) LINK_PINDEX(_param),
Expand Down Expand Up @@ -404,7 +409,8 @@ class AppExport Link : public App::DocumentObject, public App::LinkExtension
LINK_PARAM_EXT(PLACEMENT)\
LINK_PARAM_EXT(SUB_ELEMENT)\
LINK_PARAM_EXT(SHOW_ELEMENT)\
LINK_PARAM_EXT_TYPE(COUNT,App::PropertyIntegerConstraint)
LINK_PARAM_EXT_TYPE(COUNT,App::PropertyIntegerConstraint)\
LINK_PARAM_EXT_ATYPE(COLORED_ELEMENTS,App::Prop_Hidden)

LINK_PROPS_DEFINE(LINK_PARAMS_LINK)

Expand Down Expand Up @@ -466,7 +472,8 @@ class AppExport LinkGroup : public App::DocumentObject, public App::LinkBaseExte
LINK_PARAM_EXT(ELEMENTS)\
LINK_PARAM_EXT(PLACEMENT)\
LINK_PARAM_EXT(VISIBILITIES)\
LINK_PARAM_EXT(MODE)
LINK_PARAM_EXT(MODE)\
LINK_PARAM_EXT_ATYPE(COLORED_ELEMENTS,App::Prop_Hidden)

// defines the actual properties
LINK_PROPS_DEFINE(LINK_PARAMS_GROUP)
Expand Down
5 changes: 5 additions & 0 deletions src/Gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ set(Gui_MOC_HDRS
TaskView/TaskView.h
DAGView/DAGView.h
DAGView/DAGModel.h
TaskElementColors.h
)

fc_wrap_cpp(Gui_MOC_SRCS ${Gui_MOC_HDRS})
Expand Down Expand Up @@ -370,6 +371,7 @@ SET(Gui_UIC_SRCS
TextureMapping.ui
TaskView/TaskAppearance.ui
TaskView/TaskSelectLinkProperty.ui
TaskElementColors.ui
)

SET(Gui_RES_SRCS
Expand Down Expand Up @@ -442,6 +444,7 @@ SET(Dialog_CPP_SRCS
DownloadItem.cpp
DownloadManager.cpp
DocumentRecovery.cpp
TaskElementColors.cpp
)

SET(Dialog_HPP_SRCS
Expand Down Expand Up @@ -474,6 +477,7 @@ SET(Dialog_HPP_SRCS
DownloadItem.h
DownloadManager.h
DocumentRecovery.h
TaskElementColors.h
)

SET(Dialog_SRCS
Expand Down Expand Up @@ -508,6 +512,7 @@ SET(Dialog_SRCS
Placement.ui
SceneInspector.ui
TextureMapping.ui
TaskElementColors.ui
)
SOURCE_GROUP("Dialog" FILES ${Dialog_SRCS})

Expand Down
Loading

0 comments on commit 2fcef03

Please sign in to comment.