diff --git a/src/DDF/DDF_Browser.cxx b/src/DDF/DDF_Browser.cxx index 7b71178f5c..7c6914602b 100755 --- a/src/DDF/DDF_Browser.cxx +++ b/src/DDF/DDF_Browser.cxx @@ -1,7 +1,6 @@ // File: DDF_Browser.cxx // --------------- // Author: DAUTRY Philippe -// // Copyright: Matra Datavision 1997 // Version: 0.0 @@ -9,7 +8,6 @@ // 0.0 Oct 3 1997 Creation - #include #include @@ -118,7 +116,8 @@ TCollection_AsciiString DDF_Browser::OpenRoot() const Handle(TDataStd_Name) name; list.AssignCat(TDF_BrowserSeparator2); list.AssignCat("\""); - if (root.FindAttribute(TDataStd_Name::GetID(),name)) { + if (root.FindAttribute(TDataStd_Name::GetID(),name)) + { TCollection_AsciiString tmpStr(name->Get(),'?'); tmpStr.ChangeAll(' ','_'); list.AssignCat(tmpStr); @@ -128,13 +127,7 @@ TCollection_AsciiString DDF_Browser::OpenRoot() const if (!root.MayBeModified()) list.AssignCat("Not"); list.AssignCat("Modified"); list.AssignCat(TDF_BrowserSeparator2); - if (root.HasAttribute() || (root.HasChild())) { - list.AssignCat("1"); - } - else { - list.AssignCat("0"); - } - //cout<<"OpenRoot: "<Get(),'?'); tmpStr.ChangeAll(' ','_'); list.AssignCat(tmpStr); @@ -179,14 +175,9 @@ TCollection_AsciiString DDF_Browser::OpenLabel(const TDF_Label& aLab) const list.AssignCat("Modified"); list.AssignCat(TDF_BrowserSeparator2); // May be open. - if (itr.Value().HasAttribute() || (itr.Value().HasChild())) - list.AssignCat("1"); - else - list.AssignCat("0"); - + list.AssignCat((itr.Value().HasAttribute() || itr.Value().HasChild())? "1" : "0"); split = Standard_True; } - //cout<<"OpenLabel: "<Open(att); - //cout<<"OpenAttribute: "< // Copyright: Matra Datavision 1997 // Version: 0.0 @@ -38,8 +37,8 @@ //======================================================================= static Standard_Integer DFBrowse (Draw_Interpretor& di, - Standard_Integer n, - const char** a) + Standard_Integer n, + const char** a) { if (n<2) return 1; @@ -47,11 +46,10 @@ static Standard_Integer DFBrowse (Draw_Interpretor& di, if (!DDF::GetDF (a[1], DF)) return 1; Handle(DDF_Browser) NewDDFBrowser = new DDF_Browser(DF); - char *name = new char[50]; - if (n == 3) sprintf(name,"browser_%s",a[2]); - else sprintf(name,"browser_%s",a[1]); + TCollection_AsciiString name("browser_"); + name += ((n == 3)? a[2] : a[1]); + Draw::Set (name.ToCString(), NewDDFBrowser); - Draw::Set (name, NewDDFBrowser); TCollection_AsciiString inst1("dftree "); inst1.AssignCat(name); di.Eval(inst1.ToCString()); @@ -67,8 +65,8 @@ static Standard_Integer DFBrowse (Draw_Interpretor& di, //======================================================================= static Standard_Integer DFOpenLabel (Draw_Interpretor& di, - Standard_Integer n, - const char** a) + Standard_Integer n, + const char** a) { if (n < 2) return 1; @@ -78,14 +76,8 @@ static Standard_Integer DFOpenLabel (Draw_Interpretor& di, TDF_Label lab; if (n == 3) TDF_Tool::Label(browser->Data(),a[2],lab); - if (lab.IsNull()) { - TCollection_AsciiString list = browser->OpenRoot(); - di<OpenLabel(lab); - di<OpenRoot() : browser->OpenLabel(lab)); + di<Data(),a[2],lab); - if (lab.IsNull()) { + if (lab.IsNull()) return 1; - } - TCollection_AsciiString list = browser->OpenAttributeList(lab); + TCollection_AsciiString list(browser->OpenAttributeList(lab)); di << list.ToCString(); return 0; } @@ -128,18 +119,16 @@ static Standard_Integer DFOpenAttributeList(Draw_Interpretor& di, //======================================================================= static Standard_Integer DFOpenAttribute (Draw_Interpretor& di, - Standard_Integer n, - const char** a) + Standard_Integer n, + const char** a) { if (n < 3) return 1; Handle(DDF_Browser) browser = Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True)); - Standard_Integer index = atoi(a[2]); - + const Standard_Integer index = atoi(a[2]); TCollection_AsciiString list = browser->OpenAttribute(index); - di< #include #include +#include +#include +#include #include +#include #include #include #include #include +#include //======================================================================= //function : mtmCreate @@ -207,24 +212,18 @@ static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer if ( ! itr.More() ) { di << "ERROR: Attribute #" << num << " not found" << "\n"; return 0; } const Handle(TDF_Attribute)& att = itr.Value(); - if ( att->IsKind(STANDARD_TYPE(TDataStd_TreeNode)) ) + if ( att->IsKind(STANDARD_TYPE(TDataStd_TreeNode)) ) { - Standard_CString type = ""; -// if ( att->ID() == XCAFDoc::ShapeRefGUID() ) type = "Shape Instance Link"; -// else if ( att->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorGen) ) type = "Generic Color Link"; -// else if ( att->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorSurf) ) type = "Surface Color Link"; -// else if ( att->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorCurv) ) type = "Curve Color Link"; -// else return 0; Handle(TDataStd_TreeNode) TN = Handle(TDataStd_TreeNode)::DownCast(att); TCollection_AsciiString ref; if ( TN->HasFather() ) { TDF_Tool::Entry ( TN->Father()->Label(), ref ); - di << type << " ==> " << ref.ToCString(); + di << " ==> " << ref.ToCString(); } else { - di << type << " <== (" << ref.ToCString(); + di << " <== (" << ref.ToCString(); Handle(TDataStd_TreeNode) child = TN->First(); while ( ! child.IsNull() ) { @@ -236,6 +235,13 @@ static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer di << ")"; } } + else if ( att->IsKind(STANDARD_TYPE(TDF_Reference)) ) + { + Handle(TDF_Reference) val = Handle(TDF_Reference)::DownCast ( att ); + TCollection_AsciiString ref; + TDF_Tool::Entry ( val->Get(), ref ); + di << "==> " << ref.ToCString(); + } else if ( att->IsKind(STANDARD_TYPE(TDataStd_Integer)) ) { Handle(TDataStd_Integer) val = Handle(TDataStd_Integer)::DownCast ( att ); @@ -248,13 +254,35 @@ static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer TCollection_AsciiString str ( val->Get() ); di << str.ToCString(); } - else if ( att->IsKind(STANDARD_TYPE(TDataStd_Name)) ) + else if ( att->IsKind(STANDARD_TYPE(TDataStd_Name)) ) { Handle(TDataStd_Name) val = Handle(TDataStd_Name)::DownCast ( att ); TCollection_AsciiString str ( val->Get(), '?' ); di << str.ToCString(); } - else if ( att->IsKind(STANDARD_TYPE(TDataStd_RealArray)) ) + else if ( att->IsKind(STANDARD_TYPE(TDataStd_Comment)) ) + { + Handle(TDataStd_Comment) val = Handle(TDataStd_Comment)::DownCast ( att ); + TCollection_AsciiString str ( val->Get(), '?' ); + di << str.ToCString(); + } + else if ( att->IsKind(STANDARD_TYPE(TDataStd_AsciiString)) ) + { + Handle(TDataStd_AsciiString) val = Handle(TDataStd_AsciiString)::DownCast ( att ); + TCollection_AsciiString str ( val->Get(), '?' ); + di << str.ToCString(); + } + else if ( att->IsKind(STANDARD_TYPE(TDataStd_IntegerArray)) ) + { + Handle(TDataStd_IntegerArray) val = Handle(TDataStd_IntegerArray)::DownCast ( att ); + for ( Standard_Integer j=val->Lower(); j <= val->Upper(); j++ ) + { + if ( j > val->Lower() ) di << ", "; + TCollection_AsciiString str ( val->Value(j) ); + di << str.ToCString(); + } + } + else if ( att->IsKind(STANDARD_TYPE(TDataStd_RealArray)) ) { Handle(TDataStd_RealArray) val = Handle(TDataStd_RealArray)::DownCast ( att ); for ( Standard_Integer j=val->Lower(); j <= val->Upper(); j++ ) @@ -264,7 +292,17 @@ static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer di << str.ToCString(); } } - else if ( att->IsKind(STANDARD_TYPE(TNaming_NamedShape)) ) + else if ( att->IsKind(STANDARD_TYPE(TDataStd_ByteArray)) ) + { + Handle(TDataStd_ByteArray) val = Handle(TDataStd_ByteArray)::DownCast ( att ); + for ( Standard_Integer j=val->Lower(); j <= val->Upper(); j++ ) + { + if ( j > val->Lower() ) di << ", "; + TCollection_AsciiString str ( val->Value(j) ); + di << str.ToCString(); + } + } + else if ( att->IsKind(STANDARD_TYPE(TNaming_NamedShape)) ) { Handle(TNaming_NamedShape) val = Handle(TNaming_NamedShape)::DownCast ( att ); TopoDS_Shape S = val->Get(); diff --git a/src/DrawResources/dftree.tcl b/src/DrawResources/dftree.tcl new file mode 100644 index 0000000000..f10fc26283 --- /dev/null +++ b/src/DrawResources/dftree.tcl @@ -0,0 +1,362 @@ +########################### +# # +# Version 1.4 # +# by SZV # +# # +########################### +# +# Open : double-clic or + +# Close : double-clic or - +# Refresh tree : close top level and re-open +# +# Attributes: +# white : interoperable +# white + c : non interoperable +# X : X Reference +# Red : not yet commited in transaction #0 +# +# + +proc __update { args } { +} + +proc dftree { DDF_Browser } { + + global env + global DFTREE_WINDOWS + global DFTREE_GLOBALS + global $DDF_Browser + + puts $DDF_Browser + + package require Tk + + ## Create images + set DFTREE_GLOBALS(ImageLabel) [DFOpenImage dfb_folder.gif] + set DFTREE_GLOBALS(ImageAttrOther) [DFOpenImage dfb_attribute.gif] + set DFTREE_GLOBALS(ImageAttrNS) [DFOpenImage dfb_attribns.gif] + +## set DFTREE_LabelStyle [tixDisplayStyle imagetext \ +## -font 9x15bold \ +## -background Bisque3 \ +## ] + +## set DFTREE_LabelStyle1 [tixDisplayStyle imagetext \ +## -font 9x15bold \ +## -background Bisque3 \ +## -foreground SeaGreen2 \ +## ] + +## set DFTREE_AttributeStyle [tixDisplayStyle imagetext \ +## -font 9x15 \ +## -background Bisque3 \ +## ] + +## set DFTREE_AttributeStyle1 [tixDisplayStyle imagetext \ +## -font 9x15 \ +## -background Bisque3 \ +## -foreground DarkGreen \ +## ] + +## set DFTREE_AttributeStyle2 [tixDisplayStyle imagetext \ +## -font 9x15 \ +## -background Bisque3 \ +## -foreground Red \ +## ] + + set w .$DDF_Browser + toplevel $w -height 400 -width 700 -background bisque3 + + ######## + # Tree # + ######## + + set tree1 [ttk::treeview $w.tree -show tree] + $tree1 tag bind Label <> [list DFTREE:Tree:Open $DDF_Browser $w] + $tree1 tag configure Label -font 9x15bold -foreground DarkGreen + #$tree1 tag configure Attribute -font 9x15 -background bisque3 + #$tree1 tag configure AttributeList -font 9x15 -background bisque3 + pack $tree1 -expand yes -fill both -padx 4 -pady 4 + + # to see different fonts: /usr/openwin/lib/X11/fonts/misc or xlsfonts? + # 8x13 8x13bold 9x15 9x15bold + # hlist.font 8x13bold + # hlist.gap "15" + # hlist.indent "30" + + set DFTREE_WINDOWS($w,tree) $tree1 + set DFTREE_WINDOWS($w,root) [$tree1 insert {} end \ + -text $DDF_Browser \ + -values "" \ + -tags Label] + + # Here we need to open first node! + + return +} + +############################################################################### +# +# +proc DFTREE:Tree:Open { DDF_Browser w } { + + global DFTREE_WINDOWS + global DFTREE_GLOBALS + global $DDF_Browser + + set df_tree $DFTREE_WINDOWS($w,tree) + set df_node [$df_tree focus] + + #if {$df_node == $DFTREE_WINDOWS($w,root)} { + # This is root + set chdlist [$df_tree children $df_node] + if {$chdlist != {}} { + # The root branch already exists in hlist. + # Clear all its children to force the tree to be updated. + $df_tree delete $chdlist + } + #} + + #update + DFTREE:Tree:Fill $DDF_Browser $df_tree $df_node + return +} + +############################################################################### +# +# +proc DFTREE:Tree:Fill { DDF_Browser df_tree df_node } { + + global DFTREE_GLOBALS + global $DDF_Browser + + set loc [lindex [$df_tree item $df_node -values] 0] + set type [lindex [$df_tree item $df_node -tags] 0] + + switch -glob $type { + + Label { + DFTREE:Tree:UpdateLabel $DDF_Browser $df_tree $df_node $loc + } + + #AttributeList { + # DFTREE:Tree:UpdateAttributeList $DDF_Browser $df_tree $df_node $loc + #} + + default { + } + } + return +} + +############################################################################### +# $df_entry is a label entry, "1:3:2" for example, or "" for root. +# +proc DFTREE:Tree:UpdateLabel { DDF_Browser df_tree df_node df_entry } { + + global DFTREE_GLOBALS + global $DDF_Browser + + foreach fullname [split [DFOpenLabel $DDF_Browser $df_entry] "\\" ] { + FCTREE:Tree:DecodeLabelItem $DDF_Browser $df_tree $df_node $df_entry $fullname + } + return +} + +############################################################################### +# +# +proc DFTREE:Tree:UpdateAttributeList { DDF_Browser df_tree df_node df_entry} { + + global DFTREE_GLOBALS + global $DDF_Browser + + set image_other $DFTREE_GLOBALS(ImageAttrOther) + set image_ns $DFTREE_GLOBALS(ImageAttrNS) + #set xrefimage $DFTREE_GLOBALS(ImageAttrOther) + + # abv: index attributes + set num 0 + set attributes [split [DFOpenAttributeList $DDF_Browser $df_entry ] "\\" ] + set iattributes {} + foreach fullname $attributes { + set num [expr $num + 1] + lappend fullname $num + lappend iattributes $fullname + } + + foreach fullname [lsort $iattributes] { + + # Information first split + set tmplist [split $fullname " "] + set name [lindex $tmplist 0] + set transaction [lindex $tmplist 1] + set valid [lindex $tmplist 2] + set forgotten [lindex $tmplist 3] + set backuped [lindex $tmplist 4] + set maybeopen [lindex $tmplist 5] + + # Name analysis to suppress the map address. + set shortlist [split $name "#"] + set shortname [lindex $shortlist 0] + set index [lindex $shortlist 1] + + # Package analysis to determine the icon type. + #set pk [lindex [split $name _] 0] + set node_img $image_other + #if {$pk == "TDataStd" || $pk == "TNaming"} {set node_img $standardimage} + #if {$pk == "TXRef"} {set node_img $xrefimage} + if {$shortname == "TNaming_NamedShape"} {set node_img $image_ns} + + set textname "$shortname" + +# if { [llength $tmplist] >5 } { set textname [lindex $tmplist 5] } + set textname "$textname [DFGetAttributeValue $DDF_Browser $df_entry [lindex $tmplist 6]]" + + # Transaction analysis + if {$transaction == "0"} { +# set locstyle $DFTREE_AttributeStyle + } else { +# set textname "$textname T=$transaction" +# set locstyle $DFTREE_AttributeStyle1 + } + + # Valid? + if {$valid == "NotValid"} {set textname "$textname $valid"} + + # Forgotten? + if {$forgotten == "Forgotten"} {set textname "$textname $forgotten"} + + # Backuped? + if {$backuped == "Backuped"} {set textname "$textname $backuped"} + + set df_new [$df_tree insert $df_node end \ + -text $textname -image $node_img -tags Attribute] + + if {$maybeopen == "1"} { + $df_tree item $df_new -open true + DFTREE:Tree:UpdateAttribute $DDF_Browser $df_tree $df_new $index + } + } +} + +############################################################################### +# $loc is always the attribute index +# +proc DFTREE:Tree:UpdateAttribute { DDF_Browser df_tree df_node a_index } { + + global DFTREE_GLOBALS + global $DDF_Browser + + set tmplist [split [DFOpenAttribute $DDF_Browser $a_index ] "\\"] + + # Failed or not? + if {[lindex $tmplist 0] == "Failed"} { +## set locstyle $DFTREE_AttributeStyle2 + } else { +## set locstyle $DFTREE_AttributeStyle + } + + foreach name $tmplist { + $df_tree insert $df_node end -text $name -tags Terminal + } + return +} + +############################################################################### +# item: +# "Entry Name=TheNameIfExists Modified|NotModified 0|1" +proc FCTREE:Tree:DecodeLabelItem { DDF_Browser df_tree df_node df_entry labelItem} { + + global DFTREE_GLOBALS + global $DDF_Browser + + set tmplist [split $labelItem " " ] + set labname [lindex $tmplist 0] + + set textname "$labname" + + if {$labname == "AttributeList"} { + + # Attribute List + # -------------- + + #set modified [lindex $tmplist 1] + + # Modified or not? + #if {$modified == "Modified"} { + # set textname "$textname $modified" +## set locstyle $DFTREE_AttributeStyle1 + #} else { +## set locstyle $DFTREE_AttributeStyle + #} + + #set df_new [$df_tree insert $df_node end \ + # -text $textname \ + # -image $DFTREE_GLOBALS(ImageAttrList) \ + # -tags AttributeList] + + #$df_tree item $df_new -open true + + DFTREE:Tree:UpdateAttributeList $DDF_Browser $df_tree $df_node $df_entry + + } else { + + # Sub-label(s) + # ------------ + + set name [lindex $tmplist 1] + set modified [lindex $tmplist 2] + set maybeopen [lindex $tmplist 3] + + # Name? + set ll [expr [string length $name] -2] + if {$ll > 0} { + set textname "$textname [string range $name 1 $ll]" + } + + # Modified or not? + if {$modified == "Modified"} { + set textname "$textname $modified" + } + + set df_new [$df_tree insert $df_node end \ + -text $textname \ + -image $DFTREE_GLOBALS(ImageLabel) \ + -values $labname \ + -tags Label] + + if {$maybeopen == "1"} { + $df_tree item $df_new -open true + } + + DFTREE:Tree:UpdateLabel $DDF_Browser $df_tree $df_new $labname + } +} + +############################################################################### +# +# +proc DFGetAttributeValue { DDF_Browser lab index } { + + global $DDF_Browser; # necessary for DRAW command to see the browser + + if {[catch "XAttributeValue $DDF_Browser $lab $index" ret]} { + return "" + } + if {"$ret" == ""} { return "" } + return "\[$ret\]" +} + +############################################################################### +# +# +proc DFOpenImage { img } { + + global env + + if {[catch "image create photo -file $env(DRAWHOME)/$img" ret]} { + return "" + } + return $ret +} diff --git a/src/StdResource/dftree.tcl b/src/StdResource/dftree.tcl index a9835e712a..e69de29bb2 100755 --- a/src/StdResource/dftree.tcl +++ b/src/StdResource/dftree.tcl @@ -1,541 +0,0 @@ -########################### -# # -# Version 1.3 # -# by FID & YAN # -# # -########################### -# -# Open : double-clic or + -# Close : double-clic or - -# Refresh tree : close top level and re-open -# -# Attributes: -# white : interoperable -# white + c : non interoperable -# X : X Reference -# Red : not yet commited in transaction #0 -# -# - -proc __update { args } { -} - -proc dftree { DDF_Browser } { - - global DFTREE_WINDOWS - global DFTREE_LabelStyle - global DFTREE_LabelStyle1 - global DFTREE_AttributeStyle - global DFTREE_AttributeStyle1 - global DFTREE_AttributeStyle2 - - global $DDF_Browser -## global $DDF_Browser - puts $DDF_Browser - - package require Tix - #tixPref:InitFontSet:14Point - - set DFTREE_LabelStyle [tixDisplayStyle imagetext \ - -font 9x15bold \ - -background Bisque3 \ - ] - - set DFTREE_LabelStyle1 [tixDisplayStyle imagetext \ - -font 9x15bold \ - -background Bisque3 \ - -foreground SeaGreen2 \ - ] - - set DFTREE_AttributeStyle [tixDisplayStyle imagetext \ - -font 9x15 \ - -background Bisque3 \ - ] - - set DFTREE_AttributeStyle1 [tixDisplayStyle imagetext \ - -font 9x15 \ - -background Bisque3 \ - -foreground DarkGreen \ - ] - - set DFTREE_AttributeStyle2 [tixDisplayStyle imagetext \ - -font 9x15 \ - -background Bisque3 \ - -foreground Red \ - ] - - set w .$DDF_Browser - toplevel $w - - set top [frame $w.thu -bd 1 -relief raised -background Bisque3] - - ################ - # Paned Window # - ################ - set p [tixPanedWindow $top.p -orient horizontal -height 400 -width 700] - pack $p -expand yes -fill both -padx 4 -pady 4 - - DFTREE:Tree:InitTreePanel $DDF_Browser $w $p -# DFTREE:Tree:InitTextPanel $DDF_Browser $w $p - - tixForm $top -left 2 -top 2 -right %99 -bottom %99 - - return -} - -############################################################################### -# -# -proc DFTREE:Tree:InitTreePanel { DDF_Browser w p } { - global DFTREE_WINDOWS - global $DDF_Browser - - ######## - # Tree # - ######## - - set p1 [$p add pane1 -expand 1 -size 700] ; $p1 config -relief flat - set tree [tixTree $p1.tree \ - -opencmd [list DFTREE:Tree:Open $DDF_Browser $w] \ - -options { \ - hlist.separator "^" \ - hlist.font 9x15bold \ - hlist.background Bisque3 \ - hlist.foreground Black \ - } ] - pack $p1.tree -expand yes -fill both -padx 4 -pady 4 - - # -browsecmd DFTREE:Tree:BrowseCmd - # Cette option peut etre ajoutee a la commande tixTree, - # mais elle declanche l'appel a la procedure a chaque clic , - # double-clic, voire a chaque appui puis relachement de souris!!! - - # to see different fonts: /usr/openwin/lib/X11/fonts/misc or xlsfonts? - # 8x13 8x13bold 9x15 9x15bold - # hlist.font 8x13bold - # hlist.gap "15" - # hlist.indent "30" - - set DFTREE_WINDOWS($w,NAV,tree) $tree - set DFTREE_WINDOWS($w,NAV,hlist) [$tree subwidget hlist] - $DFTREE_WINDOWS($w,NAV,hlist) add ^ \ - -text $DDF_Browser \ - -data [list $DDF_Browser DataFramework] - $DFTREE_WINDOWS($w,NAV,tree) setmode ^ open -} - -############################################################################### -# -# -proc DFTREE:Tree:InitTextPanel { DDF_Browser w p } { - global DFTREE_WINDOWS - global $DDF_Browser - - ######## - # Text # - ######## - set p2 [$p add pane2 -expand 4 -size 400] ; $p2 config -relief flat - tixScrolledText $p2.st - pack $p2.st -expand yes -fill both -padx 4 -pady 4 - - set DFTREE_WINDOWS($w,NAV,text) [$p2.st subwidget text] - - - - $DFTREE_WINDOWS($w,NAV,text) insert end " Welcome to the QDF browser (Rev #.#)\n" - $DFTREE_WINDOWS($w,NAV,text) insert end "--------------------------------------\n\n" - $DFTREE_WINDOWS($w,NAV,text) insert end "This browser is an easy to use prototype made with Tix technology. We hope it will be usefull for understanding and debugging QDF.\n" - $DFTREE_WINDOWS($w,NAV,text) insert end "\t\t\t\tFID & YAN" -} - -############################################################################### -# -# -proc DFTREE:Tree:BrowseCmd { dir } { - puts "Hello $dir !" -} -############################################################################### -# Se positionne sur l'entry pere et update les fenetres. -# -proc DFTREE:Tree:Up { w } { - global DFTREE_WINDOWS - global DFTREE_GLOBALS - #puts "DFTREE:Tree:Up" - - if { [set here [$DFTREE_WINDOWS($w,NAV,hlist) info anchor]] != {} } { - if { [set up [$DFTREE_WINDOWS($w,NAV,hlist) info parent $here]] != {} } { - DFTREE:Tree:ShowUp $w $up - set DFTREE_GLOBALS(CWD) [lindex [$DFTREE_WINDOWS($w,NAV,hlist) info data $up] 0] - } - } - return -} -############################################################################### -# Se positionne sur l'entry up sans update (History) -# -proc DFTREE:Tree:ShowUp { w dir } { - global DFTREE_WINDOWS - #puts "DFTREE:Tree:ShowUp" - - $DFTREE_WINDOWS($w,NAV,hlist) anchor clear - $DFTREE_WINDOWS($w,NAV,hlist) anchor set $dir - $DFTREE_WINDOWS($w,NAV,hlist) selection clear - $DFTREE_WINDOWS($w,NAV,hlist) selection set $dir - $DFTREE_WINDOWS($w,NAV,hlist) see $dir - return -} -############################################################################### -# -# -proc DFTREE:Tree:Open { DDF_Browser w dir} { - global DFTREE_WINDOWS - global $DDF_Browser - #puts "DFTREE:Tree:Open" - - if {$dir == "^"} { - # This is root - if {[$DFTREE_WINDOWS($w,NAV,hlist) info children $dir] != {}} { - # The root branch already exists in hlist. - # Clear all its children to force the tree to be updated. - foreach kid [$DFTREE_WINDOWS($w,NAV,hlist) info children $dir] { - $DFTREE_WINDOWS($w,NAV,hlist) delete entry $kid - } - } - } - - if {[$DFTREE_WINDOWS($w,NAV,hlist) info children $dir] != {}} { - # The branch exists in hlist. - foreach kid [$DFTREE_WINDOWS($w,NAV,hlist) info children $dir] { - $DFTREE_WINDOWS($w,NAV,hlist) show entry $kid - } - set data [$DFTREE_WINDOWS($w,NAV,hlist) info data $dir] - set loc [lindex $data 0] - } else { - # The branch is unknown. - tixBusy $w on - update - DFTREE:Tree:Fill $DDF_Browser $w $dir - tixBusy $w off - } - return -} -############################################################################### -# -# -proc DFTREE:Tree:Fill { DDF_Browser w dir } { - global DFTREE_WINDOWS - global DFTREE_GLOBALS - global $DDF_Browser - #puts "DFTREE:Tree:Fill" - - set data [$DFTREE_WINDOWS($w,NAV,hlist) info data $dir] - set loc [lindex $data 0] - set type [lindex $data 1] - - #puts "=====================" - #puts "Type $type" - #puts "Window $w" - #puts "Loc $loc" - #puts "Dir $dir" - switch -glob $type { - - DataFramework { - DFTREE:Tree:UpdateDataFramework $DDF_Browser $w $loc $dir - } - - Label { - DFTREE:Tree:UpdateLabel $DDF_Browser $w $loc $dir - } - - AttributeList { - set lab [lindex $data 2] - DFTREE:Tree:UpdateAttributeList $DDF_Browser $w $loc $dir $lab - } - - Attribute { - DFTREE:Tree:UpdateAttribute $DDF_Browser $w $loc $dir - } - - terminal { - DFTREE:Tree:terminal $DDF_Browser $w $loc $dir - } - - default { - puts "type non reconnu" - } - } - return -} -############################################################################### -# ici dir = ^ -# -proc DFTREE:Tree:UpdateDataFramework { DDF_Browser w loc dir } { - global DFTREE_WINDOWS - global $DDF_Browser - global DFTREE_LabelStyle - global DFTREE_LabelStyle1 - - set litm {} - - foreach fullname [split [DFOpenLabel $DDF_Browser ""] "\\" ] { - FCTREE:Tree:DecodeLabelItem $DDF_Browser $w $loc $dir $fullname - } - - return -} -############################################################################### -# $loc is a label entry, "1.3.2" for exemple. -# -proc DFTREE:Tree:UpdateLabel { DDF_Browser w loc dir } { - global DFTREE_WINDOWS - global $DDF_Browser - global DFTREE_LabelStyle - global DFTREE_LabelStyle1 - global DFTREE_AttributeStyle - global DFTREE_AttributeStyle1 - - set litm {} - foreach fullname [split [DFOpenLabel $DDF_Browser $loc ] "\\" ] { - FCTREE:Tree:DecodeLabelItem $DDF_Browser $w $loc $dir $fullname - } - return -} -############################################################################### -# -# -proc DFTREE:Tree:UpdateAttributeList { DDF_Browser w loc dir lab} { - global DFTREE_WINDOWS - global $DDF_Browser - global DFTREE_AttributeStyle - global DFTREE_AttributeStyle1 - - set litm {} - set standardimage [tix getimage srcfile] - set otherimage [tix getimage file] - set xrefimage [tix getimage cross] - - # abv: index attributes - set num 0 - set attributes [split [DFOpenAttributeList $DDF_Browser $lab ] "\\" ] - set iattributes {} - foreach fullname $attributes { - set num [expr $num + 1] - lappend fullname $num - lappend iattributes $fullname - } - foreach fullname [lsort $iattributes] { - - # Information first split - set tmplist [split $fullname " "] - set name [lindex $tmplist 0] - set transaction [lindex $tmplist 1] - set valid [lindex $tmplist 2] - set forgotten [lindex $tmplist 3] - set backuped [lindex $tmplist 4] - set maybeopen [lindex $tmplist 5] - - # Package analysis to determine the icon type. - set pk [lindex [split $name _] 0] - set image $otherimage - if {$pk == "TDataStd" || $pk == "TNaming"} {set image $standardimage} - if {$pk == "TXRef"} {set image $xrefimage} - - # Name analysis to suppress the map address. - set shortlist [split $name "#"] - set shortname [lindex $shortlist 0] - set index [lindex $shortlist 1] - - set textname "$shortname" - -# if { [llength $tmplist] >5 } { set textname [lindex $tmplist 5] } - set textname "$textname [DFGetAttributeValue $DDF_Browser $lab [lindex $tmplist 6]]" - - # Transaction analysis - if {$transaction == "0"} { - set locstyle $DFTREE_AttributeStyle - } else { -# set textname "$textname T=$transaction" - set locstyle $DFTREE_AttributeStyle1 - } - - # Valid? - if {$valid == "NotValid"} {set textname "$textname $valid"} - - # Forgotten? - if {$forgotten == "Forgotten"} {set textname "$textname $forgotten"} - - # Backuped? - if {$backuped == "Backuped"} {set textname "$textname $backuped"} - - - $DFTREE_WINDOWS($w,NAV,hlist) add ${dir}^${name} \ - -itemtype imagetext \ - -text $textname \ - -image $image \ - -style $locstyle \ - -data [list ${index} Attribute] - if {$maybeopen == "1"} { - $DFTREE_WINDOWS($w,NAV,tree) setmode ${dir}^${name} open - } - lappend litm [list $name $image] - } - return -} -############################################################################### -# $loc is always the attribute index -# -proc DFTREE:Tree:UpdateAttribute { DDF_Browser w loc dir } { - global DFTREE_WINDOWS - global $DDF_Browser - global DFTREE_AttributeStyle - global DFTREE_AttributeStyle1 - global DFTREE_AttributeStyle2 - - set litm {} - set image [tix getimage minimize] - set tmplist [split [DFOpenAttribute $DDF_Browser $loc ] "\\"] - - # Failed or not? - if {[lindex $tmplist 0] == "Failed"} { - set locstyle $DFTREE_AttributeStyle2 - } else { - set locstyle $DFTREE_AttributeStyle - } - - foreach name $tmplist { - $DFTREE_WINDOWS($w,NAV,hlist) add ${dir}^${name} \ - -itemtype imagetext \ - -text $name \ - -image $image \ - -style $locstyle \ - -data [list ${loc}:${name} terminal] \ - -state disabled - #$DFTREE_WINDOWS($w,NAV,tree) setmode ${dir}^${name} open - lappend litm [list $name $image] - } - return -} -############################################################################### -# item: -# "Entry Name=LeNomSIlExiste Modified|NotModified 0|1" -proc FCTREE:Tree:DecodeLabelItem { DDF_Browser w loc dir labelItem} { - global DFTREE_WINDOWS - global $DDF_Browser - global DFTREE_LabelStyle - global DFTREE_LabelStyle1 - global DFTREE_AttributeStyle - global DFTREE_AttributeStyle1 - - set image [tix getimage folder] - - set tmplist [split $labelItem " " ] - set labentry [lindex $tmplist 0] - set name [lindex $tmplist 1] - set modified [lindex $tmplist 2] - set maybeopen [lindex $tmplist 3] - - set textname "$labentry" - - if {$labentry == "AttributeList"} { - # Attribute List - # -------------- - - set modified [lindex $tmplist 1] - - # Modified or not? - if {$modified == "Modified"} { - set textname "$textname $modified" - set locstyle $DFTREE_AttributeStyle1 - } else { - set locstyle $DFTREE_AttributeStyle - } - - set image [tix getimage textfile] - $DFTREE_WINDOWS($w,NAV,hlist) add ${dir}^$labentry \ - -itemtype imagetext \ - -text $textname \ - -image $image \ - -style $locstyle \ - -data [list $labentry AttributeList $loc] - $DFTREE_WINDOWS($w,NAV,tree) setmode ${dir}^$labentry open - lappend litm [list $labentry $image] - set image [tix getimage folder] - - } else { - # Sub-label(s) - # ------------ - - # Name? - set ll [expr [string length $name] -2] - if {$ll > 0} { - set textname "$textname [string range $name 1 $ll]" - } - - # Modified or not? - if {$modified == "Modified"} { - set textname "$textname $modified" - set locstyle $DFTREE_LabelStyle1 - } else { - set locstyle $DFTREE_LabelStyle - } - - $DFTREE_WINDOWS($w,NAV,hlist) add ${dir}^$labentry \ - -itemtype imagetext \ - -text $textname \ - -image $image \ - -style $locstyle \ - -data [list $labentry Label] - if {$maybeopen == "1"} { - $DFTREE_WINDOWS($w,NAV,tree) setmode ${dir}^$labentry open - } - lappend litm [list $labentry $image] - } -} -############################################################################### -# -# -proc DFTREE:Tree:terminal { DDF_Browser w loc dir } { - global DFTREE_WINDOWS - global $DDF_Browser - return -} -############################################################################### -# loc est une adresse de label? -# -proc DFTREE:Tree:DisplayAttribute { DDF_Browser w loc dir } { - global DFTREE_WINDOWS - global $DDF_Browser - - return -} -############################################################################### -# imprime tout ce qu'il y a dans hli ( Hlist ) -# -proc wokDBG { {root {}} } { - global DFTREE_GLOBALS - global DFTREE_WINDOWS - set w $DFTREE_GLOBALS(toplevel) - set hli $DFTREE_WINDOWS($w,NAV,hlist) - foreach c [$hli info children $root] { - puts "$c : data <[$hli info data $c]>" - wokDBG $c - } - return -} - -proc DFGetAttributeValue {browser lab index} { - global $browser; # necessary for DRAW command to see the browser -#puts "$lab $index" -# set names [split $dir ^] -# set len [expr [llength $names] -1] -# set lab [lindex $names [expr $len - 2]] -# set num [lindex $names $len] -# regexp {browser_(.*)} $browser whole doc -# XSAttributeValue browser_D a b - if {[catch "XAttributeValue $browser $lab $index" ret]} { - return "" - } - if {"$ret" == ""} { return "" } - return "\[$ret\]" -} - diff --git a/src/XDEDRAW/XDEDRAW.cxx b/src/XDEDRAW/XDEDRAW.cxx index f46d2f1c70..b74266b862 100755 --- a/src/XDEDRAW/XDEDRAW.cxx +++ b/src/XDEDRAW/XDEDRAW.cxx @@ -28,14 +28,19 @@ #include #include #include +#include #include #include #include #include #include #include +#include +#include #include +#include #include +#include #include #include #include @@ -527,7 +532,7 @@ static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer const Handle(TDF_Attribute)& att = itr.Value(); if ( att->IsKind(STANDARD_TYPE(TDataStd_TreeNode)) ) { - Standard_CString type; + Standard_CString type = ""; if ( att->ID() == XCAFDoc::ShapeRefGUID() ) type = "Shape Instance Link"; else if ( att->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorGen) ) type = "Generic Color Link"; else if ( att->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorSurf) ) type = "Surface Color Link"; @@ -535,7 +540,6 @@ static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer else if ( att->ID() == XCAFDoc::DimTolRefGUID() ) type = "DGT Link"; else if ( att->ID() == XCAFDoc::DatumRefGUID() ) type = "Datum Link"; else if ( att->ID() == XCAFDoc::MaterialRefGUID() ) type = "Material Link"; - else return 0; Handle(TDataStd_TreeNode) TN = Handle(TDataStd_TreeNode)::DownCast(att); TCollection_AsciiString ref; if ( TN->HasFather() ) { @@ -546,14 +550,20 @@ static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer di << type << " <== (" << ref.ToCString(); Handle(TDataStd_TreeNode) child = TN->First(); while ( ! child.IsNull() ) { - TDF_Tool::Entry ( child->Label(), ref ); - if ( child != TN->First() ) di << ", "; - di << ref.ToCString(); - child = child->Next(); + TDF_Tool::Entry ( child->Label(), ref ); + if ( child != TN->First() ) di << ", "; + di << ref.ToCString(); + child = child->Next(); } di << ")"; } } + else if ( att->IsKind(STANDARD_TYPE(TDF_Reference)) ) { + Handle(TDF_Reference) val = Handle(TDF_Reference)::DownCast ( att ); + TCollection_AsciiString ref; + TDF_Tool::Entry ( val->Get(), ref ); + di << "==> " << ref.ToCString(); + } else if ( att->IsKind(STANDARD_TYPE(TDataStd_Integer)) ) { Handle(TDataStd_Integer) val = Handle(TDataStd_Integer)::DownCast ( att ); TCollection_AsciiString str ( val->Get() ); @@ -564,6 +574,51 @@ static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer TCollection_AsciiString str ( val->Get() ); di << str.ToCString(); } + else if ( att->IsKind(STANDARD_TYPE(TDataStd_Name)) ) { + Handle(TDataStd_Name) val = Handle(TDataStd_Name)::DownCast ( att ); + TCollection_AsciiString str ( val->Get(), '?' ); + di << str.ToCString(); + } + else if ( att->IsKind(STANDARD_TYPE(TDataStd_Comment)) ) { + Handle(TDataStd_Comment) val = Handle(TDataStd_Comment)::DownCast ( att ); + TCollection_AsciiString str ( val->Get(), '?' ); + di << str.ToCString(); + } + else if ( att->IsKind(STANDARD_TYPE(TDataStd_AsciiString)) ) { + Handle(TDataStd_AsciiString) val = Handle(TDataStd_AsciiString)::DownCast ( att ); + TCollection_AsciiString str ( val->Get(), '?' ); + di << str.ToCString(); + } + else if ( att->IsKind(STANDARD_TYPE(TDataStd_IntegerArray)) ) { + Handle(TDataStd_IntegerArray) val = Handle(TDataStd_IntegerArray)::DownCast ( att ); + for ( Standard_Integer j=val->Lower(); j <= val->Upper(); j++ ) { + if ( j > val->Lower() ) di << ", "; + TCollection_AsciiString str ( val->Value(j) ); + di << str.ToCString(); + } + } + else if ( att->IsKind(STANDARD_TYPE(TDataStd_RealArray)) ) { + Handle(TDataStd_RealArray) val = Handle(TDataStd_RealArray)::DownCast ( att ); + for ( Standard_Integer j=val->Lower(); j <= val->Upper(); j++ ) { + if ( j > val->Lower() ) di << ", "; + TCollection_AsciiString str ( val->Value(j) ); + di << str.ToCString(); + } + } + else if ( att->IsKind(STANDARD_TYPE(TDataStd_ByteArray)) ) { + Handle(TDataStd_ByteArray) val = Handle(TDataStd_ByteArray)::DownCast ( att ); + for ( Standard_Integer j=val->Lower(); j <= val->Upper(); j++ ) { + if ( j > val->Lower() ) di << ", "; + TCollection_AsciiString str ( val->Value(j) ); + di << str.ToCString(); + } + } + else if ( att->IsKind(STANDARD_TYPE(TNaming_NamedShape)) ) { + Handle(TNaming_NamedShape) val = Handle(TNaming_NamedShape)::DownCast ( att ); + TopoDS_Shape S = val->Get(); + di << S.TShape()->DynamicType()->Name(); + if ( ! S.Location().IsIdentity() ) di << "(located)"; + } else if ( att->IsKind(STANDARD_TYPE(XCAFDoc_Volume)) ) { Handle(XCAFDoc_Volume) val = Handle(XCAFDoc_Volume)::DownCast ( att ); TCollection_AsciiString str ( val->Get() ); @@ -585,25 +640,6 @@ static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer di << myCentroid.Z(); di << ")"; } - else if ( att->IsKind(STANDARD_TYPE(TDataStd_Name)) ) { - Handle(TDataStd_Name) val = Handle(TDataStd_Name)::DownCast ( att ); - TCollection_AsciiString str ( val->Get(), '?' ); - di << str.ToCString(); - } - else if ( att->IsKind(STANDARD_TYPE(TDataStd_RealArray)) ) { - Handle(TDataStd_RealArray) val = Handle(TDataStd_RealArray)::DownCast ( att ); - for ( Standard_Integer j=val->Lower(); j <= val->Upper(); j++ ) { - if ( j > val->Lower() ) di << ", "; - TCollection_AsciiString str ( val->Value(j) ); - di << str.ToCString(); - } - } - else if ( att->IsKind(STANDARD_TYPE(TNaming_NamedShape)) ) { - Handle(TNaming_NamedShape) val = Handle(TNaming_NamedShape)::DownCast ( att ); - TopoDS_Shape S = val->Get(); - di << S.TShape()->DynamicType()->Name(); - if ( ! S.Location().IsIdentity() ) di << "(located)"; - } else if ( att->IsKind(STANDARD_TYPE(TDataStd_UAttribute)) ) { if ( att->ID() == XCAFDoc::AssemblyGUID() ) di << "is assembly"; if ( att->ID() == XCAFDoc::InvisibleGUID() ) di << "invisible";