From: ouv Date: Wed, 21 May 2014 11:55:19 +0000 (+0400) Subject: GUITHARE issue 0002109: External 20696 2D 3D surfaces X-Git-Tag: CTH_1_10_a~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=141663d84cb790a038b3232346fcfe5c053651f3;p=modules%2Fgui.git GUITHARE issue 0002109: External 20696 2D 3D surfaces 5) Color scale 6) Legends --- diff --git a/adm_local/win32/GUI_SRC.sln b/adm_local/win32/GUI_SRC.sln index 5e5b2da57..7e8dbf57f 100644 --- a/adm_local/win32/GUI_SRC.sln +++ b/adm_local/win32/GUI_SRC.sln @@ -3,77 +3,77 @@ Microsoft Visual Studio Solution File, Format Version 10.00 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "All", "All.vcproj", "{0D811160-3A03-4C59-9610-498786BAFECE}" ProjectSection(ProjectDependencies) = postProject {06CA8800-62E7-4FA8-BA7B-3607F27491B8} = {06CA8800-62E7-4FA8-BA7B-3607F27491B8} + {06CA8800-62E7-4FA8-BA7B-3607F27491B8} = {06CA8800-62E7-4FA8-BA7B-3607F27491B8} + {7DB13706-F0ED-4EA8-BE14-E4D62D500C67} = {7DB13706-F0ED-4EA8-BE14-E4D62D500C67} + {7DB13706-F0ED-4EA8-BE14-E4D62D500C67} = {7DB13706-F0ED-4EA8-BE14-E4D62D500C67} + {EBCDC006-A873-4DA9-9CA6-B6BE320C0DFD} = {EBCDC006-A873-4DA9-9CA6-B6BE320C0DFD} + {EBCDC006-A873-4DA9-9CA6-B6BE320C0DFD} = {EBCDC006-A873-4DA9-9CA6-B6BE320C0DFD} + {36CA5C15-A7E6-4451-AE8E-8AD61754F970} = {36CA5C15-A7E6-4451-AE8E-8AD61754F970} + {36CA5C15-A7E6-4451-AE8E-8AD61754F970} = {36CA5C15-A7E6-4451-AE8E-8AD61754F970} + {37FA9C33-4512-4833-A4A7-CCF490ADD732} = {37FA9C33-4512-4833-A4A7-CCF490ADD732} + {37FA9C33-4512-4833-A4A7-CCF490ADD732} = {37FA9C33-4512-4833-A4A7-CCF490ADD732} + {4B9BF133-1E25-4C6E-9233-651833F22313} = {4B9BF133-1E25-4C6E-9233-651833F22313} + {4B9BF133-1E25-4C6E-9233-651833F22313} = {4B9BF133-1E25-4C6E-9233-651833F22313} + {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} + {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} {DB53E05E-3E2E-460D-8B77-9B339FA3DE59} = {DB53E05E-3E2E-460D-8B77-9B339FA3DE59} - {AE9A31F5-1301-4E6D-91A3-E78DF4ABF0EA} = {AE9A31F5-1301-4E6D-91A3-E78DF4ABF0EA} - {AE9A31F5-1301-4E6D-91A3-E78DF4ABF0EA} = {AE9A31F5-1301-4E6D-91A3-E78DF4ABF0EA} - {447B72EF-4B7D-4200-A92E-BDE789576117} = {447B72EF-4B7D-4200-A92E-BDE789576117} - {447B72EF-4B7D-4200-A92E-BDE789576117} = {447B72EF-4B7D-4200-A92E-BDE789576117} - {9EA751D5-767C-45CC-AA52-283E69308EB7} = {9EA751D5-767C-45CC-AA52-283E69308EB7} - {9EA751D5-767C-45CC-AA52-283E69308EB7} = {9EA751D5-767C-45CC-AA52-283E69308EB7} - {D5E571BF-0C2E-4513-8BF0-A7A54E4EA973} = {D5E571BF-0C2E-4513-8BF0-A7A54E4EA973} - {D5E571BF-0C2E-4513-8BF0-A7A54E4EA973} = {D5E571BF-0C2E-4513-8BF0-A7A54E4EA973} - {D2CA8DB5-A2DE-4EF9-B967-0F639736469F} = {D2CA8DB5-A2DE-4EF9-B967-0F639736469F} - {D2CA8DB5-A2DE-4EF9-B967-0F639736469F} = {D2CA8DB5-A2DE-4EF9-B967-0F639736469F} - {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} = {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} - {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} = {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} - {6755FAA7-967A-4D23-966D-DE4F66234913} = {6755FAA7-967A-4D23-966D-DE4F66234913} - {6755FAA7-967A-4D23-966D-DE4F66234913} = {6755FAA7-967A-4D23-966D-DE4F66234913} - {29831E95-B38D-4460-A46F-A4A4E1EE3941} = {29831E95-B38D-4460-A46F-A4A4E1EE3941} - {29831E95-B38D-4460-A46F-A4A4E1EE3941} = {29831E95-B38D-4460-A46F-A4A4E1EE3941} - {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} - {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} - {C3A1EE8B-C548-4A37-B49A-D322128EE161} = {C3A1EE8B-C548-4A37-B49A-D322128EE161} - {C3A1EE8B-C548-4A37-B49A-D322128EE161} = {C3A1EE8B-C548-4A37-B49A-D322128EE161} {C8FB7D64-0A82-4588-8D27-2B7CC6C2EA85} = {C8FB7D64-0A82-4588-8D27-2B7CC6C2EA85} {C8FB7D64-0A82-4588-8D27-2B7CC6C2EA85} = {C8FB7D64-0A82-4588-8D27-2B7CC6C2EA85} - {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} - {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} - {4B9BF133-1E25-4C6E-9233-651833F22313} = {4B9BF133-1E25-4C6E-9233-651833F22313} - {4B9BF133-1E25-4C6E-9233-651833F22313} = {4B9BF133-1E25-4C6E-9233-651833F22313} - {37FA9C33-4512-4833-A4A7-CCF490ADD732} = {37FA9C33-4512-4833-A4A7-CCF490ADD732} - {37FA9C33-4512-4833-A4A7-CCF490ADD732} = {37FA9C33-4512-4833-A4A7-CCF490ADD732} - {36CA5C15-A7E6-4451-AE8E-8AD61754F970} = {36CA5C15-A7E6-4451-AE8E-8AD61754F970} - {36CA5C15-A7E6-4451-AE8E-8AD61754F970} = {36CA5C15-A7E6-4451-AE8E-8AD61754F970} - {EBCDC006-A873-4DA9-9CA6-B6BE320C0DFD} = {EBCDC006-A873-4DA9-9CA6-B6BE320C0DFD} - {EBCDC006-A873-4DA9-9CA6-B6BE320C0DFD} = {EBCDC006-A873-4DA9-9CA6-B6BE320C0DFD} - {7DB13706-F0ED-4EA8-BE14-E4D62D500C67} = {7DB13706-F0ED-4EA8-BE14-E4D62D500C67} - {7DB13706-F0ED-4EA8-BE14-E4D62D500C67} = {7DB13706-F0ED-4EA8-BE14-E4D62D500C67} - {06CA8800-62E7-4FA8-BA7B-3607F27491B8} = {06CA8800-62E7-4FA8-BA7B-3607F27491B8} + {C3A1EE8B-C548-4A37-B49A-D322128EE161} = {C3A1EE8B-C548-4A37-B49A-D322128EE161} + {C3A1EE8B-C548-4A37-B49A-D322128EE161} = {C3A1EE8B-C548-4A37-B49A-D322128EE161} + {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} + {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} + {29831E95-B38D-4460-A46F-A4A4E1EE3941} = {29831E95-B38D-4460-A46F-A4A4E1EE3941} + {29831E95-B38D-4460-A46F-A4A4E1EE3941} = {29831E95-B38D-4460-A46F-A4A4E1EE3941} + {6755FAA7-967A-4D23-966D-DE4F66234913} = {6755FAA7-967A-4D23-966D-DE4F66234913} + {6755FAA7-967A-4D23-966D-DE4F66234913} = {6755FAA7-967A-4D23-966D-DE4F66234913} + {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} = {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} + {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} = {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} + {D2CA8DB5-A2DE-4EF9-B967-0F639736469F} = {D2CA8DB5-A2DE-4EF9-B967-0F639736469F} + {D2CA8DB5-A2DE-4EF9-B967-0F639736469F} = {D2CA8DB5-A2DE-4EF9-B967-0F639736469F} + {D5E571BF-0C2E-4513-8BF0-A7A54E4EA973} = {D5E571BF-0C2E-4513-8BF0-A7A54E4EA973} + {D5E571BF-0C2E-4513-8BF0-A7A54E4EA973} = {D5E571BF-0C2E-4513-8BF0-A7A54E4EA973} + {9EA751D5-767C-45CC-AA52-283E69308EB7} = {9EA751D5-767C-45CC-AA52-283E69308EB7} + {9EA751D5-767C-45CC-AA52-283E69308EB7} = {9EA751D5-767C-45CC-AA52-283E69308EB7} + {447B72EF-4B7D-4200-A92E-BDE789576117} = {447B72EF-4B7D-4200-A92E-BDE789576117} + {447B72EF-4B7D-4200-A92E-BDE789576117} = {447B72EF-4B7D-4200-A92E-BDE789576117} + {AE9A31F5-1301-4E6D-91A3-E78DF4ABF0EA} = {AE9A31F5-1301-4E6D-91A3-E78DF4ABF0EA} + {AE9A31F5-1301-4E6D-91A3-E78DF4ABF0EA} = {AE9A31F5-1301-4E6D-91A3-E78DF4ABF0EA} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CAF", "CAF.vcproj", "{EBCDC006-A873-4DA9-9CA6-B6BE320C0DFD}" ProjectSection(ProjectDependencies) = postProject - {29831E95-B38D-4460-A46F-A4A4E1EE3941} = {29831E95-B38D-4460-A46F-A4A4E1EE3941} - {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} + {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} + {29831E95-B38D-4460-A46F-A4A4E1EE3941} = {29831E95-B38D-4460-A46F-A4A4E1EE3941} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CAM", "CAM.vcproj", "{37FA9C33-4512-4833-A4A7-CCF490ADD732}" ProjectSection(ProjectDependencies) = postProject - {29831E95-B38D-4460-A46F-A4A4E1EE3941} = {29831E95-B38D-4460-A46F-A4A4E1EE3941} - {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} + {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} + {29831E95-B38D-4460-A46F-A4A4E1EE3941} = {29831E95-B38D-4460-A46F-A4A4E1EE3941} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Event", "Event.vcproj", "{9EA751D5-767C-45CC-AA52-283E69308EB7}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GLViewer", "GLViewer.vcproj", "{4B9BF133-1E25-4C6E-9233-651833F22313}" ProjectSection(ProjectDependencies) = postProject - {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} + {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LogWindow", "LogWindow.vcproj", "{7DB13706-F0ED-4EA8-BE14-E4D62D500C67}" ProjectSection(ProjectDependencies) = postProject - {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} + {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OBJECT", "OBJECT.vcproj", "{447B72EF-4B7D-4200-A92E-BDE789576117}" ProjectSection(ProjectDependencies) = postProject - {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} - {4B9BF133-1E25-4C6E-9233-651833F22313} = {4B9BF133-1E25-4C6E-9233-651833F22313} {06CA8800-62E7-4FA8-BA7B-3607F27491B8} = {06CA8800-62E7-4FA8-BA7B-3607F27491B8} + {4B9BF133-1E25-4C6E-9233-651833F22313} = {4B9BF133-1E25-4C6E-9233-651833F22313} + {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ObjBrowser", "ObjBrowser.vcproj", "{D2CA8DB5-A2DE-4EF9-B967-0F639736469F}" @@ -83,8 +83,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ObjBrowser", "ObjBrowser.vc EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plot2d", "Plot2d.vcproj", "{D5E571BF-0C2E-4513-8BF0-A7A54E4EA973}" ProjectSection(ProjectDependencies) = postProject - {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} + {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Prs", "Prs.vcproj", "{F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217}" @@ -93,39 +93,39 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Qtx", "Qtx.vcproj", "{961D1 EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SPlot2d", "SPlot2d.vcproj", "{36CA5C15-A7E6-4451-AE8E-8AD61754F970}" ProjectSection(ProjectDependencies) = postProject - {447B72EF-4B7D-4200-A92E-BDE789576117} = {447B72EF-4B7D-4200-A92E-BDE789576117} - {D5E571BF-0C2E-4513-8BF0-A7A54E4EA973} = {D5E571BF-0C2E-4513-8BF0-A7A54E4EA973} - {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} = {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} + {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} = {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} + {D5E571BF-0C2E-4513-8BF0-A7A54E4EA973} = {D5E571BF-0C2E-4513-8BF0-A7A54E4EA973} + {447B72EF-4B7D-4200-A92E-BDE789576117} = {447B72EF-4B7D-4200-A92E-BDE789576117} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "STD", "STD.vcproj", "{29831E95-B38D-4460-A46F-A4A4E1EE3941}" ProjectSection(ProjectDependencies) = postProject - {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} + {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SUIT", "SUIT.vcproj", "{8512A935-1BBB-4A7B-A552-F50824FDD87F}" ProjectSection(ProjectDependencies) = postProject - {D2CA8DB5-A2DE-4EF9-B967-0F639736469F} = {D2CA8DB5-A2DE-4EF9-B967-0F639736469F} {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} + {D2CA8DB5-A2DE-4EF9-B967-0F639736469F} = {D2CA8DB5-A2DE-4EF9-B967-0F639736469F} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SUITApp", "SUITApp.vcproj", "{6755FAA7-967A-4D23-966D-DE4F66234913}" ProjectSection(ProjectDependencies) = postProject - {AE9A31F5-1301-4E6D-91A3-E78DF4ABF0EA} = {AE9A31F5-1301-4E6D-91A3-E78DF4ABF0EA} - {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} + {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} + {AE9A31F5-1301-4E6D-91A3-E78DF4ABF0EA} = {AE9A31F5-1301-4E6D-91A3-E78DF4ABF0EA} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SVTK", "SVTK.vcproj", "{C3A1EE8B-C548-4A37-B49A-D322128EE161}" ProjectSection(ProjectDependencies) = postProject - {447B72EF-4B7D-4200-A92E-BDE789576117} = {447B72EF-4B7D-4200-A92E-BDE789576117} - {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} = {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} - {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} - {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} - {37FA9C33-4512-4833-A4A7-CCF490ADD732} = {37FA9C33-4512-4833-A4A7-CCF490ADD732} {06CA8800-62E7-4FA8-BA7B-3607F27491B8} = {06CA8800-62E7-4FA8-BA7B-3607F27491B8} + {37FA9C33-4512-4833-A4A7-CCF490ADD732} = {37FA9C33-4512-4833-A4A7-CCF490ADD732} + {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} + {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} + {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} = {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} + {447B72EF-4B7D-4200-A92E-BDE789576117} = {447B72EF-4B7D-4200-A92E-BDE789576117} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Style", "Style.vcproj", "{AE9A31F5-1301-4E6D-91A3-E78DF4ABF0EA}" @@ -135,28 +135,29 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Style", "Style.vcproj", "{A EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VTKViewer", "VTKViewer.vcproj", "{06CA8800-62E7-4FA8-BA7B-3607F27491B8}" ProjectSection(ProjectDependencies) = postProject - {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} + {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LightApp", "LightApp.vcproj", "{C8FB7D64-0A82-4588-8D27-2B7CC6C2EA85}" ProjectSection(ProjectDependencies) = postProject - {AE9A31F5-1301-4E6D-91A3-E78DF4ABF0EA} = {AE9A31F5-1301-4E6D-91A3-E78DF4ABF0EA} - {447B72EF-4B7D-4200-A92E-BDE789576117} = {447B72EF-4B7D-4200-A92E-BDE789576117} - {9EA751D5-767C-45CC-AA52-283E69308EB7} = {9EA751D5-767C-45CC-AA52-283E69308EB7} - {D5E571BF-0C2E-4513-8BF0-A7A54E4EA973} = {D5E571BF-0C2E-4513-8BF0-A7A54E4EA973} - {D2CA8DB5-A2DE-4EF9-B967-0F639736469F} = {D2CA8DB5-A2DE-4EF9-B967-0F639736469F} - {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} = {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} - {29831E95-B38D-4460-A46F-A4A4E1EE3941} = {29831E95-B38D-4460-A46F-A4A4E1EE3941} - {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} - {C3A1EE8B-C548-4A37-B49A-D322128EE161} = {C3A1EE8B-C548-4A37-B49A-D322128EE161} - {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} - {4B9BF133-1E25-4C6E-9233-651833F22313} = {4B9BF133-1E25-4C6E-9233-651833F22313} - {37FA9C33-4512-4833-A4A7-CCF490ADD732} = {37FA9C33-4512-4833-A4A7-CCF490ADD732} - {36CA5C15-A7E6-4451-AE8E-8AD61754F970} = {36CA5C15-A7E6-4451-AE8E-8AD61754F970} - {7DB13706-F0ED-4EA8-BE14-E4D62D500C67} = {7DB13706-F0ED-4EA8-BE14-E4D62D500C67} {06CA8800-62E7-4FA8-BA7B-3607F27491B8} = {06CA8800-62E7-4FA8-BA7B-3607F27491B8} + {7DB13706-F0ED-4EA8-BE14-E4D62D500C67} = {7DB13706-F0ED-4EA8-BE14-E4D62D500C67} + {36CA5C15-A7E6-4451-AE8E-8AD61754F970} = {36CA5C15-A7E6-4451-AE8E-8AD61754F970} + {37FA9C33-4512-4833-A4A7-CCF490ADD732} = {37FA9C33-4512-4833-A4A7-CCF490ADD732} + {4B9BF133-1E25-4C6E-9233-651833F22313} = {4B9BF133-1E25-4C6E-9233-651833F22313} + {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} {DB53E05E-3E2E-460D-8B77-9B339FA3DE59} = {DB53E05E-3E2E-460D-8B77-9B339FA3DE59} + {C3A1EE8B-C548-4A37-B49A-D322128EE161} = {C3A1EE8B-C548-4A37-B49A-D322128EE161} + {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} + {29831E95-B38D-4460-A46F-A4A4E1EE3941} = {29831E95-B38D-4460-A46F-A4A4E1EE3941} + {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} = {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} + {D2CA8DB5-A2DE-4EF9-B967-0F639736469F} = {D2CA8DB5-A2DE-4EF9-B967-0F639736469F} + {1FE6A5B7-9504-4119-BC86-13115BEA326B} = {1FE6A5B7-9504-4119-BC86-13115BEA326B} + {D5E571BF-0C2E-4513-8BF0-A7A54E4EA973} = {D5E571BF-0C2E-4513-8BF0-A7A54E4EA973} + {9EA751D5-767C-45CC-AA52-283E69308EB7} = {9EA751D5-767C-45CC-AA52-283E69308EB7} + {447B72EF-4B7D-4200-A92E-BDE789576117} = {447B72EF-4B7D-4200-A92E-BDE789576117} + {AE9A31F5-1301-4E6D-91A3-E78DF4ABF0EA} = {AE9A31F5-1301-4E6D-91A3-E78DF4ABF0EA} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GraphicsView", "GraphicsView.vcproj", "{DB53E05E-3E2E-460D-8B77-9B339FA3DE59}" @@ -165,6 +166,17 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GraphicsView", "GraphicsVie {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plot3d", "Plot3d.vcproj", "{1FE6A5B7-9504-4119-BC86-13115BEA326B}" + ProjectSection(ProjectDependencies) = postProject + {06CA8800-62E7-4FA8-BA7B-3607F27491B8} = {06CA8800-62E7-4FA8-BA7B-3607F27491B8} + {37FA9C33-4512-4833-A4A7-CCF490ADD732} = {37FA9C33-4512-4833-A4A7-CCF490ADD732} + {8512A935-1BBB-4A7B-A552-F50824FDD87F} = {8512A935-1BBB-4A7B-A552-F50824FDD87F} + {C3A1EE8B-C548-4A37-B49A-D322128EE161} = {C3A1EE8B-C548-4A37-B49A-D322128EE161} + {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} = {961D1F90-2AF9-4D8B-B1D5-061EB3CA4474} + {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} = {F33BDEB3-AC58-4A0C-8E4C-3671A9C8F217} + {447B72EF-4B7D-4200-A92E-BDE789576117} = {447B72EF-4B7D-4200-A92E-BDE789576117} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -251,6 +263,10 @@ Global {DB53E05E-3E2E-460D-8B77-9B339FA3DE59}.Debug|Win32.Build.0 = Debug|Win32 {DB53E05E-3E2E-460D-8B77-9B339FA3DE59}.Release|Win32.ActiveCfg = Release|Win32 {DB53E05E-3E2E-460D-8B77-9B339FA3DE59}.Release|Win32.Build.0 = Release|Win32 + {1FE6A5B7-9504-4119-BC86-13115BEA326B}.Debug|Win32.ActiveCfg = Debug|Win32 + {1FE6A5B7-9504-4119-BC86-13115BEA326B}.Debug|Win32.Build.0 = Debug|Win32 + {1FE6A5B7-9504-4119-BC86-13115BEA326B}.Release|Win32.ActiveCfg = Release|Win32 + {1FE6A5B7-9504-4119-BC86-13115BEA326B}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/adm_local/win32/Plot3d.vcproj b/adm_local/win32/Plot3d.vcproj new file mode 100644 index 000000000..9d6125e36 --- /dev/null +++ b/adm_local/win32/Plot3d.vcproj @@ -0,0 +1,635 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/adm_local/win32/SVTK.vcproj b/adm_local/win32/SVTK.vcproj index 4f231d289..0302bfbf5 100644 --- a/adm_local/win32/SVTK.vcproj +++ b/adm_local/win32/SVTK.vcproj @@ -281,54 +281,6 @@ /> - - - - - - - - - - - - - - - - @@ -569,30 +521,6 @@ /> - - - - - - - - @@ -622,126 +550,6 @@ Name="Header Files" Filter="h;hpp;hxx;hm;inl" > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1137,6 +945,26 @@ + + + + + + - - - - - - - - - - @@ -1788,22 +1596,6 @@ Name="Meta Object Files" Filter="moc_*.cxx" > - - - - - - - - diff --git a/src/LightApp/resources/LightApp.ini b/src/LightApp/resources/LightApp.ini index 30d061b36..b4aa29405 100755 --- a/src/LightApp/resources/LightApp.ini +++ b/src/LightApp/resources/LightApp.ini @@ -11,6 +11,7 @@ SUIT = $(GUI_ROOT_DIR)/share/salome/resources/gui STD = $(GUI_ROOT_DIR)/share/salome/resources/gui LightApp = $(GUI_ROOT_DIR)/share/salome/resources/gui Plot2d = $(GUI_ROOT_DIR)/share/salome/resources/gui +Plot3d = $(GUI_ROOT_DIR)/share/salome/resources/gui GraphicsView = $(GUI_ROOT_DIR)/share/salome/resources/gui GLViewer = $(GUI_ROOT_DIR)/share/salome/resources/gui OCCViewer = $(GUI_ROOT_DIR)/share/salome/resources/gui diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index 06cd5bff4..c05531b76 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -36,6 +36,7 @@ + diff --git a/src/Plot3d/Makefile.am b/src/Plot3d/Makefile.am new file mode 100644 index 000000000..050291e1c --- /dev/null +++ b/src/Plot3d/Makefile.am @@ -0,0 +1,87 @@ +# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# File : Makefile.in +# Author : Oleg Uvarov (OCN) +# Module : Plot3d +# $Header: + +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +lib_LTLIBRARIES = libPlot3d.la + +salomeinclude_HEADERS= \ + Plot3d.h \ + Plot3d_Actor.h \ + Plot3d_ColorDic.h \ + Plot3d_FitDataDlg.h \ + Plot3d_SetupColorScaleDlg.h \ + Plot3d_SetupSpecificColorScaleDlg.h \ + Plot3d_SetupSurfacesDlg.h \ + Plot3d_ViewManager.h \ + Plot3d_ViewModel.h + +dist_libPlot3d_la_SOURCES= \ + Plot3d_Actor.cxx \ + Plot3d_ColorDic.cxx \ + Plot3d_FitDataDlg.cxx \ + Plot3d_SetupColorScaleDlg.cxx \ + Plot3d_SetupSpecificColorScaleDlg.cxx \ + Plot3d_SetupSurfacesDlg.cxx \ + Plot3d_ViewManager.cxx \ + Plot3d_ViewModel.cxx + +MOC_FILES= \ + Plot3d_SetupColorScaleDlg_moc.cxx \ + Plot3d_SetupSpecificColorScaleDlg_moc.cxx \ + Plot3d_SetupSurfacesDlg_moc.cxx \ + Plot3d_ViewManager_moc.cxx \ + Plot3d_ViewModel_moc.cxx +nodist_libPlot3d_la_SOURCES= $(MOC_FILES) + +dist_salomeres_DATA=\ + resources/plot3d_minus.png \ + resources/plot3d_mode_2d.png \ + resources/plot3d_surfaces_settings.png + +nodist_salomeres_DATA = \ + Plot3d_msg_en.qm \ + Plot3d_images.qm + +libPlot3d_la_CPPFLAGS = \ + $(QT_INCLUDES) \ + $(CAS_CPPFLAGS) \ + $(VTK_INCLUDES) \ + $(BOOST_CPPFLAGS) \ + -I$(srcdir)/../Qtx \ + -I$(srcdir)/../SUIT \ + -I$(srcdir)/../OBJECT \ + -I$(srcdir)/../Prs \ + -I$(srcdir)/../VTKViewer + +libPlot3d_la_LDFLAGS = \ + $(QT_MT_LIBS) \ + $(CAS_KERNEL) $(CAS_VIEWER) \ + $(VTK_LIBS) $(OGL_LIBS) + +libPlot3d_la_LIBADD = ../Qtx/libqtx.la ../SUIT/libsuit.la ../OBJECT/libSalomeObject.la \ + ../Prs/libSalomePrs.la ../VTKViewer/libVTKViewer.la + +Plot3d_CPPFLAGS = $(libPlot3d_la_CPPFLAGS) +Plot3d_LDFLAGS = $(libPlot3d_la_LDFLAGS) +Plot3d_LDADD = libPlot3d.la $(libPlot3d_la_LIBADD) diff --git a/src/Plot3d/Plot3d.h b/src/Plot3d/Plot3d.h new file mode 100644 index 000000000..3c63765fe --- /dev/null +++ b/src/Plot3d/Plot3d.h @@ -0,0 +1,37 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef PLOT3D_H +#define PLOT3D_H + +#ifdef WIN32 +# ifdef PLOT3D_EXPORTS +# define PLOT3D_EXPORT __declspec(dllexport) +# else +# define PLOT3D_EXPORT __declspec(dllimport) +# endif +#else +# define PLOT3D_EXPORT +#endif + +#if defined WIN32 +#pragma warning ( disable: 4251 ) +#pragma warning ( disable: 4786 ) +#endif + +#endif diff --git a/src/Plot3d/Plot3d_Actor.cxx b/src/Plot3d/Plot3d_Actor.cxx new file mode 100644 index 000000000..d42f0cee7 --- /dev/null +++ b/src/Plot3d/Plot3d_Actor.cxx @@ -0,0 +1,487 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "Plot3d_Actor.h" + +#include "Plot3d_ColorDic.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +vtkStandardNewMacro(Plot3d_Actor); + +//============================================================================= +// Function : Plot3d_Actor +// Purpose : Constructor +//============================================================================= +Plot3d_Actor::Plot3d_Actor() +{ + myColorDic = new Plot3d_ColorDic(); + + myIsDistance = false; + + myStartPoint = 0; + myEndPoint = 0; + + // Scalar bar + myToDisplayScalarBar = false; + + myScalarBarActor = vtkScalarBarActor::New(); + myScalarBarActor->SetVisibility( false ); + + // Title props + QColor aTextColor = Qt::white; + + vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New(); + aScalarBarTitleProp->SetColor( aTextColor.redF(), aTextColor.greenF(), aTextColor.blueF() ); + aScalarBarTitleProp->SetFontFamilyToArial(); + int aSize = 24; + aScalarBarTitleProp->SetFontSize( aSize ); + myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp ); + aScalarBarTitleProp->Delete(); + + // Label props + vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New(); + aScalarBarLabelProp->SetColor( aTextColor.redF(), aTextColor.greenF(), aTextColor.blueF() ); + aScalarBarLabelProp->SetFontFamilyToArial(); + myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp ); + aScalarBarLabelProp->Delete(); + + // Position + double aXPos = 0.01, aYPos = 0.1; + myScalarBarActor->SetPosition( aXPos, aYPos ); + + // Width + double aWidth = 0.10, aHeight = 0.80; + myScalarBarActor->SetWidth( aWidth ); + myScalarBarActor->SetHeight( aHeight ); + + // Number of labels and Maximum number of colors + myScalarBarActor->SetNumberOfLabels( 5 ); + myScalarBarActor->SetMaximumNumberOfColors( 99 ); + + // ScalarBar widget + myScalarBarWg = vtkScalarBarWidget::New(); + myScalarBarWg->SetScalarBarActor( myScalarBarActor.GetPointer() ); + + // Property + this->GetProperty()->ShadingOff(); + this->GetProperty()->LightingOff(); + + // Lookup table + myLookupTable = vtkLookupTable::New(); + myLookupTable->SetHueRange( 0.667, 0.0 ); +} + +//============================================================================= +// Function : ~Plot3d_Actor +// Purpose : Destructor +//============================================================================= +Plot3d_Actor::~Plot3d_Actor() +{ + if( myColorDic ) + { + delete myColorDic; + myColorDic = 0; + } + + myLookupTable->Delete(); +} + +//============================================================================= +// Function : SetVisibility +// Purpose : +//============================================================================= +void Plot3d_Actor::SetVisibility( int theVisibility ) +{ + Superclass::SetVisibility( theVisibility ); + + myScalarBarActor->SetVisibility( GetVisibility() && myToDisplayScalarBar ); + + if ( !theVisibility || !myScalarBarActor->GetLookupTable() || !myToDisplayScalarBar ) + myScalarBarWg->EnabledOff(); + else + myScalarBarWg->EnabledOn(); +} + +//============================================================================= +// Function : SetMapper +// Purpose : +//============================================================================= +void Plot3d_Actor::SetMapper( vtkMapper* theMapper ) +{ + Superclass::SetMapper(theMapper); +} + +//============================================================================= +// Function : AddToRender +// Purpose : +//============================================================================= +void Plot3d_Actor::AddToRender( vtkRenderer* theRenderer ) +{ + Superclass::AddToRender( theRenderer ); + + if ( vtkRenderWindow *win = theRenderer->GetRenderWindow() ) + { + if ( vtkRenderWindowInteractor *interactor = win->GetInteractor() ) + { + myScalarBarWg->SetInteractor( interactor ); + if ( myToDisplayScalarBar ) + myScalarBarWg->EnabledOn(); + } + } + + theRenderer->AddActor( myScalarBarActor.GetPointer() ); +} + +//============================================================================= +// Function : RemoveFromRender +// Purpose : +//============================================================================= +void Plot3d_Actor::RemoveFromRender( vtkRenderer* theRenderer ) +{ + myScalarBarWg->EnabledOff(); + theRenderer->RemoveActor( myScalarBarActor.GetPointer() ); + + Superclass::RemoveFromRender( theRenderer ); +} + +//============================================================================= +// Function : GetColorDic +// Purpose : +//============================================================================= +Plot3d_ColorDic* Plot3d_Actor::GetColorDic() +{ + return myColorDic; +} + +//============================================================================= +// Function : GetScalarBarActor +// Purpose : +//============================================================================= +vtkSmartPointer Plot3d_Actor::GetScalarBarActor() const +{ + return myScalarBarActor; +} + +//============================================================================= +// Function : DisplayScalarBar +// Purpose : +//============================================================================= +void Plot3d_Actor::DisplayScalarBar( const bool theToDisplay ) +{ + myToDisplayScalarBar = theToDisplay; + myScalarBarActor->SetVisibility( GetVisibility() && theToDisplay ); + myScalarBarWg->SetEnabled( GetVisibility() && theToDisplay ? 1 : 0 ); +} + +//============================================================================= +// Function : Build +// Purpose : +//============================================================================= +void Plot3d_Actor::Build( const int theNX, + const int theNY, + const QList& thePntList, + const QList& theValueList, + const double theMinValue, + const double theMaxValue ) +{ + vtkPolyData* aPointSet = vtkPolyData::New(); + aPointSet->Allocate( ( theNX - 1 ) * ( theNY - 1 ) ); + + vtkPoints* aPoints = vtkPoints::New(); + QListIterator aPntIter( thePntList ); + while( aPntIter.hasNext() ) + { + const QPointF& aPnt = aPntIter.next(); + aPoints->InsertNextPoint( aPnt.x(), aPnt.y(), 0 ); + } + aPointSet->SetPoints( aPoints ); + + vtkIdType pts[ 4 ]; + for( int i = 0; i < theNX - 1; i++ ) + { + for( int j = 0; j < theNY - 1; j++ ) + { + pts[0] = j + theNY * i; + pts[1] = j + theNY * i + 1; + pts[2] = j + theNY * ( i + 1 ) + 1; + pts[3] = j + theNY * ( i + 1 ); + aPointSet->InsertNextCell( VTK_QUAD, 4, pts ); + } + } + + vtkFloatArray* aFloatArray = vtkFloatArray::New(); + QListIterator aValueIter( theValueList ); + while( aValueIter.hasNext() ) + { + const double aValue = aValueIter.next(); + aFloatArray->InsertNextTuple1( aValue ); + } + + vtkPointData* aPointData = aPointSet->GetPointData(); + aPointData->SetScalars( aFloatArray ); + + vtkWarpScalar* aWarpScalar = vtkWarpScalar::New(); + aWarpScalar->SetInput( aPointSet ); + aWarpScalar->SetScaleFactor( 1 ); + + vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New(); + aMapper->SetInput( aWarpScalar->GetPolyDataOutput() ); + aMapper->SetScalarRange( theMinValue, theMaxValue ); + + SetMapper( aMapper ); + + aPoints->Delete(); + aFloatArray->Delete(); + aPointSet->Delete(); + + myColorDic->SetRange( theMinValue, theMaxValue ); + + RecomputeLookupTable(); +} + +//============================================================================= +// Function : RecomputeLookupTable +// Purpose : +//============================================================================= +void Plot3d_Actor::RecomputeLookupTable() +{ + if( !myColorDic ) + return; + + vtkPolyDataMapper* aMapper = dynamic_cast( GetMapper() ); + if( !aMapper ) + return; + + double myMinimum = myColorDic->GetMin(); + double myMaximum = myColorDic->GetMax(); + + int aScaleMode = (int)myColorDic->GetScaleMode(); + + int nbColors = myColorDic->GetNumber(); + if ( aScaleMode == Plot3d_ColorDic::Specific ) + { + nbColors = 1000; + if( nbColors == 0 ) + return; + } + + if( myMinimum > myMaximum || + myMinimum < RealFirst() / 2. || + myMaximum > RealLast() / 2. ) + return; // protection from uninitialized bounds (empty results) + + double aMin = myMinimum; + double aMax = myMaximum; + double range[2] = { aMin, aMax }; + + double aHueMin, aHueMax, aSaturationMin, aSaturationMax, aValueMin, aValueMax; + myColorDic->GetHSVRange( aHueMin, aHueMax, aSaturationMin, aSaturationMax, aValueMin, aValueMax ); + + double range1[2] = { 0, 0 }; + if ( aScaleMode == Plot3d_ColorDic::Linear || + aScaleMode == Plot3d_ColorDic::Specific ) + { + double delta = ( aMax - aMin ) / nbColors; + range1[0] = aMin - 2 * delta; + range1[1] = aMax + 2 * delta; + } + else if ( aScaleMode == Plot3d_ColorDic::Logarithmic ) + { + if( aMin > 0 && aMax > 0 ) + { + double aLogMin = log10( aMin ); + double aLogMax = log10( aMax ); + double aLogDelta = ( aLogMax - aLogMin ) / nbColors; + range1[0] = pow( 10, aLogMin - 2 * aLogDelta ); + range1[1] = pow( 10, aLogMax + 2 * aLogDelta ); + } + } + + vtkLookupTable* aTable = dynamic_cast( aMapper->GetLookupTable() ); + + if ( range[0] == range[1] ) + { + aTable->SetRange( range ); + aTable->SetNumberOfTableValues( 1 ); + aTable->SetTableValue( 0, 0, 0, 1 ); + + myLookupTable->SetRange( range ); + myLookupTable->SetNumberOfTableValues( 1 ); + myLookupTable->SetTableValue( 0, 0, 0, 1 ); + } + else + { + if ( aScaleMode == Plot3d_ColorDic::Specific ) + { + const Value2ColorList& aSpecificScale = myColorDic->GetSpecificScale(); + if ( aSpecificScale.size() < 2 ) + return; + + myLookupTable->SetRange( range ); + myLookupTable->SetNumberOfTableValues( nbColors ); + myLookupTable->SetScaleToLinear(); + + Value2ColorListIterator anIter( aSpecificScale ); + Value2Color aValue2ColorRef = anIter.next(); + Value2Color aValue2Color = anIter.next(); + + QColor aColor; + double rgba[4]; + + double valMin = range[0]; + double valMax = range[1]; + double valRange = valMax - valMin; + double valStep = valRange / (double)nbColors; + for ( int anIndex = 0; anIndex < nbColors; anIndex++ ) + { + double val = valMin + valStep * (double)anIndex; + while ( val > aValue2Color.first && anIter.hasNext() ) + { + aValue2ColorRef = aValue2Color; + aValue2Color = anIter.next(); + } + + aColor = aValue2ColorRef.second; + rgba[0] = aColor.redF(); + rgba[1] = aColor.greenF(); + rgba[2] = aColor.blueF(); + rgba[3] = 1.0; + + myLookupTable->SetTableValue( anIndex, rgba ); + } + } + else + { + myLookupTable->SetRange( range ); + myLookupTable->SetNumberOfTableValues( nbColors ); + myLookupTable->SetHueRange( aHueMin, aHueMax ); + myLookupTable->SetSaturationRange( aSaturationMin, aSaturationMax ); + myLookupTable->SetValueRange( aValueMin, aValueMax ); + myLookupTable->SetScale( aScaleMode ); + myLookupTable->ForceBuild(); + } + + // TODO: number of colors should be computed (recieved from the filter) + aTable->SetNumberOfTableValues( nbColors + 4 ); + aTable->SetScale( myLookupTable->GetScale() ); + aTable->SetRange( range1 ); + aTable->Build(); + double rgba[4]; + + aTable->SetTableValue( 0, 0, 0, 0, 1 ); + myLookupTable->GetTableValue(0, rgba); + aTable->SetTableValue( 1, rgba ); + for (int i = 0; i < nbColors; i++) { + myLookupTable->GetTableValue(i, rgba); + aTable->SetTableValue(i+2, rgba); + } + aTable->SetTableValue( nbColors + 2, rgba ); + aTable->SetTableValue( nbColors + 3, 0, 0, 0, 1 ); + } + + Modified(); + + aMapper->SetScalarRange( range1 ); + aMapper->SetLookupTable( aTable ); + + myScalarBarActor->SetLookupTable( myLookupTable ); +} + +//============================================================================= +// Function : SetUnits +// Purpose : +//============================================================================= +void Plot3d_Actor::SetUnits( const QString& theUnits ) +{ + myUnits = theUnits; +} + +//============================================================================= +// Function : GetUnits +// Purpose : +//============================================================================= +QString Plot3d_Actor::GetUnits() const +{ + return myUnits; +} + +//============================================================================= +// Function : SetIsDistance +// Purpose : +//============================================================================= +void Plot3d_Actor::SetIsDistance( const bool theIsDistance ) +{ + myIsDistance = theIsDistance; +} + +//============================================================================= +// Function : GetIsDistance +// Purpose : +//============================================================================= +bool Plot3d_Actor::GetIsDistance() const +{ + return myIsDistance; +} + +//============================================================================= +// Function : SetBoundaryPoints +// Purpose : +//============================================================================= +void Plot3d_Actor::SetBoundaryPoints( const int theStartPoint, + const int theEndPoint ) +{ + myStartPoint = theStartPoint; + myEndPoint = theEndPoint; +} + +//============================================================================= +// Function : GetBoundaryPoints +// Purpose : +//============================================================================= +void Plot3d_Actor::GetBoundaryPoints( int& theStartPoint, + int& theEndPoint ) +{ + theStartPoint = myStartPoint; + theEndPoint = myEndPoint; +} + +//============================================================================= +// Function : SetTextColor +// Purpose : +//============================================================================= +void Plot3d_Actor::SetTextColor( const QColor& theColor ) +{ + vtkTextProperty* aScalarBarTitleProp = myScalarBarActor->GetTitleTextProperty(); + aScalarBarTitleProp->SetColor( theColor.redF(), theColor.greenF(), theColor.blueF() ); + + vtkTextProperty* aScalarBarLabelProp = myScalarBarActor->GetLabelTextProperty(); + aScalarBarLabelProp->SetColor( theColor.redF(), theColor.greenF(), theColor.blueF() ); +} diff --git a/src/Plot3d/Plot3d_Actor.h b/src/Plot3d/Plot3d_Actor.h new file mode 100644 index 000000000..5d3899fa8 --- /dev/null +++ b/src/Plot3d/Plot3d_Actor.h @@ -0,0 +1,99 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef PLOT3D_ACTOR_H +#define PLOT3D_ACTOR_H + +#include "Plot3d.h" + +#include "SALOME_Actor.h" + +#include +#include +#include +#include + +class vtkLookupTable; +class vtkScalarBarActor; +class vtkScalarBarWidget; + +class Plot3d_ColorDic; + +/* + Class : Plot3d_Actor + Descrtiption : Class for presentation of the Plot3d graph +*/ + +class PLOT3D_EXPORT Plot3d_Actor : public SALOME_Actor +{ +public: + static Plot3d_Actor* New(); + vtkTypeMacro( Plot3d_Actor, SALOME_Actor ); + + Plot3d_Actor(); + virtual ~Plot3d_Actor(); + + virtual void AddToRender( vtkRenderer* theRender ); + virtual void RemoveFromRender(vtkRenderer* theRendere); + + virtual void SetVisibility( int ); + + virtual void SetMapper( vtkMapper* theMapper ); + + Plot3d_ColorDic* GetColorDic(); + + vtkSmartPointer GetScalarBarActor() const; + void DisplayScalarBar( const bool ); + + void Build( const int theNX, + const int theNY, + const QList& thePntList, + const QList& theValueList, + const double theMinValue, + const double theMaxValue ); + + void RecomputeLookupTable(); + + void SetUnits( const QString& ); + QString GetUnits() const; + + void SetIsDistance( const bool ); + bool GetIsDistance() const; + + void SetBoundaryPoints( const int, const int ); + void GetBoundaryPoints( int&, int& ); + + void SetTextColor( const QColor& theColor ); + +protected: + Plot3d_ColorDic* myColorDic; + + vtkLookupTable* myLookupTable; + + vtkSmartPointer myScalarBarActor; + vtkSmartPointer myScalarBarWg; + bool myToDisplayScalarBar; + + QString myUnits; + bool myIsDistance; + + int myStartPoint; + int myEndPoint; +}; + +#endif diff --git a/src/Plot3d/Plot3d_ColorDic.cxx b/src/Plot3d/Plot3d_ColorDic.cxx new file mode 100644 index 000000000..1a77be082 --- /dev/null +++ b/src/Plot3d/Plot3d_ColorDic.cxx @@ -0,0 +1,486 @@ +// File: Plot3d_ColorDic.cxx +// Created: November, 2004 +// Author: OCC team +// Copyright (C) CEA 2004 + +#include "Plot3d_ColorDic.h" + +#include + +#include + +//======================================================================= +//function : Plot3d_ColorDic +//purpose : Constructor +//======================================================================= +Plot3d_ColorDic::Plot3d_ColorDic() +: myNum( 99 ), + myMin( 0 ), + myMax( 1 ), + myTimeStep( 0 ), + myHueMin( 0.667 ), + myHueMax( 0 ), + mySaturationMin( 1 ), + mySaturationMax( 1 ), + myValueMin( 1 ), + myValueMax( 1 ), + myScaleMode( Linear ) +{ + Init(); +} + +//======================================================================= +//function : Plot3d_ColorDic +//purpose : Constructor +//======================================================================= +Plot3d_ColorDic::Plot3d_ColorDic( const int num ) +: myNum( num ), + myMin( 0 ), + myMax( 1 ), + myTimeStep( 0 ), + myHueMin( 0.667 ), + myHueMax( 0 ), + mySaturationMin( 1 ), + mySaturationMax( 1 ), + myValueMin( 1 ), + myValueMax( 1 ), + myScaleMode( Linear ) +{ + Init(); +} + +//======================================================================= +//function : Plot3d_ColorDic +//purpose : Constructor +//======================================================================= +Plot3d_ColorDic::Plot3d_ColorDic( const int num, const double min, const double max ) +: myNum( num ), + myMin( min ), + myMax( max ), + myTimeStep( 0 ), + myHueMin( 0.667 ), + myHueMax( 0 ), + mySaturationMin( 1 ), + mySaturationMax( 1 ), + myValueMin( 1 ), + myValueMax( 1 ), + myScaleMode( Linear ) +{ + Init(); +} + +//======================================================================= +//function : ~Plot3d_ColorDic +//purpose : Destructor +//======================================================================= +Plot3d_ColorDic::~Plot3d_ColorDic() +{ + myLookupTable->Delete(); +} + +//======================================================================= +//function : init +//purpose : Define initial values +//======================================================================= +void Plot3d_ColorDic::Init() +{ + myColorMode = 0; + myCustomColors[ 0 ] = Qt::blue; + myCustomColors[ 1 ] = Qt::red; + myLookupTable = vtkLookupTable::New(); + UpdateLookupTable(); +} + +//======================================================================= +//function : UpdateLookupTable +//purpose : +//======================================================================= +void Plot3d_ColorDic::UpdateLookupTable() +{ + myLookupTable->SetHueRange( myHueMin, myHueMax ); + myLookupTable->SetSaturationRange( mySaturationMin, mySaturationMax ); + myLookupTable->SetValueRange( myValueMin, myValueMax ); + + if( myScaleMode != Specific ) + myLookupTable->SetScale( (int)myScaleMode ); + + myLookupTable->SetNumberOfTableValues( myNum ); + myLookupTable->SetRange( GetMin(), GetMax() ); + + myLookupTable->Build(); +} + +//======================================================================= +//function : GetNumber +//purpose : +//======================================================================= +int Plot3d_ColorDic::GetNumber() const +{ + return myNum; +} + +//======================================================================= +//function : SetNumber +//purpose : +//======================================================================= +void Plot3d_ColorDic::SetNumber( const int num ) +{ + myNum = num; + UpdateLookupTable(); +} + +//======================================================================= +//function : GetMin +//purpose : +//======================================================================= +double Plot3d_ColorDic::GetMin() const +{ + return myMin; +} + +//======================================================================= +//function : GetMax +//purpose : +//======================================================================= +double Plot3d_ColorDic::GetMax() const +{ + return myMax; +} + +//======================================================================= +//function : SetMin +//purpose : +//======================================================================= +void Plot3d_ColorDic::SetMin( const double min ) +{ + SetRange( min, GetMax() ); +} + +//======================================================================= +//function : SetMax +//purpose : +//======================================================================= +void Plot3d_ColorDic::SetMax( const double max ) +{ + SetRange( GetMin(), max ); +} + +//======================================================================= +//function : SetRange +//purpose : +//======================================================================= +void Plot3d_ColorDic::SetRange( const double min, const double max ) +{ + myMin = Min( min, max ); + myMax = Max( min, max ); + UpdateLookupTable(); +} + +//======================================================================= +//function : GetHSVRange +//purpose : +//======================================================================= +void Plot3d_ColorDic::GetHSVRange( double& hueMin, double& hueMax, + double& satMin, double& satMax, + double& valMin, double& valMax ) +{ + hueMin = myHueMin; + hueMax = myHueMax; + satMin = mySaturationMin; + satMax = mySaturationMax; + valMin = myValueMin; + valMax = myValueMax; +} + +//======================================================================= +//function : SetHSVRange +//purpose : +//======================================================================= +void Plot3d_ColorDic::SetHSVRange( const double hueMin, const double hueMax, + const double satMin, const double satMax, + const double valMin, const double valMax ) +{ + // additional check for achromatic colors, which have a hue value of -1 + myHueMin = hueMin < 0 ? hueMax : hueMin; + myHueMax = hueMax < 0 ? hueMin : hueMax; + mySaturationMin = satMin; + mySaturationMax = satMax; + myValueMin = valMin; + myValueMax = valMax; + UpdateLookupTable(); +} + +//======================================================================= +//function : GetScaleMode +//purpose : +//======================================================================= +Plot3d_ColorDic::ScaleMode Plot3d_ColorDic::GetScaleMode() const +{ + return myScaleMode; +} + +//======================================================================= +//function : SetScaleMode +//purpose : +//======================================================================= +void Plot3d_ColorDic::SetScaleMode( const Plot3d_ColorDic::ScaleMode type ) +{ + myScaleMode = type; + UpdateLookupTable(); +} + +//======================================================================= +//function : GetMainSpecificScale +//purpose : +//======================================================================= +const Value2ColorList& Plot3d_ColorDic::GetMainSpecificScale() const +{ + return myMainSpecificColorScale; +} + +//======================================================================= +//function : SetMainSpecificScale +//purpose : +//======================================================================= +void Plot3d_ColorDic::SetMainSpecificScale( const Value2ColorList& theSpecificColorScale ) +{ + myScaleMode = Specific; + myMainSpecificColorScale = theSpecificColorScale; +} + +//======================================================================= +//function : GetSpecificScale +//purpose : +//======================================================================= +const Value2ColorList& Plot3d_ColorDic::GetSpecificScale() const +{ + return mySpecificColorScale; +} + +//======================================================================= +//function : SetSpecificScale +//purpose : +//======================================================================= +void Plot3d_ColorDic::SetSpecificScale( const Value2ColorList& theSpecificColorScale ) +{ + myScaleMode = Specific; + mySpecificColorScale = theSpecificColorScale; + if ( !mySpecificColorScale.isEmpty() ) + SetRange( mySpecificColorScale.first().first, mySpecificColorScale.last().first ); + UpdateLookupTable(); +} + +//======================================================================= +//function : GetTimeStep +//purpose : +//======================================================================= +int Plot3d_ColorDic::GetTimeStep() const +{ + return myTimeStep; +} + +//======================================================================= +//function : SetTimeStep +//purpose : +//======================================================================= +void Plot3d_ColorDic::SetTimeStep( const int step ) +{ + myTimeStep = step; +} + +//======================================================================= +//function : GetQuantity +//purpose : +//======================================================================= +TCollection_AsciiString Plot3d_ColorDic::GetQuantity() const +{ + return myQuantity; +} + +//======================================================================= +//function : SetQuantity +//purpose : +//======================================================================= +void Plot3d_ColorDic::SetQuantity( const TCollection_AsciiString& quant ) +{ + myQuantity = quant; +} + +//======================================================================= +//function : GetColorByIndex +//purpose : +//======================================================================= +bool Plot3d_ColorDic::GetColorByIndex( const int idx, Quantity_Color& c ) const +{ + return GetColorByValue( Value( idx ), c ); +} + +//======================================================================= +//function : GetColorByValue +//purpose : +//======================================================================= +bool Plot3d_ColorDic::GetColorByValue( const double val, Quantity_Color& c ) const +{ + if ( val < GetMin() - Precision::Confusion() || + val > GetMax() + Precision::Confusion() ) + return false; + + double rgba[3]; + if ( myScaleMode == Specific ) + { + if ( !GetSpecificColor( val, rgba ) ) + return false; + } + else + myLookupTable->GetColor( val, rgba ); + + c = Quantity_Color( rgba[0], rgba[1], rgba[2], Quantity_TOC_RGB ); + + return true; +} + +//======================================================================= +//function : GetColorMode +//purpose : +//======================================================================= +int Plot3d_ColorDic::GetColorMode() const +{ + return myColorMode; +} + +//======================================================================= +//function : SetColorMode +//purpose : +//======================================================================= +void Plot3d_ColorDic::SetColorMode( const int mode ) +{ + myColorMode = mode; +} + +//======================================================================= +//function : GetCustomColors +//purpose : +//======================================================================= +void Plot3d_ColorDic::GetCustomColors( QColor& theBottom, QColor& theTop ) const +{ + theBottom = myCustomColors[ 0 ]; + theTop = myCustomColors[ 1 ]; +} + +//======================================================================= +//function : SetCustomColors +//purpose : +//======================================================================= +void Plot3d_ColorDic::SetCustomColors( const QColor& theBottom, const QColor& theTop ) +{ + myCustomColors[ 0 ] = theBottom; + myCustomColors[ 1 ] = theTop; +} + +//======================================================================= +//function : GetSpecificColor +//purpose : +//======================================================================= +bool Plot3d_ColorDic::GetSpecificColor( const double val, double rgb[3] ) const +{ + if( mySpecificColorScale.size() < 2 ) + return false; + + Value2ColorListIterator anIter( mySpecificColorScale ); + Value2Color aValue2ColorRef = anIter.next(); + while ( anIter.hasNext() ) + { + Value2Color aValue2Color = anIter.next(); + if ( val > aValue2ColorRef.first - Precision::Confusion() && + val < aValue2Color.first + Precision::Confusion() ) + { + QColor aColor = aValue2ColorRef.second; + rgb[0] = aColor.redF(); + rgb[1] = aColor.greenF(); + rgb[2] = aColor.blueF(); + return true; + } + aValue2ColorRef = aValue2Color; + } + return false; +} + +//======================================================================= +//function : Index +//purpose : +//======================================================================= +int Plot3d_ColorDic::Index( const double val ) const +{ + if ( !GetNumber() || val < GetMin() || val > GetMax() ) + return -1; + + double step = ( GetMax() - GetMin() ) / GetNumber(); + double range = val - GetMin(); + + int index = (int)( range / ( step != 0 ? step : 1 ) ); + + index = Min( index, GetNumber() - 1 ); + + return index; +} + +//======================================================================= +//function : Value +//purpose : +//======================================================================= +double Plot3d_ColorDic::Value( const int index ) const +{ + double value = 0.0; + if ( !GetNumber() || index < 0 || index >= GetNumber() ) + return value; + + if( index == 0 ) + return GetMin(); + + if( index == GetNumber() - 1 ) + return GetMax(); + + double min = GetMin(); + double max = GetMax(); + if( myScaleMode == Linear ) + value = min + index * ( qAbs( max - min ) / ( GetNumber() - 1 ) ); + else if( myScaleMode == Logarithmic ) + { + if ( min > 0 && max > 0 ) + { + double logMin = log10( min ); + double logMax = log10( max ); + double logVal = logMin + index * ( qAbs( logMax - logMin ) / ( GetNumber() - 1 ) ); + value = pow( 10, logVal ); + } + } + return value; +} + +//======================================================================= +//function : HueFromValue +//purpose : +//======================================================================= +int Plot3d_ColorDic::HueFromValue( const int val, const int min, const int max ) const +{ + static const int HUE[10] = {230, 210, 195, 180, 160, 80, 60, 50, 30, 0}; + + int hue = HUE[0]; + + if ( min != max ) + { + double aPosition = 9.0 * ( val - min ) / ( max - min ); + + if ( aPosition > 0.0 ) + { + if ( aPosition >= 9.0 ) + hue = HUE[9]; + else + { + int idx = (int)aPosition; + hue = HUE[idx] + int( ( aPosition - idx ) * ( HUE[idx + 1] - HUE[idx] ) ); + } + } + } + return hue; +} diff --git a/src/Plot3d/Plot3d_ColorDic.h b/src/Plot3d/Plot3d_ColorDic.h new file mode 100644 index 000000000..e8fe0ad3f --- /dev/null +++ b/src/Plot3d/Plot3d_ColorDic.h @@ -0,0 +1,118 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef PLOT3D_COLORDIC_H +#define PLOT3D_COLORDIC_H + +#include "Plot3d.h" + +#include +#include + +#include +#include + +class vtkLookupTable; + +typedef QPair< double, QColor > Value2Color; +typedef QList< Value2Color > Value2ColorList; +typedef QListIterator< Value2Color > Value2ColorListIterator; + +class PLOT3D_EXPORT Plot3d_ColorDic +{ +public: + enum ScaleMode { Linear = 0, Logarithmic, Specific }; + +public: + Plot3d_ColorDic(); + Plot3d_ColorDic( const int ); + Plot3d_ColorDic( const int, const double, const double ); + ~Plot3d_ColorDic(); + + int GetNumber() const; + void SetNumber( const int ); + + double GetMin() const; + double GetMax() const; + void SetMin( const double ); + void SetMax( const double ); + void SetRange( const double, const double ); + + void GetHSVRange( double&, double&, + double&, double&, + double&, double& ); + void SetHSVRange( const double, const double, + const double, const double, + const double, const double ); + + ScaleMode GetScaleMode() const; + void SetScaleMode( const ScaleMode ); + + const Value2ColorList& GetMainSpecificScale() const; + void SetMainSpecificScale( const Value2ColorList& ); + + const Value2ColorList& GetSpecificScale() const; + void SetSpecificScale( const Value2ColorList& ); + + int GetTimeStep() const; + void SetTimeStep( const int ); + + TCollection_AsciiString GetQuantity() const; + void SetQuantity( const TCollection_AsciiString& ); + + bool GetColorByIndex( const int, Quantity_Color& ) const; + bool GetColorByValue( const double, Quantity_Color& ) const; + + int GetColorMode() const; + void SetColorMode( const int ); + + void GetCustomColors( QColor&, QColor& ) const; + void SetCustomColors( const QColor&, const QColor& ); + +private: + void Init(); + void UpdateLookupTable(); + bool GetSpecificColor( const double, double[3] ) const; + int Index( const double ) const; + double Value( const int ) const; + int HueFromValue( const int, const int, const int ) const; + +private: + int myNum; + double myMin; + double myMax; + int myTimeStep; + TCollection_AsciiString myQuantity; + int myColorMode; + QColor myCustomColors[2]; + + double myHueMin; + double myHueMax; + double mySaturationMin; + double mySaturationMax; + double myValueMin; + double myValueMax; + + ScaleMode myScaleMode; + Value2ColorList myMainSpecificColorScale; + Value2ColorList mySpecificColorScale; + + vtkLookupTable* myLookupTable; +}; + +#endif diff --git a/src/Plot3d/Plot3d_FitDataDlg.cxx b/src/Plot3d/Plot3d_FitDataDlg.cxx new file mode 100644 index 000000000..dbd276a9e --- /dev/null +++ b/src/Plot3d/Plot3d_FitDataDlg.cxx @@ -0,0 +1,282 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "Plot3d_FitDataDlg.h" + +#include +#include +#include +#include +#include +#include +#include + +#define SPACING_SIZE 6 +#define MARGIN_SIZE 11 +#define MIN_EDIT_SIZE 100 + +/*! + Constructor +*/ +Plot3d_FitDataDlg::Plot3d_FitDataDlg( QWidget* parent, bool secondAxisY ) + : QDialog( parent ? parent : 0, + Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), + myY2MinEdit( 0 ), myY2MaxEdit( 0 ), mySecondAxisY( secondAxisY ) +{ + setObjectName( "Plot3d_FitDataDlg" ); + setModal( true ); + setWindowTitle( tr( "FIT_DATA_TLT" ) ); + setSizeGripEnabled( TRUE ); + QGridLayout* topLayout = new QGridLayout( this ); + topLayout->setSpacing( SPACING_SIZE ); + topLayout->setMargin( MARGIN_SIZE ); + + // 'Range' group + myRangeGrp = new QGroupBox( this ); + QGridLayout* aGridLayout = new QGridLayout( myRangeGrp ); + myRangeGrp->setLayout( aGridLayout ); + aGridLayout->setAlignment( Qt::AlignTop ); + aGridLayout->setMargin( MARGIN_SIZE ); + aGridLayout->setSpacing( SPACING_SIZE ); + + myModeAllRB = new QRadioButton( tr( "FIT_ALL" ), myRangeGrp ); + myModeHorRB = new QRadioButton( tr( "FIT_HORIZONTAL" ), myRangeGrp ); + myModeVerRB = new QRadioButton( tr( "FIT_VERTICAL" ), myRangeGrp ); + + QDoubleValidator* aValidator = new QDoubleValidator( this ); + myXMinEdit = new QLineEdit( myRangeGrp ); + myXMinEdit->setValidator( aValidator ); + myXMinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myXMinEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myXMinEdit->setText( "0.0" ); + + myYMinEdit = new QLineEdit( myRangeGrp ); + myYMinEdit->setValidator( aValidator ); + myYMinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myYMinEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myYMinEdit->setText( "0.0" ); + + myXMaxEdit = new QLineEdit( myRangeGrp ); + myXMaxEdit->setValidator( aValidator ); + myXMaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myXMaxEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myXMaxEdit->setText( "0.0" ); + + myYMaxEdit = new QLineEdit( myRangeGrp ); + myYMaxEdit->setValidator( aValidator ); + myYMaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myYMaxEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myYMaxEdit->setText( "0.0" ); + + if (mySecondAxisY) { + myY2MinEdit = new QLineEdit( myRangeGrp ); + myY2MinEdit->setValidator( aValidator ); + myY2MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myY2MinEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myY2MinEdit->setText( "0.0" ); + + myY2MaxEdit = new QLineEdit( myRangeGrp ); + myY2MaxEdit->setValidator( aValidator ); + myY2MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myY2MaxEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myY2MaxEdit->setText( "0.0" ); + } + + QFrame* aHLine = new QFrame( myRangeGrp ); + aHLine->setFrameStyle( QFrame::HLine | QFrame::Sunken ); + + QHBoxLayout* aModeLayout = new QHBoxLayout; + aModeLayout->setMargin( 0 ); + aModeLayout->setSpacing( SPACING_SIZE ); + aModeLayout->addWidget( myModeAllRB ); + aModeLayout->addWidget( myModeHorRB ); + aModeLayout->addWidget( myModeVerRB ); + + QLabel* horLab = new QLabel( tr( "HORIZONTAL_AXIS" ), myRangeGrp ); + QLabel* verLab = new QLabel( tr( "VERTICAL_AXIS" ), myRangeGrp ); + if (mySecondAxisY) + verLab->setText( tr( "VERTICAL_LEFT_AXIS" ) ); + + QFont font = horLab->font(); font.setBold( true ); + horLab->setFont( font ); verLab->setFont( font ); + + aGridLayout->addLayout( aModeLayout, 0, 0, 1, 5 ); + aGridLayout->addWidget( aHLine, 1, 0, 1, 5 ); + aGridLayout->addWidget( horLab, 2, 0 ); + aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), + 2, 1 ); + aGridLayout->addWidget( myXMinEdit, 2, 2 ); + aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), + 2, 3 ); + aGridLayout->addWidget( myXMaxEdit, 2, 4 ); + aGridLayout->addWidget( verLab, 3, 0 ); + aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), + 3, 1 ); + aGridLayout->addWidget( myYMinEdit, 3, 2 ); + aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), + 3, 3 ); + aGridLayout->addWidget( myYMaxEdit, 3, 4 ); + + if (mySecondAxisY) { + QLabel* ver2Lab = new QLabel(tr( "VERTICAL_RIGHT_AXIS" ), myRangeGrp ); + ver2Lab->setFont( font ); + aGridLayout->addWidget( ver2Lab, 4, 0 ); + aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), + 4, 1 ); + aGridLayout->addWidget( myY2MinEdit, 4, 2 ); + aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), + 4, 3 ); + aGridLayout->addWidget( myY2MaxEdit, 4, 4 ); + } + + // OK/Cancel buttons + myOkBtn = new QPushButton( tr( "BUT_OK" ), this ); + myOkBtn->setObjectName( "buttonOk" ); + myOkBtn->setAutoDefault( TRUE ); + myOkBtn->setDefault( TRUE ); + myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this ); + myCancelBtn->setObjectName( "buttonCancel" ); + myCancelBtn->setAutoDefault( TRUE ); + + topLayout->addWidget( myRangeGrp, 0, 0, 1, 3 ); + topLayout->addWidget( myOkBtn, 1, 0 ); + topLayout->setColumnStretch( 1, 5 ); + topLayout->addWidget( myCancelBtn, 1, 2 ); + + // connect signals + connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( myRangeGrp, SIGNAL( clicked( int ) ), this, SLOT( onModeChanged( int ) ) ); + + // initial state + myModeAllRB->setChecked( true ); + onModeChanged( 0 ); +} + +/*! + Sets range +*/ +void Plot3d_FitDataDlg::setRange( const double xMin, + const double xMax, + const double yMin, + const double yMax, + const double y2Min, + const double y2Max) +{ + myXMinEdit->setText( QString::number( xMin ) ); + myXMaxEdit->setText( QString::number( xMax ) ); + myYMinEdit->setText( QString::number( yMin ) ); + myYMaxEdit->setText( QString::number( yMax ) ); + if (mySecondAxisY) { + myY2MinEdit->setText( QString::number( y2Min ) ); + myY2MaxEdit->setText( QString::number( y2Max ) ); + } +} + +/*! + Gets range, returns mode (see getMode()) +*/ +int Plot3d_FitDataDlg::getRange( double& xMin, + double& xMax, + double& yMin, + double& yMax, + double& y2Min, + double& y2Max) +{ + xMin = myXMinEdit->text().toDouble(); + xMax = myXMaxEdit->text().toDouble(); + yMin = myYMinEdit->text().toDouble(); + yMax = myYMaxEdit->text().toDouble(); + if (mySecondAxisY) { + y2Min = myY2MinEdit->text().toDouble(); + y2Max = myY2MaxEdit->text().toDouble(); + } + else { + y2Min = 0; + y2Max = 0; + } + int myMode = 0; + if ( myModeAllRB->isChecked() ) + myMode = 0; + if ( myModeHorRB->isChecked() ) + myMode = 1; + if ( myModeVerRB->isChecked() ) + myMode = 2; + return myMode; +} + +/*! + Gets mode : 0 - Fit all; 1 - Fit horizontal, 2 - Fit vertical +*/ +int Plot3d_FitDataDlg::getMode() +{ + int myMode = 0; + if ( myModeAllRB->isChecked() ) + myMode = 0; + if ( myModeHorRB->isChecked() ) + myMode = 1; + if ( myModeVerRB->isChecked() ) + myMode = 2; + return myMode; +} + +/*! + Called when range mode changed +*/ +void Plot3d_FitDataDlg::onModeChanged(int mode) +{ + bool badFocus; + switch( mode ) { + case 0: // fit all mode + myXMinEdit->setEnabled(true); + myXMaxEdit->setEnabled(true); + myYMinEdit->setEnabled(true); + myYMaxEdit->setEnabled(true); + if (mySecondAxisY) { + myY2MinEdit->setEnabled(true); + myY2MaxEdit->setEnabled(true); + } + break; + case 1: // fit horizontal mode + badFocus = myYMinEdit->hasFocus() || myYMaxEdit->hasFocus(); + myXMinEdit->setEnabled(true); + myXMaxEdit->setEnabled(true); + myYMinEdit->setEnabled(false); + myYMaxEdit->setEnabled(false); + if (mySecondAxisY) { + myY2MinEdit->setEnabled(false); + myY2MaxEdit->setEnabled(false); + } + if (badFocus) + myXMinEdit->setFocus(); + break; + case 2: // fit vertical mode + badFocus = myXMinEdit->hasFocus() || myXMaxEdit->hasFocus(); + myXMinEdit->setEnabled(false); + myXMaxEdit->setEnabled(false); + myYMinEdit->setEnabled(true); + myYMaxEdit->setEnabled(true); + if (mySecondAxisY) { + myY2MinEdit->setEnabled(true); + myY2MaxEdit->setEnabled(true); + } + if (badFocus) + myYMinEdit->setFocus(); + break; + } +} diff --git a/src/Plot3d/Plot3d_FitDataDlg.h b/src/Plot3d/Plot3d_FitDataDlg.h new file mode 100644 index 000000000..e9104d28a --- /dev/null +++ b/src/Plot3d/Plot3d_FitDataDlg.h @@ -0,0 +1,76 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef PLOT3D_FITDATADLG_H +#define PLOT3D_FITDATADLG_H + +#include "Plot3d.h" + +#include + +class QGroupBox; +class QRadioButton; +class QLineEdit; +class QPushButton; + +class PLOT3D_EXPORT Plot3d_FitDataDlg : public QDialog +{ + Q_OBJECT + +public: +// constuctor + Plot3d_FitDataDlg( QWidget* parent, bool secondAxisY ); + +// sets range + void setRange(const double xMin, + const double xMax, + const double yMin, + const double yMax, + const double y2Min = 0, + const double y2Max = 0); +// gets range, returns mode (see getMode()) + int getRange(double& xMin, + double& xMax, + double& yMin, + double& yMax, + double& y2Min, + double& y2Max); +// gets mode : 0 - Fit all; 1 - Fit horizontal, 2 - Fit vertical + int getMode(); + +protected slots: +// called when range mode changed + void onModeChanged(int); + +private: + QGroupBox* myRangeGrp; + QRadioButton* myModeAllRB; + QRadioButton* myModeHorRB; + QRadioButton* myModeVerRB; + QLineEdit* myXMinEdit; + QLineEdit* myYMinEdit; + QLineEdit* myY2MinEdit; + QLineEdit* myXMaxEdit; + QLineEdit* myYMaxEdit; + QLineEdit* myY2MaxEdit; + QPushButton* myOkBtn; + QPushButton* myCancelBtn; + bool mySecondAxisY; +}; + +#endif diff --git a/src/Plot3d/Plot3d_SetupColorScaleDlg.cxx b/src/Plot3d/Plot3d_SetupColorScaleDlg.cxx new file mode 100644 index 000000000..8421dab82 --- /dev/null +++ b/src/Plot3d/Plot3d_SetupColorScaleDlg.cxx @@ -0,0 +1,457 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "Plot3d_SetupColorScaleDlg.h" + +#include "Plot3d_ColorDic.h" +#include "Plot3d_SetupSpecificColorScaleDlg.h" + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +//============================================================================= +// Function : Plot3d_SetupColorScaleDlg +// Purpose : Constructor +//============================================================================= +Plot3d_SetupColorScaleDlg::Plot3d_SetupColorScaleDlg( QWidget* theParent ) +: QtxDialog( theParent, true, false, QtxDialog::OKCancel ) +{ + setWindowTitle( tr( "SETUP_COLOR_SCALE" ) ); + + QFrame* aMainFrame = mainFrame(); + + QGroupBox* aColorScaleGroup = new QGroupBox( tr( "COLOR_SCALE" ), aMainFrame ); + + QtxGridBox* aScaleModeGroup = new QtxGridBox( 1, Qt::Vertical, aColorScaleGroup ); + aScaleModeGroup->setInsideMargin( 0 ); + + QAbstractButton* aScaleModeLinear = new QRadioButton( tr( "LINEAR" ), aScaleModeGroup ); + QAbstractButton* aScaleModeLogarithmic = new QRadioButton( tr( "LOGARITHMIC" ), aScaleModeGroup ); + QAbstractButton* aScaleModeSpecific = new QRadioButton( tr( "SPECIFIC" ), aScaleModeGroup ); + QAbstractButton* aScaleModeSpecificSetup = new QPushButton( tr( "SETUP" ), aScaleModeGroup ); + aScaleModeLinear->setChecked( true ); + aScaleModeSpecificSetup->setEnabled( false ); + + myColorScaleMode = new QButtonGroup( aScaleModeGroup ); + myColorScaleMode->setExclusive( true ); + myColorScaleMode->addButton( aScaleModeLinear, Plot3d_ColorDic::Linear ); + myColorScaleMode->addButton( aScaleModeLogarithmic, Plot3d_ColorDic::Logarithmic ); + myColorScaleMode->addButton( aScaleModeSpecific, Plot3d_ColorDic::Specific ); + + QWidget* anIntervalGroup = new QWidget( aColorScaleGroup ); + + QLabel* anIntervalLabel = new QLabel( tr( "NUMBER_OF_INTERVALS" ), anIntervalGroup ); + myInterval = new QtxIntSpinBox( 2, 99, 1, anIntervalGroup ); + + QLabel* aColorsLabel = new QLabel( tr( "COLORS" ), anIntervalGroup ); + myColorMode = new QComboBox( anIntervalGroup ); + myColorMode->addItems( QStringList() + << tr( "BLUE_RED" ) + << tr( "BLUE_WHITE" ) + << tr( "MONOCHROME" ) + << tr( "CUSTOM" ) ); + + myBottomColor = new QtxColorButton( anIntervalGroup ); + myTopColor = new QtxColorButton( anIntervalGroup ); + + QGridLayout* anIntervalGroupLayout = new QGridLayout( anIntervalGroup ); + anIntervalGroupLayout->setMargin( 0 ); + anIntervalGroupLayout->setSpacing( 5 ); + anIntervalGroupLayout->addWidget( anIntervalLabel, 0, 0 ); + anIntervalGroupLayout->addWidget( myInterval, 0, 1, 1, 3 ); + anIntervalGroupLayout->addWidget( aColorsLabel, 1, 0 ); + anIntervalGroupLayout->addWidget( myColorMode, 1, 1 ); + anIntervalGroupLayout->addWidget( myBottomColor, 1, 2 ); + anIntervalGroupLayout->addWidget( myTopColor, 1, 3 ); + + QVBoxLayout* aColorScaleLayout = new QVBoxLayout( aColorScaleGroup ); + aColorScaleLayout->setMargin( 5 ); + aColorScaleLayout->setSpacing( 5 ); + aColorScaleLayout->addWidget( aScaleModeGroup ); + aColorScaleLayout->addWidget( anIntervalGroup ); + + QGroupBox* aRangeGroup = new QGroupBox( tr( "RANGE" ), aMainFrame ); + + QLabel* aMinLabel = new QLabel( tr( "MIN" ), aRangeGroup ); + myMinLimit = new QDoubleSpinBox( aRangeGroup ); + myMinLimit->setMinimum( -DBL_MAX ); + myMinLimit->setMaximum( DBL_MAX ); + myMinLimit->setKeyboardTracking( false ); + + QLabel* aMaxLabel = new QLabel( tr( "MAX" ), aRangeGroup ); + myMaxLimit = new QDoubleSpinBox( aRangeGroup ); + myMaxLimit->setMinimum( -DBL_MAX ); + myMaxLimit->setMaximum( DBL_MAX ); + myMaxLimit->setKeyboardTracking( false ); + + myMinLimit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ) ); + myMaxLimit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ) ); + + myMinLimit->setDecimals( 6 ); + myMaxLimit->setDecimals( 6 ); + + QHBoxLayout* aRangeLayout = new QHBoxLayout( aRangeGroup ); + aRangeLayout->setMargin( 5 ); + aRangeLayout->setSpacing( 5 ); + aRangeLayout->addWidget( aMinLabel ); + aRangeLayout->addWidget( myMinLimit ); + aRangeLayout->addWidget( aMaxLabel ); + aRangeLayout->addWidget( myMaxLimit ); + + QVBoxLayout* aMainLayout = new QVBoxLayout( aMainFrame ); + aMainLayout->setMargin( 5 ); + aMainLayout->setSpacing( 5 ); + aMainLayout->addWidget( aColorScaleGroup ); + aMainLayout->addWidget( aRangeGroup ); + + connect( myMinLimit, SIGNAL( valueChanged( double ) ), this, SLOT( onMinMaxChanged( double ) ) ); + connect( myMaxLimit, SIGNAL( valueChanged( double ) ), this, SLOT( onMinMaxChanged( double ) ) ); + + connect( myInterval, SIGNAL( valueChanged( int ) ), this, SLOT( onIntervalNumberChanged( int ) ) ); + + connect( myColorMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onColorModeChanged( int ) ) ); + + connect( myColorScaleMode, SIGNAL( buttonClicked( int ) ), this, SLOT( onColorScaleModeChanged( int ) ) ); + connect( aScaleModeSpecific, SIGNAL( toggled( bool ) ), aScaleModeSpecificSetup, SLOT( setEnabled( bool ) ) ); + connect( aScaleModeSpecificSetup, SIGNAL( clicked() ), this, SLOT( onColorScaleSpecificSetup() ) ); + + onColorModeChanged( 0 ); // Blue-Red by default + + setButtonPosition( Right, Cancel ); +} + +//============================================================================= +// Function : ~Plot3d_SetupColorScaleDlg +// Purpose : Destructor +//============================================================================= +Plot3d_SetupColorScaleDlg::~Plot3d_SetupColorScaleDlg() +{ +} + +//============================================================================= +// Function : setData +// Purpose : +//============================================================================= +void Plot3d_SetupColorScaleDlg::setData( const ColorDicData& theColorDicData ) +{ + myMinLimit->setValue( theColorDicData.Min ); + myMaxLimit->setValue( theColorDicData.Max ); + + setColorScaleMode( theColorDicData.ScaleMode ); + + myInterval->setValue( theColorDicData.Num ); + + myColorMode->setCurrentIndex( theColorDicData.ColorMode ); + + myBottomColor->setColor( theColorDicData.CustomColors[0] ); + myTopColor->setColor( theColorDicData.CustomColors[1] ); + + myMajorSpecificColorScale = theColorDicData.MainSpecificColorScale; +} + +//============================================================================= +// Function : getData +// Purpose : +//============================================================================= +ColorDicData Plot3d_SetupColorScaleDlg::getData() const +{ + ColorDicData aColorDicData; + + aColorDicData.Min = myMinLimit->value(); + aColorDicData.Max = myMaxLimit->value(); + + aColorDicData.ScaleMode = (Plot3d_ColorDic::ScaleMode)colorScaleMode(); + + aColorDicData.Num = myInterval->value(); + + aColorDicData.ColorMode = myColorMode->currentIndex(); + + QColor aBottomColor = myBottomColor->color(); + QColor aTopColor = myTopColor->color(); + aColorDicData.HueMin = aBottomColor.hueF(); + aColorDicData.HueMax = aTopColor.hueF(); + aColorDicData.SaturationMin = aBottomColor.saturationF(); + aColorDicData.SaturationMax = aTopColor.saturationF(); + aColorDicData.ValueMin = aBottomColor.valueF(); + aColorDicData.ValueMax = aTopColor.valueF(); + aColorDicData.CustomColors[0] = aBottomColor; + aColorDicData.CustomColors[1] = aTopColor; + + aColorDicData.MainSpecificColorScale = myMajorSpecificColorScale; + aColorDicData.SpecificColorScale = myMinorSpecificColorScale; + + return aColorDicData; +} + +//============================================================================= +// Function : onMinMaxChanged +// Purpose : +//============================================================================= +void Plot3d_SetupColorScaleDlg::onMinMaxChanged( double value ) +{ + checkScaleMode(); +} + +//============================================================================= +// Function : onIntervalNumberChanged +// Purpose : +//============================================================================= +void Plot3d_SetupColorScaleDlg::onIntervalNumberChanged( int num ) +{ + updateColorScale(); +} + +//============================================================================= +// Function : onColorModeChanged +// Purpose : +//============================================================================= +void Plot3d_SetupColorScaleDlg::onColorModeChanged( int mode ) +{ + bool custom = false; + QColor bottomColor, topColor; + switch( mode ) + { + case Custom: + custom = true; + break; + case BlueWhite: + bottomColor = Qt::blue; + topColor = QColor( 128, 255, 255 ); + break; + case Monochrome: + bottomColor = Qt::black; + topColor = QColor( 200, 200, 200 ); + break; + case BlueRed: + default: + bottomColor = Qt::blue; + topColor = Qt::red; + } + + myBottomColor->setEnabled( custom ); + myTopColor->setEnabled( custom ); + + if( !custom ) + { + myBottomColor->setColor( bottomColor ); + myTopColor->setColor( topColor ); + } +} + +//============================================================================= +// Function : onColorScaleModeChanged +// Purpose : +//============================================================================= +void Plot3d_SetupColorScaleDlg::onColorScaleModeChanged( int mode ) +{ + checkScaleMode(); + + updateColorScale(); + updateState(); + updateMinMax(); +} + +//============================================================================= +// Function : onColorScaleSpecificSetup +// Purpose : +//============================================================================= +void Plot3d_SetupColorScaleDlg::onColorScaleSpecificSetup() +{ + Plot3d_SetupSpecificColorScaleDlg* aSetupDlg = new Plot3d_SetupSpecificColorScaleDlg( this ); + aSetupDlg->SetMajorScale( myMajorSpecificColorScale ); + + if( aSetupDlg->exec() ) + { + myMajorSpecificColorScale = aSetupDlg->GetMajorScale(); + updateColorScale(); + updateState(); + updateMinMax(); + } + delete aSetupDlg; +} + +//============================================================================= +// Function : colorScaleMode +// Purpose : +//============================================================================= +int Plot3d_SetupColorScaleDlg::colorScaleMode() const +{ + return myColorScaleMode->checkedId(); +} + +//============================================================================= +// Function : setColorScaleMode +// Purpose : +//============================================================================= +void Plot3d_SetupColorScaleDlg::setColorScaleMode( const int theMode ) +{ + if( QAbstractButton* aBtn = myColorScaleMode->button( theMode ) ) + aBtn->setChecked( true ); + onColorScaleModeChanged( theMode ); +} + +//============================================================================= +// Function : checkScaleMode +// Purpose : +//============================================================================= +int Plot3d_SetupColorScaleDlg::checkScaleMode() +{ + if ( colorScaleMode() == Plot3d_ColorDic::Logarithmic ) + { + double aCorrectValue = 1.e-6; + double aMin = myMinLimit->value(); + double aMax = myMaxLimit->value(); + bool isMinIncorrect = aMin < 0 || fabs( aMin ) < Precision::Confusion(); + bool isMaxIncorrect = aMax < 0 || fabs( aMax ) < Precision::Confusion(); + if ( isMinIncorrect || isMaxIncorrect ) + { + if ( SUIT_MessageBox::warning( this, tr( "WARNING" ), tr( "INCORRECT_RANGE" ), + tr( "CORRECT_RANGE" ), tr( "SWITCH_TO_LINEAR" ), 0, 1 ) == 0 ) + { // correct range + if ( isMinIncorrect ) + aMin = aCorrectValue; + + if ( isMaxIncorrect ) + aMax = aCorrectValue; + + bool minBlock = myMinLimit->blockSignals( true ); + bool maxBlock = myMaxLimit->blockSignals( true ); + + myMinLimit->setValue( aMin ); + myMaxLimit->setValue( aMax ); + + myMinLimit->blockSignals( minBlock ); + myMaxLimit->blockSignals( maxBlock ); + } + else // switch to linear mode + setColorScaleMode( Plot3d_ColorDic::Linear ); + } + } + return colorScaleMode(); +} + +//============================================================================= +// Function : updateState +// Purpose : +//============================================================================= +void Plot3d_SetupColorScaleDlg::updateState() +{ + bool isSpecificColorScale = colorScaleMode() == Plot3d_ColorDic::Specific; + + myMinLimit->setEnabled( !isSpecificColorScale ); + myMaxLimit->setEnabled( !isSpecificColorScale ); + + myColorMode->setEnabled( !isSpecificColorScale ); + myBottomColor->setEnabled( !isSpecificColorScale ); + myTopColor->setEnabled( !isSpecificColorScale ); + + if( isSpecificColorScale ) + { + int aNbIntervals = myMajorSpecificColorScale.count() - 1; + if( aNbIntervals > 0 ) + myInterval->setMinimum( 2 * aNbIntervals ); + } + else + myInterval->setMinimum( 2 ); +} + +//============================================================================= +// Function : updateColorScale +// Purpose : +//============================================================================= +void Plot3d_SetupColorScaleDlg::updateColorScale() +{ + if( colorScaleMode() == Plot3d_ColorDic::Specific ) + { + updateMajorSpecificColorScale(); + updateMinorSpecificColorScale(); + } +} + +//============================================================================= +// Function : updateMajorSpecificColorScale +// Purpose : +//============================================================================= +void Plot3d_SetupColorScaleDlg::updateMajorSpecificColorScale() +{ + if ( myMajorSpecificColorScale.size() < 2 ) + { + myMajorSpecificColorScale.clear(); + myMajorSpecificColorScale.append( Value2Color( myMinLimit->value(), myBottomColor->color() ) ); + myMajorSpecificColorScale.append( Value2Color( myMaxLimit->value(), myTopColor->color() ) ); + } +} + +//============================================================================= +// Function : updateMinorSpecificColorScale +// Purpose : +//============================================================================= +void Plot3d_SetupColorScaleDlg::updateMinorSpecificColorScale() +{ + myMinorSpecificColorScale.clear(); + + int aNbMajorValues = myMajorSpecificColorScale.count(); + int aNbSubIntervals = myInterval->value() / ( aNbMajorValues - 1 ); + + Value2ColorListIterator anIter( myMajorSpecificColorScale ); + Value2Color aValue2Color, aValue2ColorRef = anIter.next(); + while ( anIter.hasNext() ) + { + aValue2Color = anIter.next(); + Value2ColorList aSubList = + Plot3d_SetupSpecificColorScaleDlg::interpolateRange( aValue2ColorRef, + aValue2Color, + aNbSubIntervals ); + myMinorSpecificColorScale << aSubList; + aValue2ColorRef = aValue2Color; + } + myMinorSpecificColorScale << aValue2Color; +} + +//============================================================================= +// Function : updateMinMax +// Purpose : +//============================================================================= +void Plot3d_SetupColorScaleDlg::updateMinMax() +{ + double aMin = myMinLimit->value(); + double aMax = myMaxLimit->value(); + if ( colorScaleMode() == Plot3d_ColorDic::Specific && + !myMajorSpecificColorScale.isEmpty() ) + { + aMin = myMajorSpecificColorScale.first().first; + aMax = myMajorSpecificColorScale.last().first; + } + + myMinLimit->setValue( aMin ); + myMaxLimit->setValue( aMax ); +} diff --git a/src/Plot3d/Plot3d_SetupColorScaleDlg.h b/src/Plot3d/Plot3d_SetupColorScaleDlg.h new file mode 100644 index 000000000..3287c8790 --- /dev/null +++ b/src/Plot3d/Plot3d_SetupColorScaleDlg.h @@ -0,0 +1,109 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef PLOT3D_SETUPCOLORSCALEDLG_H +#define PLOT3D_SETUPCOLORSCALEDLG_H + +#include "Plot3d.h" + +#include "Plot3d_ColorDic.h" + +#include + +class QButtonGroup; +class QComboBox; +class QDoubleSpinBox; + +class QtxColorButton; +class QtxIntSpinBox; + +class Plot3d_ColorDic; + +struct ColorDicData +{ + int Num; + double Min, Max; + double HueMin, HueMax; + double SaturationMin, SaturationMax; + double ValueMin, ValueMax; + Plot3d_ColorDic::ScaleMode ScaleMode; + Value2ColorList MainSpecificColorScale; + Value2ColorList SpecificColorScale; + int TimeStep; + TCollection_AsciiString Quantity; + int ColorMode; + QColor CustomColors[2]; +}; + +typedef QList < ColorDicData > ColorDicDataList; +typedef QListIterator< ColorDicData > ColorDicDataListIterator; + +/* + Class : Plot3d_SetupColorScaleDlg + Description : Dialog box for setup color scale +*/ +class PLOT3D_EXPORT Plot3d_SetupColorScaleDlg : public QtxDialog +{ + Q_OBJECT + +public: + enum { BlueRed = 0, BlueWhite, Monochrome, Custom }; + +public: + Plot3d_SetupColorScaleDlg( QWidget* theParent = 0 ); + virtual ~Plot3d_SetupColorScaleDlg(); + + void setData( const ColorDicData& theColorDicData ); + ColorDicData getData() const; + +private slots: + void onMinMaxChanged( double ); + void onIntervalNumberChanged( int ); + void onColorModeChanged( int ); + void onColorScaleModeChanged( int ); + void onColorScaleSpecificSetup(); + +private: + int colorScaleMode() const; + void setColorScaleMode( const int ); + + int checkScaleMode(); + + void updateState(); + void updateColorScale(); + void updateMajorSpecificColorScale(); + void updateMinorSpecificColorScale(); + void updateMinMax(); + +private: + QtxIntSpinBox* myInterval; + + QComboBox* myColorMode; + QtxColorButton* myBottomColor; + QtxColorButton* myTopColor; + + QButtonGroup* myColorScaleMode; + + QDoubleSpinBox* myMinLimit; + QDoubleSpinBox* myMaxLimit; + + Value2ColorList myMajorSpecificColorScale; + Value2ColorList myMinorSpecificColorScale; +}; + +#endif diff --git a/src/Plot3d/Plot3d_SetupSpecificColorScaleDlg.cxx b/src/Plot3d/Plot3d_SetupSpecificColorScaleDlg.cxx new file mode 100644 index 000000000..bcde47937 --- /dev/null +++ b/src/Plot3d/Plot3d_SetupSpecificColorScaleDlg.cxx @@ -0,0 +1,945 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "Plot3d_SetupSpecificColorScaleDlg.h" + +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define VALUE_COL 0 +#define COLOR_COL 1 + +static const LDOMString NB_INTERVALS; +static const LDOMString VALUE; +static const LDOMString AUTO_VALUES; +static const LDOMString STATE; +static const LDOMString MIN; +static const LDOMString MAX; +static const LDOMString LOGARITHMIC; +static const LDOMString AUTO_COLORS; +static const LDOMString RED; +static const LDOMString GREEN; +static const LDOMString BLUE; +static const LDOMString COLOR_SCALE; +static const LDOMString SCALE_POINT; +static const LDOMString COLOR; + +//============================================================================= +// Function : initDomStringConstants +// Purpose : +//============================================================================= +static void initDomStringConstants() +{ + if( NB_INTERVALS == NULL ) + { + (LDOMString&) NB_INTERVALS = LDOMString( "NumberOfIntervals" ); + (LDOMString&) VALUE = LDOMString( "value" ); + + (LDOMString&) AUTO_VALUES = LDOMString( "AutoValues" ); + (LDOMString&) STATE = LDOMString( "state" ); + (LDOMString&) MIN = LDOMString( "min" ); + (LDOMString&) MAX = LDOMString( "max" ); + (LDOMString&) LOGARITHMIC = LDOMString( "logarithmic" ); + + (LDOMString&) AUTO_COLORS = LDOMString( "AutoColors" ); + (LDOMString&) RED = LDOMString( "red" ); + (LDOMString&) GREEN = LDOMString( "green" ); + (LDOMString&) BLUE = LDOMString( "blue" ); + + (LDOMString&) COLOR_SCALE = LDOMString( "ColorScale" ); + (LDOMString&) SCALE_POINT = LDOMString( "ScalePoint" ); + (LDOMString&) COLOR = LDOMString( "color" ); + } +} + +/* + Class : Plot3d_SetupSpecificColorScaleDlg::ItemDelegate + Description : Class, which provides editing facilities for data items from a model +*/ +class Plot3d_SetupSpecificColorScaleDlg::ItemDelegate : public QItemDelegate +{ +public: + ItemDelegate( QObject* = 0 ); + +public: + virtual QWidget* createEditor( QWidget*, const QStyleOptionViewItem&, const QModelIndex& ) const; + virtual void updateEditorGeometry( QWidget*, const QStyleOptionViewItem&, const QModelIndex& ) const; + +private: + QDoubleValidator* myDoubleValidator; +}; + +//============================================================================= +// Function : Plot3d_SetupSpecificColorScaleDlg::ItemDelegate +// Purpose : Constructor +//============================================================================= +Plot3d_SetupSpecificColorScaleDlg::ItemDelegate::ItemDelegate( QObject* theParent ) +: QItemDelegate( theParent ) +{ + myDoubleValidator = new QDoubleValidator( this ); + myDoubleValidator->setDecimals( 6 ); +} + +//============================================================================= +// Function : createEditor +// Purpose : +//============================================================================= +QWidget* Plot3d_SetupSpecificColorScaleDlg::ItemDelegate::createEditor( QWidget* theParent, + const QStyleOptionViewItem& theOption, + const QModelIndex& ) const +{ + QLineEdit* aLineEdit = new QLineEdit( theParent ); + aLineEdit->setValidator( myDoubleValidator ); + return aLineEdit; +} + +//============================================================================= +// Function : updateEditorGeometry +// Purpose : +//============================================================================= +void Plot3d_SetupSpecificColorScaleDlg::ItemDelegate::updateEditorGeometry( QWidget* theEditor, + const QStyleOptionViewItem& theOption, + const QModelIndex& ) const +{ + theEditor->setGeometry( theOption.rect ); +} + + +//============================================================================= +// Function : Plot3d_SetupSpecificColorScaleDlg +// Purpose : Constructor +//============================================================================= +Plot3d_SetupSpecificColorScaleDlg::Plot3d_SetupSpecificColorScaleDlg( QWidget* theParent ) +: QtxDialog( theParent, true, false, QtxDialog::OKCancel ) +{ + setWindowTitle( tr( "SETUP_SPECIFIC_COLOR_SCALE" ) ); + + QFrame* aMainFrame = mainFrame(); + + QVBoxLayout* aMainLayout = new QVBoxLayout( aMainFrame ); + aMainLayout->setMargin( 5 ); + aMainLayout->setSpacing( 5 ); + + // Parameters + QtxGroupBox* aParametersGrp = new QtxGroupBox( tr( "PARAMETERS" ), aMainFrame ); + aMainLayout->addWidget( aParametersGrp ); + + // Number of specific intervals + QLabel* aNbSpecificIntervalsLabel = new QLabel( tr( "NUMBER_OF_SPECIFIC_INTERVALS" ), aParametersGrp ); + myNbSpecificIntervalsSpinBox = new QSpinBox( aParametersGrp ); + myNbSpecificIntervalsSpinBox->setRange( 1, 99 ); + myNbSpecificIntervalsSpinBox->setValue( 1 ); + + // Auto values + myAutoValues = new QtxGroupBox( tr( "AUTO_VALUES" ), aParametersGrp ); + myAutoValues->setCheckable( true ); + myAutoValues->setChecked( true ); + + QLabel* aMinimumValueLabel = new QLabel( tr( "MINIMUM" ), myAutoValues ); + myMinimumSpinBox = new QDoubleSpinBox( myAutoValues ); + myMinimumSpinBox->setMinimum( -DBL_MAX ); + myMinimumSpinBox->setMaximum( DBL_MAX ); + myMinimumSpinBox->setDecimals( 6 ); + + QLabel* aMaximumValueLabel = new QLabel( tr( "MAXIMUM" ), myAutoValues ); + myMaximumSpinBox = new QDoubleSpinBox( myAutoValues ); + myMaximumSpinBox->setMinimum( -DBL_MAX ); + myMaximumSpinBox->setMaximum( DBL_MAX ); + myMaximumSpinBox->setDecimals( 6 ); + + myIsLogarithmic = new QCheckBox( tr( "LOGARITHMIC_INTERPOLATION" ) ); + myIsLogarithmic->setChecked( false ); + + QGridLayout* anAutoValuesLayout = new QGridLayout( myAutoValues ); + anAutoValuesLayout->setMargin( 5 ); + anAutoValuesLayout->setSpacing( 5 ); + anAutoValuesLayout->addWidget( aMinimumValueLabel, 0, 0, 1, 1 ); + anAutoValuesLayout->addWidget( myMinimumSpinBox, 0, 1, 1, 1 ); + anAutoValuesLayout->addWidget( aMaximumValueLabel, 1, 0, 1, 1 ); + anAutoValuesLayout->addWidget( myMaximumSpinBox, 1, 1, 1, 1 ); + anAutoValuesLayout->addWidget( myIsLogarithmic, 2, 0, 1, 2 ); + + // Auto colors + myAutoColors = new QtxGroupBox( tr( "AUTO_COLORS" ), aParametersGrp ); + myAutoColors->setCheckable( true ); + myAutoColors->setChecked( true ); + + QLabel* aMinimumColorLabel = new QLabel( tr( "MINIMUM" ), myAutoColors ); + myMinimumBtn = new QtxColorButton( myAutoColors ); + + QLabel* aMaximumColorLabel = new QLabel( tr( "MAXIMUM" ), myAutoColors ); + myMaximumBtn = new QtxColorButton( myAutoColors ); + + QGridLayout* anAutoColorsLayout = new QGridLayout( myAutoColors ); + anAutoColorsLayout->setMargin( 5 ); + anAutoColorsLayout->setSpacing( 5 ); + anAutoColorsLayout->addWidget( aMinimumColorLabel, 0, 0, 1, 1 ); + anAutoColorsLayout->addWidget( myMinimumBtn, 0, 1, 1, 1 ); + anAutoColorsLayout->addWidget( aMaximumColorLabel, 0, 2, 1, 1 ); + anAutoColorsLayout->addWidget( myMaximumBtn, 0, 3, 1, 1 ); + + // Generate table + myGenerateButton = new QPushButton( tr( "GENERATE_TABLE" ), aParametersGrp ); + + // Common + QGridLayout* aParametersLayout = new QGridLayout( aParametersGrp ); + aParametersLayout->setMargin( 5 ); + aParametersLayout->setSpacing( 5 ); + aParametersLayout->addWidget( aNbSpecificIntervalsLabel, 0, 0, 1, 1 ); + aParametersLayout->addWidget( myNbSpecificIntervalsSpinBox, 0, 1, 1, 1 ); + aParametersLayout->addWidget( myAutoValues, 1, 0, 1, 2 ); + aParametersLayout->addWidget( myAutoColors, 2, 0, 1, 2 ); + aParametersLayout->addWidget( myGenerateButton, 3, 0, 1, 2 ); + + // Color scale + QtxGroupBox* aColorScaleGrp = new QtxGroupBox( tr( "COLOR_SCALE" ), aMainFrame ); + aMainLayout->addWidget( aColorScaleGrp ); + + // Table + myTable = new QTableWidget( aColorScaleGrp ); + myTable->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + + myTable->setRowCount( 0 ); + myTable->setColumnCount( 2 ); + + QStringList aLabels; + aLabels.append( tr( "VALUE" ) ); + aLabels.append( tr( "COLOR" ) ); + myTable->setHorizontalHeaderLabels( aLabels ); + myTable->setSelectionMode( QTableWidget::NoSelection ); + + myTable->horizontalHeader()->setResizeMode( VALUE_COL, QHeaderView::Fixed ); + myTable->horizontalHeader()->setResizeMode( COLOR_COL, QHeaderView::Fixed ); + myTable->horizontalHeader()->setHighlightSections( false ); + myTable->verticalHeader()->setHighlightSections( false ); + + myTable->setColumnWidth( VALUE_COL, 150 ); + myTable->setColumnWidth( COLOR_COL, 50 ); + + myTable->setItemDelegateForColumn( VALUE_COL, new Plot3d_SetupSpecificColorScaleDlg::ItemDelegate( myTable ) ); + + QBoxLayout* aColorScaleLayout = new QVBoxLayout( aColorScaleGrp ); + aColorScaleLayout->setMargin( 5 ); + aColorScaleLayout->setSpacing( 5 ); + aColorScaleLayout->addWidget( myTable ); + + // Import/export setting + QtxGroupBox* anImportExportGrp = new QtxGroupBox( tr( "IMPORT_EXPORT_SETTINGS" ), aMainFrame ); + aMainLayout->addWidget( anImportExportGrp ); + + QPushButton* anImportButton = new QPushButton( tr( "IMPORT_SETTINGS" ), anImportExportGrp ); + QPushButton* anExportButton = new QPushButton( tr( "EXPORT_SETTINGS" ), anImportExportGrp ); + + QBoxLayout* anImportExportLayout = new QHBoxLayout( anImportExportGrp ); + anImportExportLayout->setMargin( 5 ); + anImportExportLayout->setSpacing( 5 ); + anImportExportLayout->addWidget( anImportButton ); + anImportExportLayout->addWidget( anExportButton ); + + connect( myGenerateButton, SIGNAL( clicked() ), this, SLOT( onGenerateTable() ) ); + connect( anImportButton, SIGNAL( clicked() ), this, SLOT( onImportSettings() ) ); + connect( anExportButton, SIGNAL( clicked() ), this, SLOT( onExportSettings() ) ); + + setButtonPosition( Right, Cancel ); + setMinimumHeight( 600 ); +} + +//============================================================================= +// Function : ~Plot3d_SetupSpecificColorScaleDlg +// Purpose : Destructor +//============================================================================= +Plot3d_SetupSpecificColorScaleDlg::~Plot3d_SetupSpecificColorScaleDlg() +{ +} + +//============================================================================= +// Function : SetMajorScale +// Purpose : +//============================================================================= +void Plot3d_SetupSpecificColorScaleDlg::SetMajorScale( const Value2ColorList& theMajorScale ) +{ + int aNbValues = theMajorScale.count(); + myNbSpecificIntervalsSpinBox->setValue( aNbValues - 1 ); + + if ( aNbValues >= 2 ) + { + Value2Color aValue2ColorMin = theMajorScale.first(); + myMinimumSpinBox->setValue( aValue2ColorMin.first ); + myMinimumBtn->setColor( aValue2ColorMin.second ); + + Value2Color aValue2ColorMax = theMajorScale.last(); + myMaximumSpinBox->setValue( aValue2ColorMax.first ); + myMaximumBtn->setColor( aValue2ColorMax.second ); + } + + updateTable( theMajorScale ); +} + +//============================================================================= +// Function : SetNewVar +// Purpose : +//============================================================================= +void Plot3d_SetupSpecificColorScaleDlg::SetNewVar( const bool theIsNew, + const double theMin, + const double theMax ) +{ + if ( theIsNew ) + { + myMinimumSpinBox->setValue( theMin ); + myMaximumSpinBox->setValue( theMax ); + myGenerateButton->setText( tr( "GENERATE_TABLE_FOR_NEW" ) ); + } + else + myGenerateButton->setText( tr( "GENERATE_TABLE" ) ); +} + +//============================================================================= +// Function : GetMajorScale +// Purpose : +//============================================================================= +const Value2ColorList& Plot3d_SetupSpecificColorScaleDlg::GetMajorScale() const +{ + return myMajorScale; +} + +//============================================================================= +// Function : accept +// Purpose : +//============================================================================= +void Plot3d_SetupSpecificColorScaleDlg::accept() +{ + QString aMessage; + + myMajorScale.clear(); + int aNbValues = myTable->rowCount(); + for ( int aRow = 0; aRow < aNbValues; aRow++ ) + { + Value2Color aValue2Color; + + double aValue = 0.0; + bool ok = value( aRow, aValue ); + if ( !ok ) + { + aMessage = tr( "WRN_UNINITIALIZED_VALUES" ); + break; + } + aValue2Color.first = aValue; + + QPushButton* aBtn = dynamic_cast< QPushButton* >( myTable->cellWidget( aRow, COLOR_COL ) ); + aValue2Color.second = color( aBtn ); + + myMajorScale.append( aValue2Color ); + } + + if ( !aMessage.isEmpty() || !checkMajorScale( aMessage ) ) + { + SUIT_MessageBox::warning( this, tr( "WARNING" ), aMessage ); + myMajorScale.clear(); + return; + } + + QtxDialog::accept(); +} + +//============================================================================= +// Function : onGenerateTable +// Purpose : +//============================================================================= +void Plot3d_SetupSpecificColorScaleDlg::onGenerateTable() +{ + int aNbIntervals = myNbSpecificIntervalsSpinBox->value(); + + double aMinimumValue = myMinimumSpinBox->value(); + double aMaximumValue = myMaximumSpinBox->value(); + bool anIsLogarithmic = myIsLogarithmic->isChecked(); + + QString aMessage; + if ( aMinimumValue > aMaximumValue || + fabs( aMaximumValue - aMinimumValue ) < Precision::Confusion() ) + aMessage = tr( "WRN_INCORRECT_RANGE_MIN_MAX" ); + else if ( anIsLogarithmic && + ( aMinimumValue < 0 || fabs( aMinimumValue ) < Precision::Confusion() || + aMaximumValue < 0 || fabs( aMaximumValue ) < Precision::Confusion() ) ) + aMessage = tr( "WRN_INCORRECT_RANGE_LOGARITHMIC" ); + + if ( !aMessage.isEmpty() ) + { + SUIT_MessageBox::warning( this, tr( "WARNING" ), aMessage ); + return; + } + + Value2Color aMinimum( aMinimumValue, myMinimumBtn->color() ); + Value2Color aMaximum( aMaximumValue, myMaximumBtn->color() ); + + Value2ColorList aData = interpolateRange( aMinimum, aMaximum, aNbIntervals - 1, true, anIsLogarithmic ); + aData.prepend( aMinimum ); + aData.append( aMaximum ); + + updateTable( aData ); +} + +//============================================================================= +// Function : onColorBtn +// Purpose : +//============================================================================= +void Plot3d_SetupSpecificColorScaleDlg::onColorBtn() +{ + QObject* aSender = (QObject*)sender(); + if ( !aSender ) + return; + + QPushButton* aBtn = dynamic_cast< QPushButton* >( aSender ); + if ( !aBtn ) + return; + + QColor anOldColor = color( aBtn ); + QColor aNewColor = QColorDialog::getColor( anOldColor, this ); + if ( !aNewColor.isValid() ) + return; + + setColor( aBtn, aNewColor ); +} + +//============================================================================= +// Function : clearTable +// Purpose : +//============================================================================= +void Plot3d_SetupSpecificColorScaleDlg::clearTable() +{ + QList aButtonList = myTable->findChildren(); + for ( int i = 0, n = aButtonList.count(); i < n; i++ ) + { + if( QPushButton* aButton = aButtonList.at( i ) ) + { + delete aButton; + aButton = 0; + } + } + aButtonList.clear(); + + myTable->setRowCount( 0 ); +} + +//============================================================================= +// Function : updateTable +// Purpose : +//============================================================================= +void Plot3d_SetupSpecificColorScaleDlg::updateTable( const Value2ColorList& theMajorScale ) +{ + int aNbValues = theMajorScale.count(); + myNbSpecificIntervalsSpinBox->setValue( aNbValues - 1 ); + + clearTable(); + + myTable->setRowCount( aNbValues ); + + int aRow = 0; + Value2ColorListIterator anIter( theMajorScale ); + while ( anIter.hasNext() ) + { + Value2Color aValue2Color = anIter.next(); + + // Value + if( myAutoValues->isChecked() ) + setValue( aRow, aValue2Color.first ); + + // Color + setColor( aRow, ( myAutoColors->isChecked() ) ? aValue2Color.second : Qt::black ); + + aRow++; + } +} + +//============================================================================= +// Function : value +// Purpose : +//============================================================================= +bool Plot3d_SetupSpecificColorScaleDlg::value( const int theRow, double& theValue ) const +{ + if ( QTableWidgetItem* anItem = myTable->item( theRow, VALUE_COL ) ) + { + QString aText = anItem->text(); + bool ok = false; + theValue = aText.toDouble( &ok ); + return ok; + } + return false; +} + +//============================================================================= +// Function : setValue +// Purpose : +//============================================================================= +void Plot3d_SetupSpecificColorScaleDlg::setValue( const int theRow, const double theValue ) +{ + setValue( theRow, QString::number( theValue ) ); +} + +//============================================================================= +// Function : setValue +// Purpose : +//============================================================================= +void Plot3d_SetupSpecificColorScaleDlg::setValue( const int theRow, const QString& theValue ) +{ + QTableWidgetItem* anItem = myTable->item( theRow, VALUE_COL ); + if ( !anItem ) + { + anItem = new QTableWidgetItem( theValue ); + myTable->setItem( theRow, VALUE_COL, anItem ); + } + else + anItem->setText( theValue ); +} + +//============================================================================= +// Function : setColor +// Purpose : +//============================================================================= +void Plot3d_SetupSpecificColorScaleDlg::setColor( QPushButton* theBtn, const QColor& theColor ) +{ + if( theBtn ) + { + QPalette aPal = theBtn->palette(); + aPal.setColor( theBtn->backgroundRole(), theColor ); + theBtn->setPalette( aPal ); + } +} + +//============================================================================= +// Function : setColor +// Purpose : +//============================================================================= +void Plot3d_SetupSpecificColorScaleDlg::setColor( const int theRow, const QColor& theColor ) +{ + QPushButton* aBtn = new QPushButton( myTable ); + myTable->setCellWidget( theRow, COLOR_COL, aBtn ); + setColor( aBtn, theColor ); + connect( aBtn, SIGNAL( clicked() ), SLOT( onColorBtn() ) ); +} + +//============================================================================= +// Function : color +// Purpose : +//============================================================================= +QColor Plot3d_SetupSpecificColorScaleDlg::color( QPushButton* theBtn ) const +{ + return theBtn ? theBtn->palette().color( theBtn->backgroundRole() ) : QColor(); +} + +//============================================================================= +// Function : setEditable +// Purpose : +//============================================================================= +void Plot3d_SetupSpecificColorScaleDlg::setEditable( const int theRow, + const int theCol, + const bool theState ) +{ + QTableWidgetItem* anItem = myTable->item( theRow, theCol ); + if ( !anItem ) + { + anItem = new QTableWidgetItem(); + myTable->setItem( theRow, theCol, anItem ); + } + + Qt::ItemFlags aFlags = anItem->flags(); + aFlags = theState ? aFlags | Qt::ItemIsEditable : aFlags ^ Qt::ItemIsEditable; + anItem->setFlags( aFlags ); +} + +//============================================================================= +// Function : checkMajorScale +// Purpose : +//============================================================================= +bool Plot3d_SetupSpecificColorScaleDlg::checkMajorScale( QString& theMessage ) const +{ + if ( myMajorScale.count() < 2 ) + return false; + + // check data + Value2ColorListIterator anIter( myMajorScale ); + Value2Color aValue2Color, aValue2ColorRef = anIter.next(); + while ( anIter.hasNext() ) + { + aValue2Color = anIter.next(); + if ( aValue2Color.first < aValue2ColorRef.first ) + { + theMessage = tr( "WRN_INCONSISTENT_VALUES" ); + return false; + } + aValue2ColorRef = aValue2Color; + } + + return true; +} + +//============================================================================= +// Function : interpolateRange +// Purpose : +//============================================================================= +Value2ColorList Plot3d_SetupSpecificColorScaleDlg::interpolateRange( const Value2Color& theMinimum, + const Value2Color& theMaximum, + const int theNumber, + const bool theIsMajor, + const bool theIsLogarithmic ) +{ + Value2ColorList aResult; + + double aMin = theMinimum.first; + QColor aColorMin = theMinimum.second; + double aHueMin = aColorMin.hueF(); + double aSaturationMin = aColorMin.saturationF(); + double aValueMin = aColorMin.valueF(); + + double aMax = theMaximum.first; + QColor aColorMax = theMaximum.second; + double aHueMax = aColorMax.hueF(); + double aSaturationMax = aColorMax.saturationF(); + double aValueMax = aColorMax.valueF(); + + // additional check for achromatic colors, which + // have a hue value of -1 (see CATHAREGUI_ColorDic) + double aHueMinTmp = aHueMin; + double aHueMaxTmp = aHueMax; + aHueMin = aHueMinTmp < 0 ? aHueMaxTmp : aHueMinTmp; + aHueMax = aHueMaxTmp < 0 ? aHueMinTmp : aHueMaxTmp; + + double aRange[2] = { aMin, aMax }; + + vtkLookupTable* aLookupTable = vtkLookupTable::New(); + aLookupTable->SetRange( aRange ); + aLookupTable->SetNumberOfTableValues( theNumber + ( theIsMajor ? 2 : 0 ) ); + + aLookupTable->SetHueRange( aHueMin, aHueMax ); + aLookupTable->SetSaturationRange( aSaturationMin, aSaturationMax ); + aLookupTable->SetValueRange( aValueMin, aValueMax ); + + aLookupTable->Build(); + + int anIndexFirst = 0; + int anIndexLast = theNumber - 1; + int aNumber = theNumber; + if ( theIsMajor ) + { + anIndexFirst++; + anIndexLast++; + aNumber++; + } + + if ( theIsLogarithmic ) + { + if ( aMin > 0 && aMax > 0 ) + { + aMin = log10( aMin ); + aMax = log10( aMax ); + } + else + return aResult; + } + + double rgba[4]; + Value2Color aValue2Color; + for ( int anIndex = anIndexFirst; anIndex <= anIndexLast; anIndex++ ) + { + aLookupTable->GetTableValue( anIndex, rgba ); + double aValue = aMin + ( aMax - aMin ) * (double)anIndex / (double)( aNumber ); + aValue2Color.first = theIsLogarithmic ? pow( 10, aValue ) : aValue; + aValue2Color.second.setRgbF( rgba[0], rgba[1], rgba[2] ); + aResult.append( aValue2Color ); + } + + aLookupTable->Delete(); + + return aResult; +} + +//============================================================================= +// Function : onImportSettings +// Purpose : +//============================================================================= +void Plot3d_SetupSpecificColorScaleDlg::onImportSettings() +{ + char* aHomePath = getenv( "HOME" ); + QString aPath = aHomePath ? aHomePath : ""; + + QString aFilter = tr( "XML_FILTER" ); + QString aFileName = QFileDialog::getOpenFileName( this, tr( "IMPORT_SETTINGS" ), aPath, aFilter ); + if( aFileName.isEmpty() ) + return; + + QApplication::setOverrideCursor( Qt::WaitCursor ); + + ::initDomStringConstants(); + + LDOMParser aParser; + if( aParser.parse( aFileName.toLatin1().constData() ) ) + { + QApplication::restoreOverrideCursor(); + SUIT_MessageBox::critical( this, tr( "ERROR" ), tr( "IMPORT_FAILED" ), tr( "BUT_OK" ) ); + return; + } + + LDOM_Document aDoc = aParser.getDocument(); + LDOM_Element aDocElement = aDoc.getDocumentElement(); + + LDOM_Element anElement, aSubElement, aSubElement2; + TCollection_AsciiString aString, aStringR, aStringG, aStringB; + QColor aColor; + + // Number of specific intervals + anElement = aDocElement.GetChildByTagName( NB_INTERVALS ); + if( !anElement.isNull() ) + { + aString = anElement.getAttribute( VALUE ); + if( aString.IsIntegerValue() ) + myNbSpecificIntervalsSpinBox->setValue( aString.IntegerValue() ); + } + + // Auto values + anElement = aDocElement.GetChildByTagName( AUTO_VALUES ); + if( !anElement.isNull() ) + { + aString = anElement.getAttribute( STATE ); + if( aString.IsIntegerValue() ) + myAutoValues->setChecked( (bool)aString.IntegerValue() ); + + aString = anElement.getAttribute( MIN ); + if( aString.IsRealValue() ) + myMinimumSpinBox->setValue( aString.RealValue() ); + + aString = anElement.getAttribute( MAX ); + if( aString.IsRealValue() ) + myMaximumSpinBox->setValue( aString.RealValue() ); + + aString = anElement.getAttribute( LOGARITHMIC ); + if( aString.IsIntegerValue() ) + myIsLogarithmic->setChecked( (bool)aString.IntegerValue() ); + } + + // Auto colors + anElement = aDocElement.GetChildByTagName( AUTO_COLORS ); + if( !anElement.isNull() ) + { + aString = anElement.getAttribute( STATE ); + if( aString.IsIntegerValue() ) + myAutoColors->setChecked( (bool)aString.IntegerValue() ); + + aSubElement = anElement.GetChildByTagName( MIN ); + if( !aSubElement.isNull() ) + { + aStringR = aSubElement.getAttribute( RED ); + aStringG = aSubElement.getAttribute( GREEN ); + aStringB = aSubElement.getAttribute( BLUE ); + if( aStringR.IsIntegerValue() && + aStringG.IsIntegerValue() && + aStringB.IsIntegerValue() ) + { + QColor aColor( aStringR.IntegerValue(), + aStringG.IntegerValue(), + aStringB.IntegerValue() ); + myMinimumBtn->setColor( aColor ); + } + } + + aSubElement = anElement.GetChildByTagName( MAX ); + if( !aSubElement.isNull() ) + { + aStringR = aSubElement.getAttribute( RED ); + aStringG = aSubElement.getAttribute( GREEN ); + aStringB = aSubElement.getAttribute( BLUE ); + if( aStringR.IsIntegerValue() && + aStringG.IsIntegerValue() && + aStringB.IsIntegerValue() ) + { + QColor aColor( aStringR.IntegerValue(), + aStringG.IntegerValue(), + aStringB.IntegerValue() ); + myMaximumBtn->setColor( aColor ); + } + } + } + + // Color scale + int aRow = 0; + clearTable(); + anElement = aDocElement.GetChildByTagName( COLOR_SCALE ); + for( aSubElement = anElement.GetChildByTagName( SCALE_POINT ); + !aSubElement.isNull(); + aSubElement = aSubElement.GetSiblingByTagName(), aRow++ ) + { + aString = aSubElement.getAttribute( VALUE ); + + QColor aColor; + aSubElement2 = aSubElement.GetChildByTagName( COLOR ); + if( !aSubElement2.isNull() ) + { + aStringR = aSubElement2.getAttribute( RED ); + aStringG = aSubElement2.getAttribute( GREEN ); + aStringB = aSubElement2.getAttribute( BLUE ); + if( aStringR.IsIntegerValue() && + aStringG.IsIntegerValue() && + aStringB.IsIntegerValue() ) + aColor = QColor( aStringR.IntegerValue(), + aStringG.IntegerValue(), + aStringB.IntegerValue() ); + } + + myTable->setRowCount( aRow + 1 ); + setValue( aRow, QString( aString.ToCString() ) ); + setColor( aRow, aColor ); + } + + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +// Function : onExportSettings +// Purpose : +//============================================================================= +void Plot3d_SetupSpecificColorScaleDlg::onExportSettings() +{ + char* aHomePath = getenv( "HOME" ); + QString aPath = aHomePath ? aHomePath : ""; + + QString aFilter = tr( "XML_FILTER" ); + QString aSelectedFilter; + QString aFileName = QFileDialog::getSaveFileName( this, tr( "EXPORT_SETTINGS" ), aPath, + aFilter, &aSelectedFilter ); + if( aFileName.isEmpty() ) + return; + + if( aSelectedFilter.indexOf( "xml" ) != -1 ) + { + QString aSuffix = QFileInfo( aFileName ).suffix(); + if( aSuffix.toLower() != "xml" ) + aFileName += ".xml"; + } + + QApplication::setOverrideCursor( Qt::WaitCursor ); + + ::initDomStringConstants(); + + LDOM_Document aDoc = LDOM_Document::createDocument( "Settings" ); + LDOM_Element aDocElement = aDoc.getDocumentElement(); + + // Number of specific intervals + LDOM_Element aNbIntervalsElement = aDoc.createElement( NB_INTERVALS ); + aNbIntervalsElement.setAttribute( VALUE, LDOMString( myNbSpecificIntervalsSpinBox->value() ) ); + aDocElement.appendChild( aNbIntervalsElement ); + + // Auto values + TCollection_AsciiString aMinValue( myMinimumSpinBox->value() ); + TCollection_AsciiString aMaxValue( myMaximumSpinBox->value() ); + + LDOM_Element anAutoValuesElement = aDoc.createElement( AUTO_VALUES ); + anAutoValuesElement.setAttribute( STATE, LDOMString( (int)myAutoValues->isChecked() ) ); + anAutoValuesElement.setAttribute( MIN, LDOMString( aMinValue.ToCString() ) ); + anAutoValuesElement.setAttribute( MAX, LDOMString( aMaxValue.ToCString() ) ); + anAutoValuesElement.setAttribute( LOGARITHMIC, LDOMString( (int)myIsLogarithmic->isChecked() ) ); + aDocElement.appendChild( anAutoValuesElement ); + + // Auto colors + QColor aMinColor( myMinimumBtn->color() ); + QColor aMaxColor( myMaximumBtn->color() ); + + LDOM_Element anAutoColorsElement = aDoc.createElement( AUTO_COLORS ); + anAutoColorsElement.setAttribute( STATE, LDOMString( (int)myAutoColors->isChecked() ) ); + + LDOM_Element aMinColorElement = aDoc.createElement( MIN ); + aMinColorElement.setAttribute( RED, LDOMString( aMinColor.red() ) ); + aMinColorElement.setAttribute( GREEN, LDOMString( aMinColor.green() ) ); + aMinColorElement.setAttribute( BLUE, LDOMString( aMinColor.blue() ) ); + anAutoColorsElement.appendChild( aMinColorElement ); + + LDOM_Element aMaxColorElement = aDoc.createElement( MAX ); + aMaxColorElement.setAttribute( RED, LDOMString( aMaxColor.red() ) ); + aMaxColorElement.setAttribute( GREEN, LDOMString( aMaxColor.green() ) ); + aMaxColorElement.setAttribute( BLUE, LDOMString( aMaxColor.blue() ) ); + anAutoColorsElement.appendChild( aMaxColorElement ); + + aDocElement.appendChild( anAutoColorsElement ); + + // Color scale + LDOM_Element aColorScaleElement = aDoc.createElement( COLOR_SCALE ); + + int aNbValues = myTable->rowCount(); + for( int aRow = 0; aRow < aNbValues; aRow++ ) + { + QString aValue; + if( QTableWidgetItem* anItem = myTable->item( aRow, VALUE_COL ) ) + aValue = anItem->text(); + + QPushButton* aBtn = dynamic_cast< QPushButton* >( myTable->cellWidget( aRow, COLOR_COL ) ); + QColor aColor = color( aBtn ); + + LDOM_Element aScalePointElement = aDoc.createElement( SCALE_POINT ); + aScalePointElement.setAttribute( VALUE, LDOMString( aValue.toLatin1().constData() ) ); + + LDOM_Element aColorElement = aDoc.createElement( COLOR ); + aColorElement.setAttribute( RED, LDOMString( aColor.red() ) ); + aColorElement.setAttribute( GREEN, LDOMString( aColor.green() ) ); + aColorElement.setAttribute( BLUE, LDOMString( aColor.blue() ) ); + aScalePointElement.appendChild( aColorElement ); + + aColorScaleElement.appendChild( aScalePointElement ); + } + aDocElement.appendChild( aColorScaleElement ); + + // Write data to file + FILE* aFile = fopen( aFileName.toLatin1().constData(), "wt" ); + if( aFile ) + { + LDOM_XmlWriter aWriter( aFile ); + aWriter.SetIndentation( 2 ); + aWriter << aDoc; + fclose( aFile ); + } + else + { + QApplication::restoreOverrideCursor(); + SUIT_MessageBox::critical( this, tr( "ERROR" ), tr( "EXPORT_FAILED" ), tr( "BUT_OK" ) ); + } + + QApplication::restoreOverrideCursor(); +} diff --git a/src/Plot3d/Plot3d_SetupSpecificColorScaleDlg.h b/src/Plot3d/Plot3d_SetupSpecificColorScaleDlg.h new file mode 100644 index 000000000..fbcacdbfe --- /dev/null +++ b/src/Plot3d/Plot3d_SetupSpecificColorScaleDlg.h @@ -0,0 +1,113 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef PLOT3D_SETUPSPECIFICCOLORSCALEDLG_H +#define PLOT3D_SETUPSPECIFICCOLORSCALEDLG_H + +#include "Plot3d.h" + +#include "Plot3d_ColorDic.h" + +#include + +class QtxColorButton; +class QtxGroupBox; + +class QCheckBox; +class QSpinBox; +class QDoubleSpinBox; +class QTableWidget; +class QTableWidgetItem; + +/* + Class : Plot3d_SetupSpecificColorScaleDlg + Description : Dialog box for setup specific color scale +*/ +class PLOT3D_EXPORT Plot3d_SetupSpecificColorScaleDlg : public QtxDialog +{ + Q_OBJECT + + class ItemDelegate; + +public: + Plot3d_SetupSpecificColorScaleDlg( QWidget* theParent = 0 ); + virtual ~Plot3d_SetupSpecificColorScaleDlg(); + + void SetMajorScale( const Value2ColorList& theMajorScale ); + const Value2ColorList& GetMajorScale() const; + + void SetNewVar( const bool theIsNew, + const double theMin = 0, + const double theMax = 0 ); + + static Value2ColorList interpolateRange( const Value2Color& theMinimum, + const Value2Color& theMaximum, + const int theNumber, + const bool theIsMajor = false, + const bool theIsLogarithmic = false ); + +protected slots: + virtual void accept(); + +private slots: + void onGenerateTable(); + void onColorBtn(); + void onImportSettings(); + void onExportSettings(); + +private: + void clearTable(); + void updateTable( const Value2ColorList& ); + + bool value( const int theRow, double& theValue ) const; + void setValue( const int theRow, const double theValue ); + void setValue( const int theRow, const QString& theValue ); + + QColor color( QPushButton* theBtn ) const; + void setColor( QPushButton* theBtn, const QColor& theColor ); + + void setColor( const int theRow, const QColor& theColor ); + + void setEditable( const int theRow, const int theCol, const bool theState ); + + bool checkMajorScale( QString& theMessage ) const; + +private: + QSpinBox* myNbSpecificIntervalsSpinBox; + + QtxGroupBox* myAutoValues; + QDoubleSpinBox* myMinimumSpinBox; + QDoubleSpinBox* myMaximumSpinBox; + QCheckBox* myIsLogarithmic; + + QtxGroupBox* myAutoColors; + QtxColorButton* myMinimumBtn; + QtxColorButton* myMaximumBtn; + + QPushButton* myGenerateButton; + + QTableWidget* myTable; + + Value2Color myMinimum; + Value2Color myMaximum; + + Value2ColorList myMajorScale; + Value2ColorList myMinorScale; +}; + +#endif diff --git a/src/Plot3d/Plot3d_SetupSurfacesDlg.cxx b/src/Plot3d/Plot3d_SetupSurfacesDlg.cxx new file mode 100644 index 000000000..d703246f9 --- /dev/null +++ b/src/Plot3d/Plot3d_SetupSurfacesDlg.cxx @@ -0,0 +1,267 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "Plot3d_SetupSurfacesDlg.h" + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#define TEXT_COL 0 +#define COLOR_SCALE_COL 1 + +//============================================================================= +// Function : Plot3d_SetupSurfacesDlg +// Purpose : Constructor +//============================================================================= +Plot3d_SetupSurfacesDlg::Plot3d_SetupSurfacesDlg( QWidget* theParent ) +: QtxDialog( theParent, true, false, QtxDialog::OKCancel ) +{ + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + setWindowTitle( tr( "SETUP_SURFACES" ) ); + + QFrame* aMainFrame = mainFrame(); + + QVBoxLayout* aMainLay = new QVBoxLayout( aMainFrame ); + aMainLay->setMargin( 5 ); + + myGrp = new QtxGroupBox( aMainFrame ); + myGrp->setTitle( tr( "PARAMETERS" ) ); + aMainLay->addWidget( myGrp ); + + QVBoxLayout* aLay = new QVBoxLayout( myGrp ); + aLay->setMargin( 0 ); + + // Create table + myTable = new QTableWidget( myGrp ); + myTable->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + + aLay->addWidget( myTable ); + + myTable->setRowCount( 0 ); + myTable->setColumnCount( 2 ); + + QStringList aLabels; + aLabels.append( tr( "TEXT" ) ); + aLabels.append( tr( "COLOR_SCALE" ) ); + myTable->setHorizontalHeaderLabels( aLabels ); + myTable->verticalHeader()->hide(); + myTable->setSelectionMode( QTableWidget::NoSelection ); + + QComboBox* aCombo = new QComboBox( 0 ); + myTable->verticalHeader()->setDefaultSectionSize( aCombo->sizeHint().height() ); + delete aCombo; + + int l, t, r, b; + myTable->getContentsMargins( &l, &t, &r, &b ); + myTable->setContentsMargins( 0, t, r, b ); + + myTable->horizontalHeader()->setResizeMode( TEXT_COL, QHeaderView::Stretch ); + myTable->horizontalHeader()->setResizeMode( COLOR_SCALE_COL, QHeaderView::ResizeToContents ); + myTable->horizontalHeader()->setHighlightSections( false ); + + // Minus button + QPixmap minusPix = aResMgr->loadPixmap( "VTKViewer", tr( "ICON_PLOT3D_MINUS" ) ); + myRemoveBtn = new QToolButton( 0 ); + myRemoveBtn->setIcon( minusPix ); + myRemoveBtn->setFixedSize( minusPix.size() ); + myGrp->insertTitleWidget( myRemoveBtn ); + + connect( myRemoveBtn, SIGNAL( clicked() ), SLOT( onRemove() ) ); + + setButtonPosition( Right, Cancel ); + setMinimumWidth( 300 ); + setMinimumHeight( 250 ); +} + +//============================================================================= +// Function : Plot3d_SetupSurfacesDlg +// Purpose : Destructor +//============================================================================= +Plot3d_SetupSurfacesDlg::~Plot3d_SetupSurfacesDlg() +{ +} + +//============================================================================= +// Function : setText +// Purpose : +//============================================================================= +void Plot3d_SetupSurfacesDlg::setText( const int theRow, + const int theCol, + const QString& theText ) +{ + QTableWidgetItem* anItem = myTable->item( theRow, theCol ); + if ( !anItem ) + { + anItem = new QTableWidgetItem( theText ); + myTable->setItem( theRow, theCol, anItem ); + } + else + anItem->setText( theText ); +} + +//============================================================================= +// Function : SetParameters +// Purpose : +//============================================================================= +void Plot3d_SetupSurfacesDlg::SetParameters( const QStringList& theTexts, + const ColorDicDataList& theColorDicDataList ) +{ + int nbRows = theTexts.size(); + + myTable->setRowCount( nbRows ); + + for ( int i = 0; i < nbRows; i++ ) + { + QString aText = theTexts[ i ]; + //aText.replace( QChar('\n'), QChar( ' ' ) ); + setText( i, TEXT_COL, aText ); + + QPushButton* aBtn = new QPushButton( tr( "EDIT" ), myTable ); + myTable->setCellWidget( i, COLOR_SCALE_COL, aBtn ); + connect( aBtn, SIGNAL( clicked() ), SLOT( onColorScaleBtn() ) ); + } + + myColorDicDataList = theColorDicDataList; + + myRemovedIndexes.clear(); +} + +//============================================================================= +// Function : GetParameters +// Purpose : +//============================================================================= +void Plot3d_SetupSurfacesDlg::GetParameters( QStringList& theTexts, + ColorDicDataList& theColorDicDataList ) const +{ + int nbRows = myTable->rowCount(); + + theTexts.clear(); + + for ( int i = 0; i < nbRows; i++ ) + { + QTableWidgetItem* it = myTable->item( i, TEXT_COL ); + QString aText = it ? it->text() : ""; + //aText.replace( ' ', '\n' ); + theTexts << aText; + } + + theColorDicDataList = myColorDicDataList; +} + +//============================================================================= +// Function : GetRemovedIndexes +// Purpose : +//============================================================================= +const QList< int >& Plot3d_SetupSurfacesDlg::GetRemovedIndexes() const +{ + return myRemovedIndexes; +} + +//============================================================================= +// Function : onRemove +// Purpose : +//============================================================================= +void Plot3d_SetupSurfacesDlg::onRemove() +{ + QList< int > toRemove; + + int aCurrRow = myTable->currentRow(); + int aCurrCol = myTable->currentColumn(); + + // get selected rows + QSet< int > aSelRows; + QList aRegs = myTable->selectedRanges(); + QList::iterator selIter; + for ( selIter = aRegs.begin(); selIter != aRegs.end(); ++selIter ) + { + const QTableWidgetSelectionRange& aReg = *selIter; + for ( int i = aReg.topRow(), n = aReg.bottomRow(); i < n; i++ ) + aSelRows.insert( i ); + } + + int i, n; + for ( i = 0, n = myTable->rowCount(); i < n; i++ ) + { + if ( aSelRows.contains( i ) || aCurrRow == i ) + toRemove.append( i ); + } + + if ( !toRemove.count() ) + return; + + int nbRemoved = 0; + QList< int >::iterator anIter; + for ( anIter = toRemove.begin(); anIter != toRemove.end(); ++anIter ) + { + int aRow = *anIter - nbRemoved; + myTable->removeRow( aRow ); + myRemovedIndexes.append( aRow ); + nbRemoved++; + } + + int nbRows = myTable->rowCount(); + if ( aCurrRow < nbRows && aCurrRow >= 0 && aCurrCol >= 0 ) + myTable->setCurrentCell( aCurrRow, aCurrCol ); + else if ( nbRows > 0 && aCurrCol >= 0 ) + myTable->setCurrentCell( nbRows - 1, aCurrCol ); +} + +//============================================================================= +// Function : onColorScaleBtn +// Purpose : +//============================================================================= +void Plot3d_SetupSurfacesDlg::onColorScaleBtn() +{ + QObject* aSender = sender(); + if( !aSender ) + return; + + int aRow = 0; + for( int aRowRef = 0, aRowCount = myTable->rowCount(); aRowRef < aRowCount; aRowRef++ ) + { + QWidget* aBtn = myTable->cellWidget( aRowRef, COLOR_SCALE_COL ); + if( aBtn == aSender ) + { + aRow = aRowRef; + break; + } + } + + if( aRow > myColorDicDataList.count() ) + return; + + ColorDicData aColorDicData = myColorDicDataList[ aRow ]; + + Plot3d_SetupColorScaleDlg aDlg( this ); + aDlg.setData( aColorDicData ); + + if( aDlg.exec() ) + { + aColorDicData = aDlg.getData(); + myColorDicDataList[ aRow ] = aColorDicData; + } +} diff --git a/src/Plot3d/Plot3d_SetupSurfacesDlg.h b/src/Plot3d/Plot3d_SetupSurfacesDlg.h new file mode 100644 index 000000000..5d9f53f0e --- /dev/null +++ b/src/Plot3d/Plot3d_SetupSurfacesDlg.h @@ -0,0 +1,73 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef PLOT3D_SETUPSURFACESDLG_H +#define PLOT3D_SETUPSURFACESDLG_H + +#include "Plot3d.h" + +#include "Plot3d_SetupColorScaleDlg.h" + +#include +#include +#include + +class QtxGroupBox; +class QTableWidget; +class QwtLegend; +class QToolButton; + +/* + Class : Plot3d_SetupSurfacesDlg + Description : Dialog box for setup Plot3d surfaces parameters +*/ +class PLOT3D_EXPORT Plot3d_SetupSurfacesDlg : public QtxDialog +{ + Q_OBJECT + +public: + Plot3d_SetupSurfacesDlg( QWidget* theParent = 0 ); + virtual ~Plot3d_SetupSurfacesDlg(); + + void SetParameters( const QStringList& theTexts, + const ColorDicDataList& theColorDicDataList ); + void GetParameters( QStringList& theTexts, + ColorDicDataList& theColorDicDataList ) const; + + const QList< int >& GetRemovedIndexes() const; + +private slots: + void onRemove(); + void onColorScaleBtn(); + +private: + void setText( const int theRow, + const int theCol, + const QString& theText ); +private: + + QtxGroupBox* myGrp; + QTableWidget* myTable; + QToolButton* myRemoveBtn; + + ColorDicDataList myColorDicDataList; + + QList< int > myRemovedIndexes; +}; + +#endif diff --git a/src/Plot3d/Plot3d_ViewManager.cxx b/src/Plot3d/Plot3d_ViewManager.cxx new file mode 100644 index 000000000..19496e098 --- /dev/null +++ b/src/Plot3d/Plot3d_ViewManager.cxx @@ -0,0 +1,37 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "Plot3d_ViewManager.h" + +#include "Plot3d_ViewModel.h" + +/*! + Constructor +*/ +Plot3d_ViewManager::Plot3d_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop ) +: SVTK_ViewManager( study, theDesktop, new Plot3d_Viewer() ) +{ + setTitle( Plot3d_ViewManager::tr( "PLOT3D_VIEW_TITLE" ) ); +} + +/*! + Destructor +*/ +Plot3d_ViewManager::~Plot3d_ViewManager() +{ +} diff --git a/src/Plot3d/Plot3d_ViewManager.h b/src/Plot3d/Plot3d_ViewManager.h new file mode 100644 index 000000000..b0549079f --- /dev/null +++ b/src/Plot3d/Plot3d_ViewManager.h @@ -0,0 +1,41 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef PLOT3D_VIEWMANAGER_H +#define PLOT3D_VIEWMANAGER_H + +#include "Plot3d.h" + +#include + +class SUIT_Desktop; + +//! Extend Plot3d_ViewManager to deal with Plot3d_Viewer +class PLOT3D_EXPORT Plot3d_ViewManager : public SVTK_ViewManager +{ + Q_OBJECT + +public: + //! Construct the view manager + Plot3d_ViewManager( SUIT_Study* study, SUIT_Desktop* ); + + //! Destroy the view manager + virtual ~Plot3d_ViewManager(); +}; + +#endif diff --git a/src/Plot3d/Plot3d_ViewModel.cxx b/src/Plot3d/Plot3d_ViewModel.cxx new file mode 100644 index 000000000..54597960a --- /dev/null +++ b/src/Plot3d/Plot3d_ViewModel.cxx @@ -0,0 +1,58 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "Plot3d_ViewModel.h" + +#include "Plot3d_ViewWindow.h" + +/*! + Constructor +*/ +Plot3d_Viewer::Plot3d_Viewer() +{ +} + +/*! + Destructor +*/ +Plot3d_Viewer::~Plot3d_Viewer() +{ +} + +/*!Create new instance of view window on desktop \a theDesktop. + *\retval SUIT_ViewWindow* - created view window pointer. + */ +SUIT_ViewWindow* Plot3d_Viewer::createView( SUIT_Desktop* theDesktop ) +{ + TViewWindow* aViewWindow = new TViewWindow(theDesktop); + aViewWindow->Initialize(this); + + aViewWindow->setBackgroundColor( backgroundColor() ); + aViewWindow->SetTrihedronSize( trihedronSize(), trihedronRelative() ); + aViewWindow->SetProjectionMode( projectionMode() ); + aViewWindow->SetInteractionStyle( interactionStyle() ); + aViewWindow->SetIncrementalSpeed( incrementalSpeed(), incrementalSpeedMode() ); + aViewWindow->SetSpacemouseButtons( spacemouseBtn(1), spacemouseBtn(2), spacemouseBtn(3) ); + + connect(aViewWindow, SIGNAL( actorAdded(VTKViewer_Actor*) ), + this, SLOT(onActorAdded(VTKViewer_Actor*))); + connect(aViewWindow, SIGNAL( actorRemoved(VTKViewer_Actor*) ), + this, SLOT(onActorRemoved(VTKViewer_Actor*))); + + return aViewWindow; +} diff --git a/src/Plot3d/Plot3d_ViewModel.h b/src/Plot3d/Plot3d_ViewModel.h new file mode 100644 index 000000000..16226fa76 --- /dev/null +++ b/src/Plot3d/Plot3d_ViewModel.h @@ -0,0 +1,49 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef PLOT3D_VIEWMODEL_H +#define PLOT3D_VIEWMODEL_H + +#include "Plot3d.h" + +#include + +class Plot3d_ViewWindow; + +//! Extends interface #SVTK_Viewer +class PLOT3D_EXPORT Plot3d_Viewer : public SVTK_Viewer +{ + Q_OBJECT; + +public: + typedef Plot3d_ViewWindow TViewWindow; + + //! Define string representation of the viewer type + static QString Type() { return "Plot3d"; } + + Plot3d_Viewer(); + virtual ~Plot3d_Viewer(); + + //! See #SUIT_ViewModel::createView + virtual SUIT_ViewWindow* createView( SUIT_Desktop* ); + + //! See #SUIT_ViewModel::getType + virtual QString getType() const { return Type(); } +}; + +#endif diff --git a/src/Plot3d/Plot3d_ViewWindow.cxx b/src/Plot3d/Plot3d_ViewWindow.cxx new file mode 100644 index 000000000..8f1dfa466 --- /dev/null +++ b/src/Plot3d/Plot3d_ViewWindow.cxx @@ -0,0 +1,466 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "Plot3d_ViewWindow.h" + +#include "Plot3d_Actor.h" +#include "Plot3d_FitDataDlg.h" +#include "Plot3d_SetupColorScaleDlg.h" +#include "Plot3d_SetupSurfacesDlg.h" + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include + +/*! + Constructor +*/ +Plot3d_ViewWindow::Plot3d_ViewWindow( SUIT_Desktop* theDesktop ): + SVTK_ViewWindow( theDesktop ), + myMode2D( false ), + myMode2DNormalAxis( AxisZ ) +{ +} + +/*! + Destructor +*/ +Plot3d_ViewWindow::~Plot3d_ViewWindow() +{ +} + +/*! + To initialize #Plot3d_ViewWindow instance +*/ +void Plot3d_ViewWindow::Initialize( SVTK_ViewModelBase* theModel ) +{ + myPlot3dToolBar = toolMgr()->createToolBar( tr( "PLOT3D" ), -1, this ); + + SVTK_ViewWindow::Initialize( theModel ); +} + +/*! + Fill the context menu + \param thePopup context menu +*/ +void Plot3d_ViewWindow::contextMenuPopup( QMenu* thePopup ) +{ + thePopup->addAction( tr( "MNU_PLOT3D_SURFACES_SETTINGS" ), this, SLOT( onSurfacesSettings() ) ); + + if( myMode2D ) + thePopup->addAction( tr( "FIT_RANGE" ), this, SLOT( onFitData() ) ); +} + +/*! + Creates all actions of Plot3d view window +*/ +void Plot3d_ViewWindow::createActions( SUIT_ResourceMgr* theResourceMgr ) +{ + SVTK_ViewWindow::createActions( theResourceMgr ); + + QtxAction* anAction; + QtxActionToolMgr* mgr = toolMgr(); + + anAction = new QtxAction( tr("MNU_PLOT3D_MODE_2D"), + theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_PLOT3D_MODE_2D" ) ), + tr( "MNU_PLOT3D_MODE_2D" ), 0, this ); + anAction->setStatusTip( tr("DSC_PLOT3D_MODE_2D") ); + anAction->setCheckable( true ); + connect( anAction, SIGNAL( toggled( bool ) ), this, SLOT( onMode2D( bool ) ) ); + mgr->registerAction( anAction, Mode2DId ); + + anAction = new QtxAction( tr( "MNU_PLOT3D_SURFACES_SETTINGS" ), + theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_PLOT3D_SURFACES_SETTINGS" ) ), + tr( "MNU_PLOT3D_SURFACES_SETTINGS" ), 0, this ); + anAction->setStatusTip( tr( "DSC_PLOT3D_SURFACES_SETTINGS" ) ); + connect( anAction, SIGNAL( activated() ), this, SLOT( onSurfacesSettings() ) ); + mgr->registerAction( anAction, SurfacesSettingsId ); +} + +/*! + Creates toolbar of Plot3d view window +*/ +void Plot3d_ViewWindow::createToolBar() +{ + SVTK_ViewWindow::createToolBar(); + + QtxActionToolMgr* mgr = toolMgr(); + + mgr->append( Mode2DId, myPlot3dToolBar ); + mgr->append( SurfacesSettingsId, myPlot3dToolBar ); +} + +/*! + Set the normal axis for the 2D mode +*/ +void Plot3d_ViewWindow::setMode2DNormalAxis( const int theAxis ) +{ + myMode2DNormalAxis = theAxis; +} + +/*! + Check that 2D mode is active + \return true if 2D mode is active +*/ +bool Plot3d_ViewWindow::isMode2D() const +{ + return myMode2D; +} + +/*! + Toggle 2D mode on/off +*/ +void Plot3d_ViewWindow::onMode2D( bool theOn ) +{ + bool anIsModeChanged = theOn != myMode2D; + myMode2D = theOn; + + if( getAction( ViewTrihedronId ) ) + getAction( ViewTrihedronId )->setVisible( !theOn ); + if( getAction( ViewTrihedronId ) ) + getAction( ViewTrihedronId )->setVisible( !theOn ); + if( getAction( ChangeRotationPointId ) ) + getAction( ChangeRotationPointId )->setVisible( !theOn ); + if( myViewsAction ) + myViewsAction->setVisible( !theOn ); + if( getAction( ViewTrihedronId ) ) + getAction( ViewTrihedronId )->setVisible( !theOn ); + + SVTK_ComboAction* a = ::qobject_cast( toolMgr()->action( ProjectionModeId ) ); + if( a ) + a->setVisible( !theOn ); + + if( theOn ) + { + myCubeAxesDlg->SetDimensionXEnabled( myMode2DNormalAxis != AxisX ); + myCubeAxesDlg->SetDimensionYEnabled( myMode2DNormalAxis != AxisY ); + myCubeAxesDlg->SetDimensionZEnabled( myMode2DNormalAxis != AxisZ ); + if( SVTK_CubeAxesActor2D* aCubeAxes = GetRenderer()->GetCubeAxes() ) + { + aCubeAxes->SetIsInvertedGrid( true ); + if( vtkAxisActor2D* aXAxis = aCubeAxes->GetXAxisActor2D() ) + { + aXAxis->SetTitleVisibility( myMode2DNormalAxis != AxisX ); + aXAxis->SetLabelVisibility( myMode2DNormalAxis != AxisX ); + aXAxis->SetTickVisibility( myMode2DNormalAxis != AxisX ); + } + if( vtkAxisActor2D* aYAxis = aCubeAxes->GetYAxisActor2D() ) + { + aYAxis->SetTitleVisibility( myMode2DNormalAxis != AxisY ); + aYAxis->SetLabelVisibility( myMode2DNormalAxis != AxisY ); + aYAxis->SetTickVisibility( myMode2DNormalAxis != AxisY ); + } + if( vtkAxisActor2D* aZAxis = aCubeAxes->GetZAxisActor2D() ) + { + aZAxis->SetTitleVisibility( myMode2DNormalAxis != AxisZ ); + aZAxis->SetLabelVisibility( myMode2DNormalAxis != AxisZ ); + aZAxis->SetTickVisibility( myMode2DNormalAxis != AxisZ ); + } + } + + if( anIsModeChanged ) + storeViewState( myStored3DViewState ); + if( !restoreViewState( myStored2DViewState ) ) + { + // first time the action is toggled + GetRenderer()->SetTrihedronDisplayed( false ); + switch( myMode2DNormalAxis ) + { + case AxisX: onFrontView(); break; + case AxisY: onLeftView(); break; + case AxisZ: onTopView(); break; + } + onFitAll(); + } + + myStandardInteractorStyle->SetIsRotationEnabled( false ); + myKeyFreeInteractorStyle->SetIsRotationEnabled( false ); + } + else + { + myCubeAxesDlg->SetDimensionXEnabled( true ); + myCubeAxesDlg->SetDimensionYEnabled( true ); + myCubeAxesDlg->SetDimensionZEnabled( true ); + if( SVTK_CubeAxesActor2D* aCubeAxes = GetRenderer()->GetCubeAxes() ) + { + aCubeAxes->SetIsInvertedGrid( false ); + if( vtkAxisActor2D* aXAxis = aCubeAxes->GetXAxisActor2D() ) + { + aXAxis->SetTitleVisibility( 1 ); + aXAxis->SetLabelVisibility( 1 ); + aXAxis->SetTickVisibility( 1 ); + } + if( vtkAxisActor2D* aYAxis = aCubeAxes->GetYAxisActor2D() ) + { + aYAxis->SetTitleVisibility( 1 ); + aYAxis->SetLabelVisibility( 1 ); + aYAxis->SetTickVisibility( 1 ); + } + if( vtkAxisActor2D* aZAxis = aCubeAxes->GetZAxisActor2D() ) + { + aZAxis->SetTitleVisibility( 1 ); + aZAxis->SetLabelVisibility( 1 ); + aZAxis->SetTickVisibility( 1 ); + } + } + + storeViewState( myStored2DViewState ); + restoreViewState( myStored3DViewState ); + + myStandardInteractorStyle->SetIsRotationEnabled( true ); + myKeyFreeInteractorStyle->SetIsRotationEnabled( true ); + } +} + +/*! + Change the surfaces settings +*/ +void Plot3d_ViewWindow::onSurfacesSettings() +{ + vtkRenderer* aRenderer = getRenderer(); + if( !aRenderer ) + return; + + QList< Plot3d_Actor* > aSurfaces; + QStringList aTexts; + ColorDicDataList aColorDicDataList; + vtkActor* anActor = 0; + + VTK::ActorCollectionCopy aCopy( aRenderer->GetActors() ); + vtkActorCollection* aCollection = aCopy.GetActors(); + aCollection->InitTraversal(); + while( anActor = aCollection->GetNextActor() ) + { + if( Plot3d_Actor* aSurface = dynamic_cast( anActor ) ) + { + aSurfaces << aSurface; + + vtkScalarBarActor* aScalarBar = aSurface->GetScalarBarActor().GetPointer(); + Plot3d_ColorDic* aColorDic = aSurface->GetColorDic(); + + if( aScalarBar && aColorDic ) + { + aTexts << aScalarBar->GetTitle(); + + ColorDicData aColorDicData; + aColorDicData.Num = aColorDic->GetNumber(); + aColorDicData.Min = aColorDic->GetMin(); + aColorDicData.Max = aColorDic->GetMax(); + + aColorDic->GetHSVRange( aColorDicData.HueMin, aColorDicData.HueMax, + aColorDicData.SaturationMin, aColorDicData.SaturationMax, + aColorDicData.ValueMin, aColorDicData.ValueMax ); + aColorDicData.ScaleMode = aColorDic->GetScaleMode(); + aColorDicData.MainSpecificColorScale = aColorDic->GetMainSpecificScale(); + aColorDicData.SpecificColorScale = aColorDic->GetSpecificScale(); + aColorDicData.TimeStep = aColorDic->GetTimeStep(); + aColorDicData.Quantity = aColorDic->GetQuantity(); + aColorDicData.ColorMode = aColorDic->GetColorMode(); + aColorDic->GetCustomColors( aColorDicData.CustomColors[0], aColorDicData.CustomColors[1] ); + + aColorDicDataList << aColorDicData; + } + } + } + + Plot3d_SetupSurfacesDlg aDlg( this ); + aDlg.SetParameters( aTexts, aColorDicDataList ); + + if ( aDlg.exec() != QDialog::Accepted ) + return; + + aDlg.GetParameters( aTexts, aColorDicDataList ); + + // Note: Indexes retrieved from dialog do not correspond to the real indexes of + // plot 3d surfaces. They correspond to the user actions. For example, if user removes + // first surface in dialog's table two times. Then contents of list of indexes is + // equal (1, 1) although first and surfaces curves must be removed. + const QList< int >& toRemove = aDlg.GetRemovedIndexes(); + QList< int >::const_iterator aRemIter; + for ( aRemIter = toRemove.begin(); aRemIter != toRemove.end(); ++aRemIter ) + { + int anIndex = *aRemIter; + if ( anIndex >= 0 && anIndex < (int)aSurfaces.count() ) + { + Plot3d_Actor* aSurface = aSurfaces[ anIndex ]; + aSurfaces.removeAt( anIndex ); + aSurface->RemoveFromRender( aRenderer ); + aSurface->Delete(); + + aColorDicDataList.removeAt( anIndex ); + } + } + + QMap< int, Plot3d_Actor* > anIndexToSurface; + QList< Plot3d_Actor* >::iterator aSurfIter; + int i; + for ( i = 0, aSurfIter = aSurfaces.begin(); aSurfIter != aSurfaces.end(); ++aSurfIter, ++i ) + anIndexToSurface[ i ] = *aSurfIter; + + int n; + for ( i = 0, n = aTexts.size(); i < n; i++ ) + { + const QString& aText = aTexts[ i ]; + const ColorDicData& aColorDicData = aColorDicDataList[ i ]; + + Plot3d_Actor* aSurface = anIndexToSurface[ i ]; + + vtkScalarBarActor* aScalarBar = aSurface->GetScalarBarActor().GetPointer(); + Plot3d_ColorDic* aColorDic = aSurface->GetColorDic(); + + if( aScalarBar && aColorDic ) + { + aScalarBar->SetTitle( aText.toLatin1().constData() ); + + aColorDic->SetNumber( aColorDicData.Num ); + aColorDic->SetMin( aColorDicData.Min ); + aColorDic->SetMax( aColorDicData.Max ); + + aColorDic->SetHSVRange( aColorDicData.HueMin, aColorDicData.HueMax, + aColorDicData.SaturationMin, aColorDicData.SaturationMax, + aColorDicData.ValueMin, aColorDicData.ValueMax ); + aColorDic->SetScaleMode( aColorDicData.ScaleMode ); + if( aColorDicData.ScaleMode == Plot3d_ColorDic::Specific ) + { + aColorDic->SetMainSpecificScale( aColorDicData.MainSpecificColorScale ); + aColorDic->SetSpecificScale( aColorDicData.SpecificColorScale ); + } + aColorDic->SetTimeStep( aColorDicData.TimeStep ); + aColorDic->SetQuantity( aColorDicData.Quantity ); + aColorDic->SetColorMode( aColorDicData.ColorMode ); + aColorDic->SetCustomColors( aColorDicData.CustomColors[0], aColorDicData.CustomColors[1] ); + + aSurface->RecomputeLookupTable(); + } + } + + vtkFloatingPointType aGlobalBounds[6] = { VTK_DOUBLE_MAX, VTK_DOUBLE_MIN, + VTK_DOUBLE_MAX, VTK_DOUBLE_MIN, + VTK_DOUBLE_MAX, VTK_DOUBLE_MIN }; + + for ( i = 0, aSurfIter = aSurfaces.begin(); aSurfIter != aSurfaces.end(); ++aSurfIter, ++i ) + { + if( Plot3d_Actor* aSurface = *aSurfIter ) + { + vtkFloatingPointType aBounds[6]; + aSurface->GetBounds( aBounds ); + aGlobalBounds[0] = qMin( aGlobalBounds[0], aBounds[0] ); + aGlobalBounds[1] = qMax( aGlobalBounds[1], aBounds[1] ); + aGlobalBounds[2] = qMin( aGlobalBounds[2], aBounds[2] ); + aGlobalBounds[3] = qMax( aGlobalBounds[3], aBounds[3] ); + aGlobalBounds[4] = qMin( aGlobalBounds[4], aBounds[4] ); + aGlobalBounds[5] = qMax( aGlobalBounds[5], aBounds[5] ); + } + } + + double aDX = aGlobalBounds[1] - aGlobalBounds[0]; + double aDY = aGlobalBounds[3] - aGlobalBounds[2]; + double aDZ = aGlobalBounds[5] - aGlobalBounds[4]; + + double aScale[3]; + GetScale( aScale ); // take into account the current scale + aDX = fabs( aScale[0] ) > DBL_EPSILON ? aDX / aScale[0] : aDX; + aDY = fabs( aScale[1] ) > DBL_EPSILON ? aDY / aScale[1] : aDY; + aDZ = fabs( aScale[2] ) > DBL_EPSILON ? aDZ / aScale[2] : aDZ; + + aScale[0] = fabs( aDX ) > DBL_EPSILON ? 1.0 / aDX : 1.0; + aScale[1] = fabs( aDY ) > DBL_EPSILON ? 1.0 / aDY : 1.0; + aScale[2] = fabs( aDZ ) > DBL_EPSILON ? 1.0 / aDZ : 1.0; + SetScale( aScale ); + onFitAll(); +} + +/*! + Fit 2D surfaces to the specified data range +*/ +void Plot3d_ViewWindow::onFitData() +{ + // to do +} + +/*! + Store 2D/3D view state + \param theViewState - view state to be stored +*/ +void Plot3d_ViewWindow::storeViewState( ViewState& theViewState ) +{ + vtkCamera* aCamera = getRenderer()->GetActiveCamera(); + + theViewState.IsInitialized = true; + + aCamera->GetPosition( theViewState.Position ); + aCamera->GetFocalPoint( theViewState.FocalPoint ); + aCamera->GetViewUp( theViewState.ViewUp ); + theViewState.ParallelScale = aCamera->GetParallelScale(); + + theViewState.IsTrihedronDisplayed = GetRenderer()->IsTrihedronDisplayed(); +} + +/*! + Restore 2D/3D view state + \param theViewState - view state to be restored + \return true if the view state is initialized and can be restored +*/ +bool Plot3d_ViewWindow::restoreViewState( ViewState theViewState ) +{ + vtkCamera* aCamera = getRenderer()->GetActiveCamera(); + if( theViewState.IsInitialized ) + { + GetRenderer()->SetTrihedronDisplayed( theViewState.IsTrihedronDisplayed ); + + aCamera->SetPosition( theViewState.Position ); + aCamera->SetFocalPoint( theViewState.FocalPoint ); + aCamera->SetViewUp( theViewState.ViewUp ); + aCamera->SetParallelScale( theViewState.ParallelScale ); + Repaint(); + + return true; + } + return false; +} + +/*! + Clear 2D/3D view state + \param theIs2D flag used to indicate which state has to be cleared +*/ +void Plot3d_ViewWindow::clearViewState( const bool theIs2D ) +{ + if( theIs2D ) + myStored2DViewState.IsInitialized = false; + else + myStored3DViewState.IsInitialized = false; +} diff --git a/src/Plot3d/Plot3d_ViewWindow.h b/src/Plot3d/Plot3d_ViewWindow.h new file mode 100644 index 000000000..61c8d4d7a --- /dev/null +++ b/src/Plot3d/Plot3d_ViewWindow.h @@ -0,0 +1,88 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef PLOT3D_VIEWWINDOW_H +#define PLOT3D_VIEWWINDOW_H + +#include "Plot3d.h" + +#include + +class PLOT3D_EXPORT Plot3d_ViewWindow : public SVTK_ViewWindow +{ + Q_OBJECT + +public: + enum { FirstId = SVTK_ViewWindow::LastId, + Mode2DId, SurfacesSettingsId, + LastId }; + + enum Axis { AxisX = 0, AxisY, AxisZ }; + +public: + Plot3d_ViewWindow( SUIT_Desktop* theDesktop ); + virtual ~Plot3d_ViewWindow(); + + virtual void Initialize( SVTK_ViewModelBase* theModel ); + + virtual void contextMenuPopup( QMenu* thePopup ); + + void setMode2DNormalAxis( const int theAxis ); + + bool isMode2D() const; + + void clearViewState( const bool theIs2D ); + +public slots: + void onMode2D( bool theOn ); + void onSurfacesSettings(); + void onFitData(); + +protected: + struct ViewState + { + bool IsInitialized; + double Position[3]; + double FocalPoint[3]; + double ViewUp[3]; + double ParallelScale; + bool IsTrihedronDisplayed; + + ViewState() + { + IsInitialized = false; + ParallelScale = 0.0; + IsTrihedronDisplayed = false; + } + }; + void storeViewState( ViewState& theViewState ); + bool restoreViewState( ViewState theViewState ); + + virtual void createActions( SUIT_ResourceMgr* theResourceMgr ); + virtual void createToolBar(); + +protected: + int myPlot3dToolBar; + + bool myMode2D; + int myMode2DNormalAxis; + ViewState myStored2DViewState; + ViewState myStored3DViewState; +}; + +#endif diff --git a/src/Plot3d/resources/Plot3d_images.ts b/src/Plot3d/resources/Plot3d_images.ts new file mode 100644 index 000000000..09fa563fa --- /dev/null +++ b/src/Plot3d/resources/Plot3d_images.ts @@ -0,0 +1,17 @@ + + + @default + + ICON_PLOT3D_SURFACES_SETTINGS + plot3d_surfaces_settings.png + + + ICON_PLOT3D_MODE_2D + plot3d_mode_2d.png + + + ICON_PLOT3D_MINUS + plot3d_minus.png + + + diff --git a/src/Plot3d/resources/Plot3d_msg_en.ts b/src/Plot3d/resources/Plot3d_msg_en.ts new file mode 100644 index 000000000..8ab341b40 --- /dev/null +++ b/src/Plot3d/resources/Plot3d_msg_en.ts @@ -0,0 +1,278 @@ + + + + @default + + ERROR + Error + + + WARNING + Warning + + + XML_FILTER + XML files (*.xml);;All files (*.* *) + + + + Plot3d_FitDataDlg + + FIT_ALL + Fit both + + + FIT_HORIZONTAL + Fit horizontally + + + FIT_VERTICAL + Fit vertically + + + HORIZONTAL_AXIS + Horizontal axis + + + MAX_VALUE_LAB + Max: + + + MIN_VALUE_LAB + Min: + + + VERTICAL_AXIS + Vertical axis + + + VERTICAL_LEFT_AXIS + Vertical left axis + + + VERTICAL_RIGHT_AXIS + Vertical right axis + + + + Plot3d_SetupColorScaleDlg + + BLUE_RED + Blue - Red + + + BLUE_WHITE + Blue - Light blue + + + COLOR_SCALE + Color scale + + + COLORS + Colors + + + CORRECT_RANGE + Correct range + + + CUSTOM + Custom + + + INCORRECT_RANGE + Logarithmic scale could not be used when the +minimum value of the range is less or equal zero. +Correct the range or switch to linear scale? + + + LINEAR + Linear + + + LOGARITHMIC + Logarithmic + + + MAX + Max + + + MIN + Min + + + MONOCHROME + Monochrome + + + NUMBER_OF_INTERVALS + Number of intervals + + + RANGE + Range + + + SETUP + Setup + + + SETUP_COLOR_SCALE + Setup color scale + + + SPECIFIC + Specific + + + SWITCH_TO_LINEAR + Switch to linear + + + + Plot3d_SetupSpecificColorScaleDlg + + AUTO_COLORS + Auto colors + + + AUTO_VALUES + Auto values + + + GENERATE_TABLE + Generate table + + + GENERATE_TABLE_FOR_NEW + Generate table for the new variable + + + COLOR + Color + + + COLOR_SCALE + Color scale + + + EXPORT_SETTINGS + Export settings + + + IMPORT_EXPORT_SETTINGS + Import/export settings + + + IMPORT_SETTINGS + Import settings + + + LOGARITHMIC_INTERPOLATION + Logarithmic interpolation + + + MINIMUM + Minimum + + + MAXIMUM + Maximum + + + NUMBER_OF_SPECIFIC_INTERVALS + Number of specific intervals + + + PARAMETERS + Parameters + + + SETUP_SPECIFIC_COLOR_SCALE + Setup specific color scale + + + VALUE + Value + + + WRN_INCORRECT_RANGE_MIN_MAX + The minimum value of the range should not be greater +or equal the maximum value. + + + + WRN_INCORRECT_RANGE_LOGARITHMIC + The minimum value of the range should not be less +or equal zero in case of logarithmic interpolation. + + + + WRN_INCONSISTENT_VALUES + Incorrect data: values are inconsistent. + + + WRN_UNINITIALIZED_VALUES + Incorrect data: some values are uninitialized. + + + + Plot3d_SetupSurfacesDlg + + COLOR_SCALE + Color scale + + + EDIT + Edit + + + PARAMETERS + Parameters + + + SETUP_SURFACES + Setup surfaces + + + TEXT + Text + + + + Plot3d_ViewManager + + PLOT3D_VIEW_TITLE + Plot3d scene:%M - viewer:%V + + + + Plot3d_ViewWindow + + DSC_PLOT3D_MODE_2D + Toggle 2D mode + + + DSC_PLOT3D_SURFACES_SETTINGS + Surfaces settings + + + FIT_RANGE + Fit range + + + MNU_PLOT3D_MODE_2D + Toggle 2D mode + + + MNU_PLOT3D_SURFACES_SETTINGS + Surfaces settings + + + PLOT3D + Plot3d + + + diff --git a/src/Plot3d/resources/plot3d_minus.png b/src/Plot3d/resources/plot3d_minus.png new file mode 100644 index 000000000..055182e1a Binary files /dev/null and b/src/Plot3d/resources/plot3d_minus.png differ diff --git a/src/Plot3d/resources/plot3d_mode_2d.png b/src/Plot3d/resources/plot3d_mode_2d.png new file mode 100644 index 000000000..2dcf3e482 Binary files /dev/null and b/src/Plot3d/resources/plot3d_mode_2d.png differ diff --git a/src/Plot3d/resources/plot3d_surfaces_settings.png b/src/Plot3d/resources/plot3d_surfaces_settings.png new file mode 100644 index 000000000..53d4f2c31 Binary files /dev/null and b/src/Plot3d/resources/plot3d_surfaces_settings.png differ diff --git a/src/SVTK/SVTK_CubeAxesDlg.h b/src/SVTK/SVTK_CubeAxesDlg.h index 41be79735..abac6738f 100644 --- a/src/SVTK/SVTK_CubeAxesDlg.h +++ b/src/SVTK/SVTK_CubeAxesDlg.h @@ -45,7 +45,7 @@ class SVTK_ViewWindow; * Class : SVTK_CubeAxesDlg * Description : Dialog for specifynig cube axes properties */ -class SVTK_CubeAxesDlg : public SVTK_DialogBase +class SVTK_EXPORT SVTK_CubeAxesDlg : public SVTK_DialogBase { Q_OBJECT diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 5df7b7edc..20e3569dc 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -23,13 +23,8 @@ #include "SVTK_SetRotationPointDlg.h" #include "SVTK_ViewParameterDlg.h" -#include "Plot3d_Actor.h" -#include "Plot3d_FitDataDlg.h" -#include "Plot3d_SetupSurfacesDlg.h" - #include "SALOME_Actor.h" -#include #include #include #include @@ -46,7 +41,6 @@ #include #include #include -#include #include "QtxAction.h" @@ -122,9 +116,7 @@ SVTK_ViewWindow::SVTK_ViewWindow(SUIT_Desktop* theDesktop): myDumpImage(QImage()), myStandardInteractorStyle(SVTK_InteractorStyle::New()), myKeyFreeInteractorStyle(SVTK_KeyFreeInteractorStyle::New()), - myViewsAction( NULL ), - myMode2D( false ), - myMode2DNormalAxis( AxisZ ) + myViewsAction( NULL ) { setWindowFlags( windowFlags() & ~Qt::Window ); // specific of vtkSmartPointer @@ -242,8 +234,6 @@ SVTK_ViewWindow::~SVTK_ViewWindow() */ void SVTK_ViewWindow::contextMenuPopup( QMenu* thePopup ) { - if( myMode2D ) - thePopup->addAction( tr( "TOT_SVTK_FITDATA" ), this, SLOT( onFitData() ) ); } /*! @@ -741,173 +731,6 @@ void SVTK_ViewWindow::onSwitchInteractionStyle(bool theOn) if ( a->isChecked() != theOn ) a->setChecked( theOn ); } -/*! - Toggle 2D mode on/off -*/ -void SVTK_ViewWindow::onMode2D( bool theOn ) -{ - bool anIsModeChanged = theOn != myMode2D; - myMode2D = theOn; - - if( getAction( ViewTrihedronId ) ) - getAction( ViewTrihedronId )->setVisible( !theOn ); - if( getAction( ViewTrihedronId ) ) - getAction( ViewTrihedronId )->setVisible( !theOn ); - if( getAction( ChangeRotationPointId ) ) - getAction( ChangeRotationPointId )->setVisible( !theOn ); - if( myViewsAction ) - myViewsAction->setVisible( !theOn ); - if( getAction( ViewTrihedronId ) ) - getAction( ViewTrihedronId )->setVisible( !theOn ); - - SVTK_ComboAction* a = ::qobject_cast( toolMgr()->action( ProjectionModeId ) ); - if( a ) - a->setVisible( !theOn ); - - if( theOn ) - { - myCubeAxesDlg->SetDimensionXEnabled( myMode2DNormalAxis != AxisX ); - myCubeAxesDlg->SetDimensionYEnabled( myMode2DNormalAxis != AxisY ); - myCubeAxesDlg->SetDimensionZEnabled( myMode2DNormalAxis != AxisZ ); - if( SVTK_CubeAxesActor2D* aCubeAxes = GetRenderer()->GetCubeAxes() ) - { - aCubeAxes->SetIsInvertedGrid( true ); - if( vtkAxisActor2D* aXAxis = aCubeAxes->GetXAxisActor2D() ) - { - aXAxis->SetTitleVisibility( myMode2DNormalAxis != AxisX ); - aXAxis->SetLabelVisibility( myMode2DNormalAxis != AxisX ); - aXAxis->SetTickVisibility( myMode2DNormalAxis != AxisX ); - } - if( vtkAxisActor2D* aYAxis = aCubeAxes->GetYAxisActor2D() ) - { - aYAxis->SetTitleVisibility( myMode2DNormalAxis != AxisY ); - aYAxis->SetLabelVisibility( myMode2DNormalAxis != AxisY ); - aYAxis->SetTickVisibility( myMode2DNormalAxis != AxisY ); - } - if( vtkAxisActor2D* aZAxis = aCubeAxes->GetZAxisActor2D() ) - { - aZAxis->SetTitleVisibility( myMode2DNormalAxis != AxisZ ); - aZAxis->SetLabelVisibility( myMode2DNormalAxis != AxisZ ); - aZAxis->SetTickVisibility( myMode2DNormalAxis != AxisZ ); - } - } - - if( anIsModeChanged ) - storeViewState( myStored3DViewState ); - if( !restoreViewState( myStored2DViewState ) ) - { - // first time the action is toggled - GetRenderer()->SetTrihedronDisplayed( false ); - switch( myMode2DNormalAxis ) - { - case AxisX: onFrontView(); break; - case AxisY: onLeftView(); break; - case AxisZ: onTopView(); break; - } - onFitAll(); - } - - myStandardInteractorStyle->SetIsRotationEnabled( false ); - myKeyFreeInteractorStyle->SetIsRotationEnabled( false ); - } - else - { - myCubeAxesDlg->SetDimensionXEnabled( true ); - myCubeAxesDlg->SetDimensionYEnabled( true ); - myCubeAxesDlg->SetDimensionZEnabled( true ); - if( SVTK_CubeAxesActor2D* aCubeAxes = GetRenderer()->GetCubeAxes() ) - { - aCubeAxes->SetIsInvertedGrid( false ); - if( vtkAxisActor2D* aXAxis = aCubeAxes->GetXAxisActor2D() ) - { - aXAxis->SetTitleVisibility( 1 ); - aXAxis->SetLabelVisibility( 1 ); - aXAxis->SetTickVisibility( 1 ); - } - if( vtkAxisActor2D* aYAxis = aCubeAxes->GetYAxisActor2D() ) - { - aYAxis->SetTitleVisibility( 1 ); - aYAxis->SetLabelVisibility( 1 ); - aYAxis->SetTickVisibility( 1 ); - } - if( vtkAxisActor2D* aZAxis = aCubeAxes->GetZAxisActor2D() ) - { - aZAxis->SetTitleVisibility( 1 ); - aZAxis->SetLabelVisibility( 1 ); - aZAxis->SetTickVisibility( 1 ); - } - } - - storeViewState( myStored2DViewState ); - restoreViewState( myStored3DViewState ); - - myStandardInteractorStyle->SetIsRotationEnabled( true ); - myKeyFreeInteractorStyle->SetIsRotationEnabled( true ); - } -} - -/*! - Check that 2D mode is active - \return true if 2D mode is active -*/ -bool SVTK_ViewWindow::isMode2D() const -{ - return myMode2D; -} - -/*! - Store 2D/3D view state - \param theViewState - view state to be stored -*/ -void SVTK_ViewWindow::storeViewState( ViewState& theViewState ) -{ - vtkCamera* aCamera = getRenderer()->GetActiveCamera(); - - theViewState.IsInitialized = true; - - aCamera->GetPosition( theViewState.Position ); - aCamera->GetFocalPoint( theViewState.FocalPoint ); - aCamera->GetViewUp( theViewState.ViewUp ); - theViewState.ParallelScale = aCamera->GetParallelScale(); - - theViewState.IsTrihedronDisplayed = GetRenderer()->IsTrihedronDisplayed(); -} - -/*! - Restore 2D/3D view state - \param theViewState - view state to be restored - \return true if the view state is initialized and can be restored -*/ -bool SVTK_ViewWindow::restoreViewState( ViewState theViewState ) -{ - vtkCamera* aCamera = getRenderer()->GetActiveCamera(); - if( theViewState.IsInitialized ) - { - GetRenderer()->SetTrihedronDisplayed( theViewState.IsTrihedronDisplayed ); - - aCamera->SetPosition( theViewState.Position ); - aCamera->SetFocalPoint( theViewState.FocalPoint ); - aCamera->SetViewUp( theViewState.ViewUp ); - aCamera->SetParallelScale( theViewState.ParallelScale ); - Repaint(); - - return true; - } - return false; -} - -/*! - Clear 2D/3D view state - \param theIs2D flag used to indicate which state has to be cleared -*/ -void SVTK_ViewWindow::clearViewState( const bool theIs2D ) -{ - if( theIs2D ) - myStored2DViewState.IsInitialized = false; - else - myStored3DViewState.IsInitialized = false; -} - /*! Sets incremental speed \param theValue - new incremental speed @@ -1951,15 +1774,6 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr) connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewParameters(bool))); mgr->registerAction( anAction, ViewParametersId ); - // Switch between 3D (default) and 2D modes - anAction = new QtxAction(tr("MNU_SVTK_MODE_2D"), - theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_MODE_2D" ) ), - tr( "MNU_SVTK_MODE_2D" ), 0, this); - anAction->setStatusTip(tr("DSC_SVTK_MODE_2D")); - anAction->setCheckable(true); - connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onMode2D(bool))); - mgr->registerAction( anAction, Mode2DId ); - // Switch between interaction styles anAction = new QtxAction(tr("MNU_SVTK_STYLE_SWITCH"), theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_STYLE_SWITCH" ) ), @@ -1969,14 +1783,6 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr) connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool))); mgr->registerAction( anAction, SwitchInteractionStyleId ); - // Surfaces settings - anAction = new QtxAction(tr("MNU_SVTK_SURFACES_SETTINGS"), - theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SURFACES_SETTINGS" ) ), - tr( "MNU_SVTK_SURFACES_SETTINGS" ), 0, this); - anAction->setStatusTip(tr("DSC_SVTK_SURFACES_SETTINGS")); - connect(anAction, SIGNAL(activated()), this, SLOT(onSurfacesSettings())); - mgr->registerAction( anAction, SurfacesSettingsId ); - // Start recording myStartAction = new QtxAction(tr("MNU_SVTK_RECORDING_START"), theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_START" ) ), @@ -2021,7 +1827,6 @@ void SVTK_ViewWindow::createToolBar() QtxActionToolMgr* mgr = toolMgr(); mgr->append( DumpId, myToolBar ); - mgr->append( Mode2DId, myToolBar ); mgr->append( SwitchInteractionStyleId, myToolBar ); mgr->append( ViewTrihedronId, myToolBar ); @@ -2056,17 +1861,12 @@ void SVTK_ViewWindow::createToolBar() mgr->append( GraduatedAxes, myToolBar ); mgr->append( ViewParametersId, myToolBar ); - mgr->append( SurfacesSettingsId, myToolBar ); mgr->append( ProjectionModeId, myToolBar ); mgr->append( StartRecordingId, myRecordingToolBar ); mgr->append( PlayRecordingId, myRecordingToolBar ); mgr->append( PauseRecordingId, myRecordingToolBar ); mgr->append( StopRecordingId, myRecordingToolBar ); - - // the following actions are enabled on demand - getAction( Mode2DId )->setVisible( false ); - getAction( SurfacesSettingsId )->setVisible( false ); } void SVTK_ViewWindow::onUpdateRate(bool theIsActivate) @@ -2231,134 +2031,3 @@ void SVTK_ViewWindow::hideEvent( QHideEvent * theEvent ) { emit Hide( theEvent ); } - -/*! - Show/hide the specified action -*/ -void SVTK_ViewWindow::SetActionVisible( const int theActionId, - const bool theIsVisible ) -{ - if( QtxAction* anAction = getAction( theActionId ) ) - anAction->setVisible( theIsVisible ); -} - -/*! - Set the normal axis for the Mode2D -*/ -void SVTK_ViewWindow::SetMode2DNormalAxis( const int theAxis ) -{ - myMode2DNormalAxis = theAxis; -} - -/*! - Change the surfaces settings -*/ -void SVTK_ViewWindow::onSurfacesSettings() -{ - vtkRenderer* aRenderer = getRenderer(); - if( !aRenderer ) - return; - - QList< Plot3d_Actor* > aSurfaces; - QStringList aNameList; - vtkActor* anActor = 0; - - VTK::ActorCollectionCopy aCopy( aRenderer->GetActors() ); - vtkActorCollection* aCollection = aCopy.GetActors(); - aCollection->InitTraversal(); - while( anActor = aCollection->GetNextActor() ) - { - if( Plot3d_Actor* aSurface = dynamic_cast( anActor ) ) - { - aSurfaces << aSurface; - if( vtkScalarBarActor* aScalarBar = aSurface->GetScalarBarActor().GetPointer() ) - aNameList << aScalarBar->GetTitle(); - } - } - - QVector< QString > aTexts = aNameList.toVector(); - - Plot3d_SetupSurfacesDlg aDlg; - aDlg.SetParameters( aTexts ); - - if ( aDlg.exec() != QDialog::Accepted ) - return; - - // Note: Indexes retrieved from dialog do not correspond to the real indexes of - // plot 3d surfaces. They correspond to the user actions. For example, if user removes - // first surface in dialog's table two times. Then contents of list of indexes is - // equal (1, 1) although first and surfaces curves must be removed. - const QList< int >& toRemove = aDlg.GetRemovedIndexes(); - QList< int >::const_iterator aRemIter; - for ( aRemIter = toRemove.begin(); aRemIter != toRemove.end(); ++aRemIter ) - { - int anIndex = *aRemIter; - if ( anIndex >= 0 && anIndex < (int)aSurfaces.count() ) - { - Plot3d_Actor* aSurface = aSurfaces[ anIndex ]; - aSurfaces.removeAt( anIndex ); - aSurface->RemoveFromRender( aRenderer ); - aSurface->Delete(); - } - } - - QMap< int, Plot3d_Actor* > anIndexToSurface; - QList< Plot3d_Actor* >::iterator aSurfIter; - int i; - for ( i = 0, aSurfIter = aSurfaces.begin(); aSurfIter != aSurfaces.end(); ++aSurfIter, ++i ) - anIndexToSurface[ i ] = *aSurfIter; - - aDlg.GetParameters( aTexts ); - - int n; - for ( i = 0, n = aTexts.size(); i < n; i++ ) - { - Plot3d_Actor* aSurface = anIndexToSurface[ i ]; - QString aText = aTexts[ i ]; - if( vtkScalarBarActor* aScalarBar = aSurface->GetScalarBarActor().GetPointer() ) - aScalarBar->SetTitle( aText.toLatin1().constData() ); - } - - vtkFloatingPointType aGlobalBounds[6] = { VTK_DOUBLE_MAX, VTK_DOUBLE_MIN, - VTK_DOUBLE_MAX, VTK_DOUBLE_MIN, - VTK_DOUBLE_MAX, VTK_DOUBLE_MIN }; - - for ( i = 0, aSurfIter = aSurfaces.begin(); aSurfIter != aSurfaces.end(); ++aSurfIter, ++i ) - { - if( Plot3d_Actor* aSurface = *aSurfIter ) - { - vtkFloatingPointType aBounds[6]; - aSurface->GetBounds( aBounds ); - aGlobalBounds[0] = qMin( aGlobalBounds[0], aBounds[0] ); - aGlobalBounds[1] = qMax( aGlobalBounds[1], aBounds[1] ); - aGlobalBounds[2] = qMin( aGlobalBounds[2], aBounds[2] ); - aGlobalBounds[3] = qMax( aGlobalBounds[3], aBounds[3] ); - aGlobalBounds[4] = qMin( aGlobalBounds[4], aBounds[4] ); - aGlobalBounds[5] = qMax( aGlobalBounds[5], aBounds[5] ); - } - } - - double aDX = aGlobalBounds[1] - aGlobalBounds[0]; - double aDY = aGlobalBounds[3] - aGlobalBounds[2]; - double aDZ = aGlobalBounds[5] - aGlobalBounds[4]; - - double aScale[3]; - GetScale( aScale ); // take into account the current scale - aDX = fabs( aScale[0] ) > DBL_EPSILON ? aDX / aScale[0] : aDX; - aDY = fabs( aScale[1] ) > DBL_EPSILON ? aDY / aScale[1] : aDY; - aDZ = fabs( aScale[2] ) > DBL_EPSILON ? aDZ / aScale[2] : aDZ; - - aScale[0] = fabs( aDX ) > DBL_EPSILON ? 1.0 / aDX : 1.0; - aScale[1] = fabs( aDY ) > DBL_EPSILON ? 1.0 / aDY : 1.0; - aScale[2] = fabs( aDZ ) > DBL_EPSILON ? 1.0 / aDZ : 1.0; - SetScale( aScale ); - onFitAll(); -} - -/*! - Fit 2D surfaces to the specified data range -*/ -void SVTK_ViewWindow::onFitData() -{ - // to do -} diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index 14b3e6cea..1ec37344f 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -76,15 +76,14 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow Q_OBJECT; public: - enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, + enum { FirstId = 0, + DumpId = FirstId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, ChangeRotationPointId, RotationId, FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate, ProjectionModeId, ViewParametersId, SwitchInteractionStyleId, - Mode2DId, SurfacesSettingsId, - StartRecordingId, PlayRecordingId, PauseRecordingId, StopRecordingId }; - - enum Axis { AxisX = 0, AxisY, AxisZ }; + StartRecordingId, PlayRecordingId, PauseRecordingId, StopRecordingId, + LastId }; public: //! To construct #SVTK_ViewWindow instance @@ -98,7 +97,7 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow virtual void Initialize(SVTK_ViewModelBase* theModel); //! Fill the context menu - void contextMenuPopup( QMenu* thePopup ); + virtual void contextMenuPopup( QMenu* thePopup ); //! Get #SVTK_View SVTK_View* getView(); @@ -262,19 +261,6 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow //! To invoke a VTK event on #SVTK_RenderWindowInteractor instance void InvokeEvent(unsigned long theEvent, void* theCallData); - //! Show/hide the specified action - void SetActionVisible( const int theActionId, - const bool theIsVisible ); - - //! Set the normal axis for the 2D mode - void SetMode2DNormalAxis( const int theAxis ); - - //! Check that 2D mode is active - bool isMode2D() const; - - //! Clear 2D/3D view state - void clearViewState( const bool theIs2D ); - signals: void Show( QShowEvent * ); void Hide( QHideEvent * ); @@ -311,11 +297,6 @@ public slots: void onViewParameters(bool theIsActivate); void onSwitchInteractionStyle(bool theOn); - void onMode2D(bool theOn); - - void onSurfacesSettings(); - - void onFitData(); void onStartRecording(); void onPlayRecording(); @@ -379,25 +360,6 @@ protected: void doSetVisualParameters( const QString& ); void SetEventDispatcher(vtkObject* theDispatcher); - struct ViewState - { - bool IsInitialized; - double Position[3]; - double FocalPoint[3]; - double ViewUp[3]; - double ParallelScale; - bool IsTrihedronDisplayed; - - ViewState() - { - IsInitialized = false; - ParallelScale = 0.0; - IsTrihedronDisplayed = false; - } - }; - void storeViewState( ViewState& theViewState ); - bool restoreViewState( ViewState theViewState ); - QImage dumpViewContent(); virtual QString filter() const; @@ -406,8 +368,8 @@ protected: virtual bool action( const int ); QtxAction* getAction( int ) const; - void createToolBar(); - void createActions(SUIT_ResourceMgr* theResourceMgr); + virtual void createToolBar(); + virtual void createActions(SUIT_ResourceMgr* theResourceMgr); SVTK_View* myView; //SVTK_MainWindow* myMainWindow; @@ -441,11 +403,6 @@ protected: int myToolBar; int myRecordingToolBar; - bool myMode2D; - int myMode2DNormalAxis; - ViewState myStored2DViewState; - ViewState myStored3DViewState; - private: QImage myDumpImage; }; diff --git a/src/SVTK/resources/SVTK_images.ts b/src/SVTK/resources/SVTK_images.ts index 4014ba59c..38b7285ff 100644 --- a/src/SVTK/resources/SVTK_images.ts +++ b/src/SVTK/resources/SVTK_images.ts @@ -33,10 +33,6 @@ ICON_SVTK_STYLE_SWITCH vtk_view_style_switch.png - - ICON_SVTK_SURFACES_SETTINGS - vtk_view_surfaces_settings.png - ICON_SVTK_RECORDING_START vtk_view_recording_start.png @@ -53,13 +49,5 @@ ICON_SVTK_RECORDING_STOP vtk_view_recording_stop.png - - ICON_SVTK_MODE_2D - vtk_view_mode_2d.png - - - ICON_SVTK_MINUS - vtk_view_minus.png - diff --git a/src/SVTK/resources/SVTK_msg_en.ts b/src/SVTK/resources/SVTK_msg_en.ts index 987cb7c0f..024d0bc45 100644 --- a/src/SVTK/resources/SVTK_msg_en.ts +++ b/src/SVTK/resources/SVTK_msg_en.ts @@ -177,22 +177,6 @@ MNU_SVTK_STYLE_SWITCH Interaction Style Switch - - DSC_SVTK_MODE_2D - Toggle 2D mode - - - MNU_SVTK_MODE_2D - Toggle 2D mode - - - DSC_SVTK_SURFACES_SETTINGS - Change the surfaces settings - - - MNU_SVTK_SURFACES_SETTINGS - Surfaces settings - SVTK_CubeAxesDlg @@ -629,65 +613,4 @@ Please, refer to the documentation. Change background... - - Plot3d_FitDataDlg - - FIT_HORIZONTAL - Fit horizontally - - - MIN_VALUE_LAB - Min: - - - VERTICAL_AXIS - Vertical axis - - - MAX_VALUE_LAB - Max: - - - HORIZONTAL_AXIS - Horizontal axis - - - VERTICAL_LEFT_AXIS - Vertical left axis - - - FIT_ALL - Fit both - - - VERTICAL_RIGHT_AXIS - Vertical right axis - - - FIT_VERTICAL - Fit vertically - - - - Plot3d_SetupSurfacesDlg - - SETUP_SURFACES - Setup surfaces - - - PARAMETERS - Parameters - - - TEXT - Text - - - - Plot3d_ViewManager - - PLOT3D_VIEW_TITLE - Plot3d scene:%M - viewer:%V - -