00001
00002
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00022
00028 #include <exotkAIS_MaterialMenuNode.hxx>
00029
00030 #ifndef _AIS_InteractiveObject_HeaderFile
00031 #include <AIS_InteractiveObject.hxx>
00032 #endif
00033 #ifndef _AIS_InteractiveContext_HeaderFile
00034 #include <AIS_InteractiveContext.hxx>
00035 #endif
00036 #ifndef _Graphic3d_MaterialAspect_HeaderFile
00037 #include <Graphic3d_MaterialAspect.hxx>
00038 #endif
00039 #ifndef _AIS_Drawer_HeaderFile
00040 #include <AIS_Drawer.hxx>
00041 #endif
00042 #ifndef _Prs3d_ShadingAspect_HeaderFile
00043 #include <Prs3d_ShadingAspect.hxx>
00044 #endif
00045 #ifndef _Graphic3d_AspectFillArea3d_HeaderFile
00046 #include <Graphic3d_AspectFillArea3d.hxx>
00047 #endif
00048 #ifndef _exotkGUI_HeaderFile
00049 #include <exotkGUI.hxx>
00050 #endif
00051 #ifndef _exotkGUI_GUI_HeaderFile
00052 #include <exotkGUI_GUI.hxx>
00053 #endif
00054
00055 IMPLEMENT_STANDARD_HANDLE(exotkAIS_MaterialMenuNode, exotkTree_MenuNode)
00056 IMPLEMENT_STANDARD_RTTI(exotkAIS_MaterialMenuNode, exotkTree_MenuNode)
00057
00058
00059
00060
00061
00062
00063
00064 IMPLEMENT_STANDARD_TYPE(exotkAIS_MaterialMenuNode)
00065 IMPLEMENT_STANDARD_SUPERTYPE(exotkTree_MenuNode)
00066 IMPLEMENT_STANDARD_SUPERTYPE(exotkTree_TreeNode)
00067 IMPLEMENT_STANDARD_SUPERTYPE(MMgt_TShared)
00068 IMPLEMENT_STANDARD_SUPERTYPE(Standard_Transient)
00069 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY()
00070 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(exotkTree_MenuNode)
00071 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(exotkTree_TreeNode)
00072 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(MMgt_TShared)
00073 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(Standard_Transient)
00074 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_END()
00075 IMPLEMENT_STANDARD_TYPE_END(exotkAIS_MaterialMenuNode)
00076
00077 exotkAIS_MaterialMenuNode::exotkAIS_MaterialMenuNode(const Handle_AIS_InteractiveObject& anInteractiveObject)
00078 :myInteractiveObject(anInteractiveObject)
00079 {
00080 }
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 exotkAIS_MaterialMenuNode::~exotkAIS_MaterialMenuNode()
00091 {
00092 }
00093
00094
00095
00096
00097
00098
00099
00100
00101 Standard_Boolean exotkAIS_MaterialMenuNode::Execute()
00102 {
00103 Standard_Boolean theReturnValue = Standard_False;
00104 if ( !myInteractiveObject.IsNull() )
00105 {
00106 if ( myInteractiveObject->HasInteractiveContext() )
00107 {
00108 Handle_AIS_InteractiveContext theAISContext = myInteractiveObject->GetContext();
00109 if ( !theAISContext.IsNull() )
00110 {
00111 try
00112 {
00113 Graphic3d_MaterialAspect theOriginMaterial = myInteractiveObject->Attributes()->ShadingAspect()->Aspect()->FrontMaterial();
00114 Graphic3d_MaterialAspect theNewMaterial;
00115 Standard_Boolean theMaterialIsSelected = Standard_False;
00116 if ( exotkGUI::SelectMaterial(theOriginMaterial,theNewMaterial,theMaterialIsSelected) && theMaterialIsSelected)
00117 {
00118 myInteractiveObject->SetMaterial(theNewMaterial);
00119 theAISContext->Redisplay(myInteractiveObject);
00120 }
00121 }
00122 catch(Standard_Failure)
00123 {
00124 theReturnValue = Standard_False;
00125 }
00126 catch(...)
00127 {
00128 theReturnValue = Standard_False;
00129 }
00130 }
00131 }
00132 }
00133 return theReturnValue;
00134 }