Skip to content
0
  • Recent
  • Tags
  • Popular
  • SAMSON Connect
  • Get SAMSON
  • Recent
  • Tags
  • Popular
  • SAMSON Connect
  • Get SAMSON
Collapse
SAMSON Forum
  1. Home
  2. Develop
  3. GUI
  4. The use of displayText function

The use of displayText function

Scheduled Pinned Locked Moved GUI
7 Posts 2 Posters 6.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P
    P
    Piriziwè
    wrote on last edited by
    #1

    I would like to display a text at the same position as atoms (e.g: display three atoms' serial number). I looked at displayText(std::string text, const SBPosition3 &position, std::string fontFamily, int fontSize, float ∗ color) function but I have some compilation errors. Please, would you mind giving me an example of using this function?

    1 Reply Last reply
    0
    • StephaneS
      StephaneS
      Stephane
      wrote on last edited by Stephane
      #2

      Starting with SAMSON 0.6.0, the displayText function takes a QFont instead of a std::string (see the SAMSON class in SDK/0.6.0/include/Facade/SAMSON/SAMSON.hpp, or the documentation at https://documentation.samson-connect.net), to give developers more control. An example would thus be to include the following lines in the display function of e.g. a visual model (derived from SBVisualModel) or a label (derived from SBLabel):

      float color[4] = { 1.0, 1.0, 0.5, 1.0 }; // red, green, blue, alpha
      SAMSON::displayText("Hello world", SBPosition3(SBQuantity::angstrom(0.0), SBQuantity::angstrom(0.0), SBQuantity::angstrom(0.0)), QFont("Segoe UI", 60, 200), color);
      

      This would produce the following text at the origin:
      0_1512049266956_HelloWorld.png

      P 2 Replies Last reply
      0
      • StephaneS Stephane

        Starting with SAMSON 0.6.0, the displayText function takes a QFont instead of a std::string (see the SAMSON class in SDK/0.6.0/include/Facade/SAMSON/SAMSON.hpp, or the documentation at https://documentation.samson-connect.net), to give developers more control. An example would thus be to include the following lines in the display function of e.g. a visual model (derived from SBVisualModel) or a label (derived from SBLabel):

        float color[4] = { 1.0, 1.0, 0.5, 1.0 }; // red, green, blue, alpha
        SAMSON::displayText("Hello world", SBPosition3(SBQuantity::angstrom(0.0), SBQuantity::angstrom(0.0), SBQuantity::angstrom(0.0)), QFont("Segoe UI", 60, 200), color);
        

        This would produce the following text at the origin:
        0_1512049266956_HelloWorld.png

        P
        P
        Piriziwè
        wrote on last edited by
        #3

        @stephane-redon Thank you, Sir. It is really helpful

        1 Reply Last reply
        0
        • StephaneS Stephane

          Starting with SAMSON 0.6.0, the displayText function takes a QFont instead of a std::string (see the SAMSON class in SDK/0.6.0/include/Facade/SAMSON/SAMSON.hpp, or the documentation at https://documentation.samson-connect.net), to give developers more control. An example would thus be to include the following lines in the display function of e.g. a visual model (derived from SBVisualModel) or a label (derived from SBLabel):

          float color[4] = { 1.0, 1.0, 0.5, 1.0 }; // red, green, blue, alpha
          SAMSON::displayText("Hello world", SBPosition3(SBQuantity::angstrom(0.0), SBQuantity::angstrom(0.0), SBQuantity::angstrom(0.0)), QFont("Segoe UI", 60, 200), color);
          

          This would produce the following text at the origin:
          0_1512049266956_HelloWorld.png

          P
          P
          Piriziwè
          wrote on last edited by
          #4

          @stephane-redon I tried with a visual model and this is what I got as result:
          0_1513092943079_result1.png

          I would like to get this kind of result (for instance: put on each atom its serial number):
          0_1513093026447_image1.png

          Is it possible? I am looking for the way to add a label like SAMSON ruler element does.

          Thank you in advance

          1 Reply Last reply
          0
          • StephaneS
            StephaneS
            Stephane
            wrote on last edited by
            #5

            Could you please check to see what happens when you add an atom in the document? There might be an issue when you only have a visual model that displays text, and nothing else. Once this works, it should be easy to position the text on the atoms by sending their position to the displayText function.

            P 1 Reply Last reply
            0
            • StephaneS Stephane

              Could you please check to see what happens when you add an atom in the document? There might be an issue when you only have a visual model that displays text, and nothing else. Once this works, it should be easy to position the text on the atoms by sending their position to the displayText function.

              P
              P
              Piriziwè
              wrote on last edited by
              #6

              Hi @stephane-redon, sorry for my late response. When I add atoms, nothing happens, they are correctly added.

              I have a visual model that displays arrow on atoms. It reads coordinates from a file and then displays arrows. My problem is that I would like to displays arrows when the user clicks on a button. I tried the way a structural model is added to the active layer programmatically but it does not work. Please, would mind helping me with it?

              This is just an inspiration from how a structural model is added:

              SBMVisualModel* visualModel = new SBMVisualModel();
              visualModel->setName("VP_Arrows");
              
              SAMSON::beginHolding("Display vp by arrows");
              
              SEFleXibleVisualModel vModel; // this is my visual model
              vModel.fileName = vp_file; // this is to set the coordinates file
              
              //visualModel.display(); // I don't know if I need to call this method or not
              visualModel->addChild(vModel); // add my visual model to the SBMVisualModel
              
              visualModel->create();
              SAMSON::getActiveLayer()->addChild(visualModel); // add to the active layer
              

              If this is solved I think I could then display atoms' serial numbers

              Thank you in advance.

              P 1 Reply Last reply
              0
              • P Piriziwè

                Hi @stephane-redon, sorry for my late response. When I add atoms, nothing happens, they are correctly added.

                I have a visual model that displays arrow on atoms. It reads coordinates from a file and then displays arrows. My problem is that I would like to displays arrows when the user clicks on a button. I tried the way a structural model is added to the active layer programmatically but it does not work. Please, would mind helping me with it?

                This is just an inspiration from how a structural model is added:

                SBMVisualModel* visualModel = new SBMVisualModel();
                visualModel->setName("VP_Arrows");
                
                SAMSON::beginHolding("Display vp by arrows");
                
                SEFleXibleVisualModel vModel; // this is my visual model
                vModel.fileName = vp_file; // this is to set the coordinates file
                
                //visualModel.display(); // I don't know if I need to call this method or not
                visualModel->addChild(vModel); // add my visual model to the SBMVisualModel
                
                visualModel->create();
                SAMSON::getActiveLayer()->addChild(visualModel); // add to the active layer
                

                If this is solved I think I could then display atoms' serial numbers

                Thank you in advance.

                P
                P
                Piriziwè
                wrote on last edited by
                #7

                @Stephane-Redon, it's done :) Thanks. Here's what I did:

                SEFleXibleVisualModel* model = new SEFleXibleVisualModel(vp_file, "vp"); // my visual model
                model->setName("VP_Arrows");
                
                SAMSON::beginHolding("Display vp by arrows");
                SAMSON::hold(model);
                
                model->create();
                SAMSON::getActiveLayer()->addChild(model);
                
                // stop holding changes to the document
                SAMSON::endHolding();
                
                1 Reply Last reply
                0

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Login or register to search.
                • First post
                  Last post