Change the Orientation of 3D coordinate system

Hello guys.

I am using OpenGL to do an animation about rolling 3D coordinate OXYZ from A to B to C.
Input: coordinate of cube (cube’s center): (0,0,0), (1,0,0) , (2,0,0), the cube rolling along its edge
so the coordinate of cube center will rotate along the curve as the dash line.
I attached the picture below to describe my problem.


Problem :
I created a function call DrawCoordSystem to draw Oxyz of the cube center.
I could do rolling from 1st position to 2nd position; HOWEVER, at the 2nd rolling, when I call the DrawCoordSystem it will create oxyz within the same orientation (at the wrong way in the image)

I do not know how to save the orientation of oxyz after the 1st rolling to continue the 2nd rolling.

Please give me some of the solutions.
Thanks a lot